From 1b0d3d4ddd7365cb272eaf8f505cab801a41480e Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 8 Nov 2024 09:31:36 +0100 Subject: [PATCH] feat(bot): add reaction event handling Introduced a callback to handle reaction events in the bot. This enhancement improves user interaction by allowing the bot to respond to reactions, broadening its capability beyond basic message and member events. No impact on existing functionality. --- src/matrix_applicationbot/classes/bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/matrix_applicationbot/classes/bot.py b/src/matrix_applicationbot/classes/bot.py index e9fe101..484588f 100644 --- a/src/matrix_applicationbot/classes/bot.py +++ b/src/matrix_applicationbot/classes/bot.py @@ -12,6 +12,7 @@ from nio import ( RoomMemberEvent, RoomKickResponse, RoomInviteResponse, + ReactionEvent, ) import logging @@ -52,6 +53,8 @@ class ApplicationBot: self.client.add_event_callback(self.message_callback, RoomMessageMedia) self.client.add_event_callback(self.invite_callback, InviteMemberEvent) self.client.add_event_callback(self.member_event_callback, RoomMemberEvent) + self.client.add_event_callback(self.reaction_callback, ReactionEvent) + await self.client.sync_forever(timeout=30000) async def message_callback(self, room: MatrixRoom, event): @@ -448,7 +451,10 @@ class ApplicationBot: await self.client.room_send( room.room_id, "m.room.message", - {"msgtype": "m.text", "body": f"Application #{ticket_id} does not exist."}, + { + "msgtype": "m.text", + "body": f"Application #{ticket_id} does not exist.", + }, ) async def close_ticket(self, room, sender, command):