2using System.Reflection.Metadata;
3using System.Text.RegularExpressions;
4using System.Threading.Tasks;
13 private readonly Regex expression;
22 this.expression =
new Regex(RegularExpression, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase);
28 public abstract string Name {
get; }
45 if (Details is Match Match)
46 return this.
Execute(State, Arguments, OrgMessage, Match, ResponseCallback);
48 throw new ArgumentException(
"Expected a Regex Match object.", nameof(Details));
68 public virtual bool AppliesTo(
string CommandLine,
string[] Arguments, out
object Details)
70 Match M = this.expression.Match(CommandLine);
72 return M.Success && M.Index == 0 && M.Length == CommandLine.Length;
An administrative command whose syntax is validated with a regular expression.
abstract Task Execute(ChatState State, string[] Arguments, string OrgMessage, Match Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
abstract string Name
Command name
virtual string[] Aliases
Optional set of aliases. Can be null.
virtual bool AppliesTo(string CommandLine, string[] Arguments, out object Details)
If the command is applicable to the given command line.
virtual Task Execute(ChatState State, string[] Arguments, string OrgMessage, object Details, ResponseCallbackHandler ResponseCallback)
Executes the command.
CommandRegEx(string RegularExpression)
An administrative command whose syntax is validated with a regular expression.
abstract HelpItem[] GetHelp()
Gets help about the command.
Contains an item of information about a command.
Basic interface for administration commands
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.