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.
This commit is contained in:
Kumi 2023-09-12 09:17:59 +02:00
parent 94b2457a39
commit 9abea6e3f8
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 5 additions and 3 deletions

View file

@ -29,6 +29,5 @@ RESPONSE_CALLBACKS = {
}
EVENT_CALLBACKS = {
Event: test_callback,
MessageEvent: message_callback,
}

View file

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