Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DisableAccount.cs
1using System.Text.RegularExpressions;
2using System.Threading.Tasks;
4
6{
11 {
16 : base(@"^disable\s+account\s+(?'Name'[^\s]+)$")
17 {
18 }
19
23 public override string Name => "Disable";
24
33 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details,
34 ResponseCallbackHandler ResponseCallback)
35 {
36 int c = Arguments.Length;
37 string Name = c < 2 ? string.Empty : Arguments[1];
38
39 Account Account = await XmppServerModule.PersistenceLayer.GetAccountEx(Name);
40
41 if (Account is null)
42 await XmppServerModule.SendErrorMessage("An account with name `" + Name + "` does not exist.", string.Empty, ResponseCallback);
43 else
44 {
45 Account.Enabled = false;
46 await Persistence.Database.Update(Account);
47 await ResponseCallback("Account `" + Name + "` has been disabled.", string.Empty);
48 }
49 }
50
55 public override HelpItem[] GetHelp()
56 {
57 return new HelpItem[]
58 {
59 new HelpItem("disable account NAME", "Disables an existing account named `NAME`. It is not possible to log into a disabled account.")
60 };
61 }
62 }
63}
override HelpItem[] GetHelp()
Gets help about the command.
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
An administrative command whose syntax is validated with a regular expression.
Definition: CommandRegEx.cs:12
Contains an item of information about a command.
Definition: HelpItem.cs:9
Contains information about a broker account.
Definition: Account.cs:28
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.