diff options
author | Rory& <root@rory.gay> | 2024-03-15 18:10:58 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-03-15 18:11:18 +0100 |
commit | 096375344ef87fe53ca009b7a7eaa34c9c9f5407 (patch) | |
tree | 76d666cd6961ca04ae9e91e47c43d91eed27a87a /Utilities/LibMatrix.Utilities.Bot/Interfaces | |
parent | Fix README (diff) | |
download | LibMatrix-096375344ef87fe53ca009b7a7eaa34c9c9f5407.tar.xz |
Bot changes, move named filters to subclass
Diffstat (limited to 'Utilities/LibMatrix.Utilities.Bot/Interfaces')
-rw-r--r-- | Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs | 14 | ||||
-rw-r--r-- | Utilities/LibMatrix.Utilities.Bot/Interfaces/ICommand.cs | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs index e65f86d..062e99f 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs @@ -19,4 +19,18 @@ public class CommandContext { public required AuthenticatedHomeserverGeneric Homeserver { get; set; } public async Task<EventIdResponse> Reply(RoomMessageEventContent content) => await Room.SendMessageEventAsync(content); +} + +public class CommandResult { + public required bool Success { get; set; } + public Exception? Exception { get; set; } + public required CommandResultType Result { get; set; } + public required CommandContext Context { get; set; } + + public enum CommandResultType { + Success, + Failure_Exception, + Failure_NoPermission, + Failure_InvalidCommand + } } \ No newline at end of file diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/ICommand.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/ICommand.cs index 453a8fe..4626a23 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/ICommand.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/ICommand.cs @@ -1,10 +1,20 @@ +using System.Collections.Frozen; +using System.Collections.Immutable; + namespace LibMatrix.Utilities.Bot.Interfaces; public interface ICommand { public string Name { get; } + public string[]? Aliases { get; } public string Description { get; } + public bool Unlisted { get; } public Task<bool> CanInvoke(CommandContext ctx) => Task.FromResult(true); public Task Invoke(CommandContext ctx); +} + + +public interface ICommandGroup : ICommand { + public IImmutableList<ICommand> SubCommands { get; } } \ No newline at end of file |