diff --git a/Jenny/Handlers/CommandResultHandler.cs b/Jenny/Handlers/CommandResultHandler.cs
new file mode 100644
index 0000000..767944a
--- /dev/null
+++ b/Jenny/Handlers/CommandResultHandler.cs
@@ -0,0 +1,40 @@
+using ArcaneLibs;
+using LibMatrix.Helpers;
+using LibMatrix.Utilities.Bot.Interfaces;
+
+namespace Jenny.Handlers;
+
+public static class CommandResultHandler {
+ private static string binDir = FileUtils.GetBinDir();
+
+ public static async Task HandleAsync(CommandResult res) {
+ {
+ if (res.Success) return;
+ var room = res.Context.Room;
+ var hs = res.Context.Homeserver;
+ var msb = new MessageBuilder();
+ if (res.Result == CommandResult.CommandResultType.Failure_Exception) {
+ var angryEmojiPath = Path.Combine(binDir, "Resources", "Stickers", "JennyAngryPink.webp");
+ var hash = await FileUtils.GetFileSha384Async(angryEmojiPath);
+ var angryEmoji = await hs.NamedCaches.FileCache.GetOrSetValueAsync(hash, async () => {
+ await using var fs = File.OpenRead(angryEmojiPath);
+ return await hs.UploadFile("JennyAngryPink.webp", fs, "image/webp");
+ });
+ msb.WithCustomEmoji(angryEmoji, "JennyAngryPink")
+ .WithColoredBody("#EE4444", "An error occurred during the execution of this command")
+ .WithCodeBlock(res.Exception!.ToString(), "csharp");
+ }
+ // else if(res.Result == CommandResult.CommandResultType.) {
+ // msb.AddMessage(new RoomMessageEventContent("m.notice", "An error occurred during the execution of this command"));
+ // }
+ // var msg = res.Result switch {
+ // CommandResult.CommandResultType.Failure_Exception => MessageFormatter.FormatException("An error occurred during the execution of this command", res.Exception!)
+ // CommandResult.CommandResultType.Failure_NoPermission => new RoomMessageEventContent("m.notice", "You do not have permission to run this command!"),
+ // CommandResult.CommandResultType.Failure_InvalidCommand => new RoomMessageEventContent("m.notice", $"Command \"{res.Context.CommandName}\" not found!"),
+ // _ => throw new ArgumentOutOfRangeException()
+ // };
+
+ await room.SendMessageEventAsync(msb.Build());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Jenny/Handlers/InviteHandler.cs b/Jenny/Handlers/InviteHandler.cs
new file mode 100644
index 0000000..128de44
--- /dev/null
+++ b/Jenny/Handlers/InviteHandler.cs
@@ -0,0 +1,12 @@
+using LibMatrix.EventTypes.Spec;
+using LibMatrix.Utilities.Bot.Services;
+
+namespace Jenny.Handlers;
+
+public static class InviteHandler {
+ public static async Task HandleAsync(InviteHandlerHostedService.InviteEventArgs invite) {
+ var room = invite.Homeserver.GetRoom(invite.RoomId);
+ await room.JoinAsync();
+ await room.SendMessageEventAsync(new RoomMessageEventContent("m.notice", "Hello! I'm Jenny!"));
+ }
+}
\ No newline at end of file
|