diff --git a/bot.py b/bot.py index 1ac7cee..e13f766 100644 --- a/bot.py +++ b/bot.py @@ -25,6 +25,7 @@ from nio import ( LoginResponse, InviteMemberEvent, MegolmEvent, + ReactionEvent, RoomEncryptedFile, RoomEncryptedImage, RoomMessageFile, @@ -1268,7 +1269,7 @@ class Bot: self.client.add_event_callback(self.on_file_message, RoomMessageFile) self.client.add_event_callback(self.on_encrypted_file_message, RoomEncryptedFile) self.client.add_event_callback(self.on_room_unknown, RoomMessageUnknown) - self.client.add_event_callback(self.on_reaction, UnknownEvent) + self.client.add_event_callback(self.on_reaction, ReactionEvent) self.client.add_response_callback(self.on_sync, SyncResponse) self.client.add_to_device_callback(self.on_key_verification, KeyVerificationStart) self.client.add_to_device_callback(self.on_key_verification, KeyVerificationKey) @@ -1464,23 +1465,15 @@ class Bot: self.client.verify_device(device) logger.info("Auto-trusted device %s of %s", device.device_id, user_id) - async def on_reaction(self, room, event: UnknownEvent): + async def on_reaction(self, room, event: ReactionEvent): """Handle reaction events for pipeline approval flow.""" if event.sender == BOT_USER: return if not self._sync_token_received: return - source = event.source or {} - if source.get("type") != "m.reaction": - return - content = source.get("content", {}) - relates_to = content.get("m.relates_to", {}) - if relates_to.get("rel_type") != "m.annotation": - return - - event_id = relates_to.get("event_id", "") - reaction_key = relates_to.get("key", "") + event_id = event.reacts_to + reaction_key = event.key # Check if this reaction is for a pipeline approval if not self.cron_scheduler: