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;
2using System.Text.RegularExpressions;
3using System.Threading.Tasks;
5
7{
12 {
17 : base(@"^disable\s+account\s+(?'Name'[^\s]+)$")
18 {
19 }
20
24 public override string Name => "Disable";
25
34 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details,
35 ResponseCallbackHandler ResponseCallback)
36 {
37 int c = Arguments.Length;
38 string Name = c < 2 ? string.Empty : Arguments[1];
39
40 Account Account = await XmppServerModule.PersistenceLayer.GetAccountEx(Name);
41
42 if (Account is null)
43 await XmppServerModule.SendErrorMessage("An account with name `" + Name + "` does not exist.", string.Empty, ResponseCallback);
44 else
45 {
46 Account.Enabled = false;
47 Account.Updated = DateTime.UtcNow;
48
49 await Persistence.Database.Update(Account);
50 await ResponseCallback("Account `" + Name + "` has been disabled.", string.Empty);
51 }
52 }
53
58 public override HelpItem[] GetHelp()
59 {
60 return new HelpItem[]
61 {
62 new HelpItem("disable account NAME", "Disables an existing account named `NAME`. It is not possible to log into a disabled account.")
63 };
64 }
65 }
66}
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:41
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.