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.
This commit is contained in:
Kumi 2024-11-08 13:19:28 +01:00
parent 372a719de0
commit 84de0f7eb5
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -63,7 +63,7 @@ class ApplicationBot:
if body and body.startswith("!supportbot"): if body and body.startswith("!supportbot"):
await self.handle_command(room, sender, body) 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) await self.process_application(room, sender, event)
else: else:
await self.relay_message(room, sender, event) await self.relay_message(room, sender, event)
@ -221,6 +221,8 @@ class ApplicationBot:
# React to the message with approve, reject, and invite emojis # React to the message with approve, reject, and invite emojis
if isinstance(sent_message, RoomMessageText): if isinstance(sent_message, RoomMessageText):
logging.debug(f"Reacting to message {sent_message.event_id}")
await self.client.room_send( await self.client.room_send(
room.room_id, room.room_id,
"m.reaction", "m.reaction",