start work to allow customizing command properties via configuration

This commit is contained in:
RaidMax
2020-01-26 18:06:50 -06:00
parent e6bdcc9012
commit 11ae91281f
16 changed files with 1061 additions and 587 deletions

View File

@ -0,0 +1,18 @@
namespace SharedLibraryCore.Commands
{
/// <summary>
/// Holds information about command args
/// </summary>
public class CommandArgument
{
/// <summary>
/// Name of the argument
/// </summary>
public string Name { get; set; }
/// <summary>
/// Indicates if the argument is required
/// </summary>
public bool Required { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,28 @@
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Interfaces;
using System.Threading.Tasks;
namespace SharedLibraryCore.Commands
{
/// <summary>
/// Generates a token for use in webfront login
/// </summary>
public class RequestTokenCommand : Command
{
public RequestTokenCommand() :
base("requesttoken", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GENERATETOKEN_DESC"], "rt", EFClient.Permission.Trusted, false)
{ }
public RequestTokenCommand(CommandConfiguration config, ITranslationLookup lookup) : base(config, lookup)
{
Name = "requesttoken";
Description = lookup["COMMANDS_GENERATETOKEN_DESC"];
Alias = "rt";
Permission = EFClient.Permission.Trusted;
RequiresTarget = false;
}
public override Task ExecuteAsync(GameEvent E)
{
var state = E.Owner.Manager.TokenAuthenticator.GenerateNextToken(E.Origin.NetworkId);
E.Origin.Tell(string.Format(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {Utilities.CurrentLocalization.LocalizationIndex["GLOBAL_MINUTES"]}", E.Origin.ClientId));
E.Origin.Tell(string.Format(_translationLookup["COMMANDS_GENERATETOKEN_SUCCESS"], state.Token, $"{state.RemainingTime} {_translationLookup["GLOBAL_MINUTES"]}", E.Origin.ClientId));
return Task.CompletedTask;
}

View File

@ -1,4 +1,6 @@
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Interfaces;
using System.Threading.Tasks;
namespace SharedLibraryCore.Commands
@ -12,14 +14,19 @@ namespace SharedLibraryCore.Commands
/// </summary>
public class UnlinkClientCommand : Command
{
public UnlinkClientCommand() :
base("unlinkclient", Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNLINK_CLIENT_DESC"], "uc", EFClient.Permission.Administrator, true)
{ }
public UnlinkClientCommand(CommandConfiguration config, ITranslationLookup lookup) : base(config, lookup)
{
Name = "unlinkclient";
Description = lookup["COMMANDS_UNLINK_CLIENT_DESC"];
Alias = "uc";
Permission = EFClient.Permission.Administrator;
RequiresTarget = true;
}
public override async Task ExecuteAsync(GameEvent E)
{
await E.Owner.Manager.GetClientService().UnlinkClient(E.Target.ClientId);
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_UNLINK_CLIENT_SUCCESS"].FormatExt(E.Target));
E.Origin.Tell(_translationLookup["COMMANDS_UNLINK_CLIENT_SUCCESS"].FormatExt(E.Target));
}
}
}