From 84de0f7eb5975c9ec111a099cfbcc4839df890be Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 8 Nov 2024 13:19:28 +0100 Subject: [PATCH] fix(bot): prevent self-sending of "!apply" commands Ensure that the bot ignores "!apply" commands sent by itself to avoid unnecessary processing and potential loops. Also, add logging for message reactions to aid in debugging and monitoring. --- src/matrix_applicationbot/classes/bot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/matrix_applicationbot/classes/bot.py b/src/matrix_applicationbot/classes/bot.py index 8b35d6d..ee1a2ed 100644 --- a/src/matrix_applicationbot/classes/bot.py +++ b/src/matrix_applicationbot/classes/bot.py @@ -63,7 +63,7 @@ class ApplicationBot: if body and body.startswith("!supportbot"): await self.handle_command(room, sender, body) - elif body and body.startswith("!apply"): + elif body and body.startswith("!apply") and not sender == self.client.user_id: await self.process_application(room, sender, event) else: await self.relay_message(room, sender, event) @@ -221,6 +221,8 @@ class ApplicationBot: # React to the message with approve, reject, and invite emojis if isinstance(sent_message, RoomMessageText): + logging.debug(f"Reacting to message {sent_message.event_id}") + await self.client.room_send( room.room_id, "m.reaction",