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.
This commit is contained in:
Kumi 2024-11-08 09:31:36 +01:00
parent 005a407d93
commit 1b0d3d4ddd
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -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):