1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-13 00:28:10 -05:00

add configurable command and broadcast command prefix for issue #149

This commit is contained in:
RaidMax
2020-07-31 20:40:03 -05:00
parent fc20e78066
commit 51202e7f8b
27 changed files with 403 additions and 61 deletions

View File

@ -1,4 +1,5 @@
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Exceptions;
using System;
using System.Collections.Generic;
@ -10,12 +11,14 @@ namespace SharedLibraryCore.Commands
{
public class CommandProcessing
{
public static async Task<Command> ValidateCommand(GameEvent E)
public static async Task<Command> ValidateCommand(GameEvent E, ApplicationConfiguration appConfig)
{
var loc = Utilities.CurrentLocalization.LocalizationIndex;
var Manager = E.Owner.Manager;
bool isBroadcast = E.Data.StartsWith(appConfig.BroadcastCommandPrefix);
int prefixLength = isBroadcast ? appConfig.BroadcastCommandPrefix.Length : appConfig.CommandPrefix.Length;
string CommandString = E.Data.Substring(1, E.Data.Length - 1).Split(' ')[0];
string CommandString = E.Data.Substring(prefixLength, E.Data.Length - prefixLength).Split(' ')[0];
E.Message = E.Data;
Command C = null;
@ -34,6 +37,8 @@ namespace SharedLibraryCore.Commands
throw new CommandException($"{E.Origin} entered unknown command \"{CommandString}\"");
}
C.IsBroadcast = isBroadcast;
if (!C.AllowImpersonation && E.ImpersonationOrigin != null)
{
E.ImpersonationOrigin.Tell(loc["COMMANDS_RUN_AS_FAIL"]);