1using System.Collections.Generic;
3using System.Text.RegularExpressions;
4using System.Threading.Tasks;
20 : base(
@"^create\s+account\s+(?'Name'[^\s]+)(\s+(?'Password'[^\s]+))?(\s+(?'EMail'[^\s]+))?(\s+(?'PhoneNr'[^\s]+))?$")
27 public override string Name =>
"Create";
37 public override async Task
Execute(
ChatState State,
string[] Arguments,
string OrgMessage, Match Details,
40 int c = Arguments.Length;
41 string Name = c < 2 ? string.Empty : Arguments[1];
42 string Password = c < 3 ? string.Empty : Arguments[2];
43 string EMail = c < 4 ? string.Empty : Arguments[3];
44 string PhoneNr = c < 5 ? string.Empty : Arguments[4];
46 KeyValuePair<IAccount, string[]> P = await
XmppServerModule.PersistenceLayer.CreateAccount(
string.Empty,
Name,
55 await
XmppServerModule.SendErrorMessage(
"An account with name `" +
Name +
"` already exists.",
string.Empty, ResponseCallback);
57 string[] Alternatives = P.Value;
58 if (!(Alternatives is
null) && Alternatives.Length > 0)
60 StringBuilder Markdown =
new StringBuilder();
62 Markdown.AppendLine(
"Alternative name suggestions:");
63 Markdown.AppendLine();
65 foreach (
string Alternative
in Alternatives)
67 Markdown.Append(
"* `");
68 Markdown.Append(Alternative);
69 Markdown.AppendLine(
"`");
72 await ResponseCallback(Markdown.ToString(),
string.Empty);
77 StringBuilder Markdown =
new StringBuilder();
79 Markdown.AppendLine(
"Information for user:");
80 Markdown.AppendLine();
81 Markdown.AppendLine(
"| Account ||");
82 Markdown.AppendLine(
"|:----|:----|");
83 Markdown.Append(
"| Domain: | `");
85 Markdown.AppendLine(
"` |");
86 Markdown.Append(
"| Account: | `");
88 Markdown.AppendLine(
"` |");
89 Markdown.Append(
"| Password: | `");
91 Markdown.AppendLine(
"` |");
93 await ResponseCallback(Markdown.ToString(),
string.Empty);
105 new HelpItem(
"create account NAME[ PASSWORD[ EMAIL[ PHONE]]]",
"Creates a new account with the account name given by `NAME`. Optional `PASSWORD`, `EMAIL` and `PHONE` parameters can also be provided.")
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
Contains information about one XMPP address.
CaseInsensitiveString BareJid
Bare JID
Contains methods for simple hash calculations.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
CreateAccount()
Creates an account.
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
override string Name
Command name
override HelpItem[] GetHelp()
Gets help about the command.
An administrative command whose syntax is validated with a regular expression.
Contains an item of information about a command.
Service Module hosting the XMPP broker and its components.
CaseInsensitiveString UserName
User Name
Interface for XMPP user accounts.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.