1using System.Collections.Generic;
3using System.Text.RegularExpressions;
4using System.Threading.Tasks;
21 : base(
"^notify(\\s+(?'SubCommand'(add|remove)))?(\\s+(([^@/<>'\\\"\\s]+)@)([^@/<> '\\\"\\s]+))*$")
28 public override string Name =>
"Notify";
38 public override async Task
Execute(
ChatState State,
string[] Arguments,
string OrgMessage, Match Details,
42 int c = Arguments.Length;
46 StringBuilder Markdown =
new StringBuilder();
54 Markdown.Append(
"; ");
61 await ResponseCallback(Markdown.ToString(),
string.Empty);
65 List<CaseInsensitiveString> Addresses =
new List<CaseInsensitiveString>();
66 List<CaseInsensitiveString> AddressesOrg =
new List<CaseInsensitiveString>();
69 bool ContainsSelf =
false;
71 bool Relative =
false;
74 switch (Arguments[0].ToLower())
89 AddressesOrg.Add(Jid);
92 Addresses.AddRange(AddressesOrg);
96 string JID = Arguments[i++];
98 if (cs == IoTGateway.Gateway.XmppClient.BareJID)
103 if (Addresses.Remove(cs))
108 if (!Addresses.Contains(cs))
112 if (Relative || !AddressesOrg.Contains(cs))
120 if (Jid == BareSenderJid)
124 if (ContainsSelf || !IsFromBareJid)
126 IoTGateway.Setup.NotificationConfiguration.Instance.Addresses = Addresses.ToArray();
127 await Persistence.Database.Update(IoTGateway.Setup.NotificationConfiguration.Instance);
130 await ResponseCallback(
"Notification list updated.",
string.Empty);
132 await ResponseCallback(
"Notification list up to date.",
string.Empty);
135 await
XmppServerModule.SendErrorMessage(
"Must be included: " + BareSenderJid,
string.Empty, ResponseCallback);
147 new HelpItem(
"notify",
"Lists recipients of JIDs that will be notified of events on the broker. They also have access to chat admin interface."),
148 new HelpItem(
"notify[ JID[ JID2[...]]]",
"Sets the recipients of notifications, and those with access to chat admin interface. You cannot remove yourself from the list."),
149 new HelpItem(
"notify add [ JID[ JID2[...]]]",
"Adds new recipients to the list of notification recipients."),
150 new HelpItem(
"notify remove [ JID[ JID2[...]]]",
"Removes recipients from the list of notification recipients.")
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static string GetBareJID(string JID)
Gets the Bare JID from a JID, which may be a Full JID.
static readonly Regex BareJidRegEx
Regular expression for Bare JIDs
Represents a case-insensitive string.
string LowerCase
Lower-case representation of the case-insensitive string.
An administrative command whose syntax is validated with a regular expression.
Displays who to notify about server events. Can also be used to update list of whom to notify....
Notify()
Displays who to notify about server events. Can also be used to update list of whom to notify....
override string Name
Command name
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.
Contains an item of information about a command.
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.