about summary refs log tree commit diff
path: root/Utilities/LibMatrix.Utilities.Bot
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-04-24 10:07:47 +0200
committerRory& <root@rory.gay>2025-04-24 10:07:47 +0200
commitee7d348ff1736a3b534bdf1b39667e17fc4c68e2 (patch)
treee097c085c7d0003c9bf27fe8ef2f74f40c5b9196 /Utilities/LibMatrix.Utilities.Bot
parentMaubot ping compat, make json extensibility easier to use (diff)
downloadLibMatrix-ee7d348ff1736a3b534bdf1b39667e17fc4c68e2.tar.xz
Command handling fixes
Diffstat (limited to 'Utilities/LibMatrix.Utilities.Bot')
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs2
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs6
2 files changed, 4 insertions, 4 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs b/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs

index d55c67c..f29d6e9 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Commands/HelpCommand.cs
@@ -6,7 +6,7 @@ namespace LibMatrix.Utilities.Bot.Commands; public class HelpCommand(IServiceProvider services) : ICommand { public string Name { get; } = "help"; - public string[]? Aliases { get; } = new[] { "?" }; + public string[]? Aliases { get; } = ["?"]; public string Description { get; } = "Displays this help message"; public bool Unlisted { get; } diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
index a6b5654..9fe460b 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
@@ -142,7 +142,9 @@ public class CommandListenerHostedService : IHostedService { .OrderByDescending(x => x.Length) .FirstOrDefault(commandWithoutPrefix.StartsWith); var args = - usedCommand == null ? [] : commandWithoutPrefix[(usedCommand.Length + 1)..].Split(' '); + usedCommand == null || commandWithoutPrefix.Length <= usedCommand.Length + ? [] + : commandWithoutPrefix[(usedCommand.Length + 1)..].Split(' '); var ctx = new CommandContext { Room = room, MessageEvent = evt, @@ -153,8 +155,6 @@ public class CommandListenerHostedService : IHostedService { try { var command = _commands.SingleOrDefault(x => x.Name == ctx.CommandName || x.Aliases?.Contains(ctx.CommandName) == true); if (command == null) { - await room.SendMessageEventAsync( - new RoomMessageEventContent("m.notice", $"Command \"{ctx.CommandName}\" not found!")); return new() { Success = false, Result = CommandResult.CommandResultType.Failure_InvalidCommand,