From 9abea6e3f87a88da2a2e9d60b3bb8d47c8b7b196 Mon Sep 17 00:00:00 2001 From: Kumi Date: Tue, 12 Sep 2023 09:17:59 +0200 Subject: [PATCH] Fix event handling in GPTBot class and add missing callback entries - Fix handling of events in the `handle_event` method of the `GPTBot` class. - Add missing callback entries in the `EVENT_CALLBACKS` dictionary. --- src/gptbot/callbacks/__init__.py | 1 - src/gptbot/classes/bot.py | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gptbot/callbacks/__init__.py b/src/gptbot/callbacks/__init__.py index edd9d9d..368c3d4 100644 --- a/src/gptbot/callbacks/__init__.py +++ b/src/gptbot/callbacks/__init__.py @@ -29,6 +29,5 @@ RESPONSE_CALLBACKS = { } EVENT_CALLBACKS = { - Event: test_callback, MessageEvent: message_callback, } \ No newline at end of file diff --git a/src/gptbot/classes/bot.py b/src/gptbot/classes/bot.py index 1964c88..948632d 100644 --- a/src/gptbot/classes/bot.py +++ b/src/gptbot/classes/bot.py @@ -461,10 +461,13 @@ class GPTBot: self.logger.log("Sent image", "debug") - async def handle_event(self, *args, **kwargs): + async def handle_event(self, event): """Handle an event.""" - self.logger.log(f"Handling event: {args} {kwargs}", "debug") + for event_type, callback in EVENT_CALLBACKS.items(): + if isinstance(event, event_type): + print(event_type, callback) + await callback(event, self) async def send_message( self, room: RoomID | str, message: str, notice: bool = False