1using System.Text.RegularExpressions;
2using System.Threading.Tasks;
16 : base(
@"^enable\s+key\s+(?'Key'[^\s]+)\s+(?'Accounts'\d{1,8})$")
23 public override string Name =>
"Enable";
33 public override async Task
Execute(
ChatState State,
string[] Arguments,
string OrgMessage, Match Details,
36 int c = Arguments.Length;
37 string Key = c < 2 ? string.Empty : Arguments[1];
38 int Accounts =
int.Parse(c < 3 ?
string.Empty : Arguments[2]);
43 await
XmppServerModule.SendErrorMessage(
"An API key with key `" + Key +
"` does not exist.",
string.Empty, ResponseCallback);
47 await Persistence.Database.Update(
ApiKey);
48 await ResponseCallback(
"API key `" + Key +
"` has been enabled for the creation of " +
Accounts.ToString() +
" accounts.",
string.Empty);
60 new HelpItem(
"enable key KEY NRACCOUNTS",
"Enables an existing API Key `KEY`, and allows `NRACCOUNTS` to be created with the key.")
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
override HelpItem[] GetHelp()
Gets help about the command.
override string Name
Command name
EnableKey()
Enables an API key.
An administrative command whose syntax is validated with a regular expression.
Contains an item of information about a command.
Collection of broker accounts
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.