about summary refs log tree commit diff
path: root/Utilities/LibMatrix.Utilities.Bot/Services
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-19 00:16:36 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-19 00:16:36 +0200
commitf5447484512d726f4403f0d7725777d0a95601fb (patch)
tree47fe88a4c021f62ff42663f6d8c5229e71d21813 /Utilities/LibMatrix.Utilities.Bot/Services
parentImprove README (diff)
downloadLibMatrix-f5447484512d726f4403f0d7725777d0a95601fb.tar.xz
Add more stuff, add unit tests
Diffstat (limited to '')
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
index df702f4..910db0a 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
@@ -1,7 +1,7 @@
+using LibMatrix.EventTypes.Spec;
 using LibMatrix.Helpers;
 using LibMatrix.Homeservers;
-using LibMatrix.StateEventTypes.Spec;
-using MediaModeratorPoC.Bot.Interfaces;
+using LibMatrix.Utilities.Bot.Interfaces;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Logging;
@@ -39,7 +39,7 @@ public class CommandListenerHostedService : IHostedService {
         _logger.LogInformation("Starting command listener!");
         _hs.SyncHelper.TimelineEventHandlers.Add(async @event => {
             try {
-                var room = await _hs.GetRoom(@event.RoomId);
+                var room = _hs.GetRoom(@event.RoomId);
                 // _logger.LogInformation(eventResponse.ToJson(indent: false));
                 if (@event is { Type: "m.room.message", TypedContent: RoomMessageEventContent message }) {
                     if (message is { MessageType: "m.text" }) {
@@ -48,7 +48,7 @@ public class CommandListenerHostedService : IHostedService {
                         if (messageContentWithoutReply.StartsWith(_config.Prefix)) {
                             var command = _commands.FirstOrDefault(x => x.Name == messageContentWithoutReply.Split(' ')[0][_config.Prefix.Length..]);
                             if (command == null) {
-                                await room.SendMessageEventAsync("m.room.message",
+                                await room.SendMessageEventAsync(
                                     new RoomMessageEventContent(messageType: "m.notice", body: "Command not found!"));
                                 return;
                             }
@@ -64,12 +64,12 @@ public class CommandListenerHostedService : IHostedService {
                                     await command.Invoke(ctx);
                                 }
                                 catch (Exception e) {
-                                    await room.SendMessageEventAsync("m.room.message",
+                                    await room.SendMessageEventAsync(
                                         MessageFormatter.FormatException("An error occurred during the execution of this command", e));
                                 }
                             }
                             else {
-                                await room.SendMessageEventAsync("m.room.message",
+                                await room.SendMessageEventAsync(
                                     new RoomMessageEventContent(messageType: "m.notice", body: "You do not have permission to run this command!"));
                             }
                         }