From df567d005e394553f46d72eba575c23beddc4072 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 18 May 2024 21:36:06 +0200 Subject: [PATCH] refactor(callbacks): remove test callbacks and imports This commit streamlines the `callbacks` module by removing the debugging and testing related callbacks (`test_callback` and `test_response_callback`) along with their associated imports. It focuses on enhancing the clarity and maintainability of the callback handling by eliminating unused code paths and dependencies that were specifically used for testing purposes. This cleanup is part of an effort to mature the codebase and reduce potential confusion for new contributors by ensuring that only operational code is present in the production paths. This should not affect the existing functionality but will make future modifications and understanding of the callback mechanisms more straightforward. --- src/gptbot/callbacks/__init__.py | 10 +--------- src/gptbot/callbacks/test.py | 11 ----------- src/gptbot/callbacks/test_response.py | 11 ----------- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/gptbot/callbacks/test.py delete mode 100644 src/gptbot/callbacks/test_response.py diff --git a/src/gptbot/callbacks/__init__.py b/src/gptbot/callbacks/__init__.py index 77ec2a1..67e135d 100644 --- a/src/gptbot/callbacks/__init__.py +++ b/src/gptbot/callbacks/__init__.py @@ -1,32 +1,24 @@ from nio import ( RoomMessageText, InviteEvent, - Event, SyncResponse, JoinResponse, RoomMemberEvent, - Response, - MegolmEvent, - KeysQueryResponse ) -from .test import test_callback from .sync import sync_callback from .invite import room_invite_callback from .join import join_callback from .message import message_callback from .roommember import roommember_callback -from .test_response import test_response_callback RESPONSE_CALLBACKS = { - #Response: test_response_callback, SyncResponse: sync_callback, JoinResponse: join_callback, } EVENT_CALLBACKS = { - #Event: test_callback, InviteEvent: room_invite_callback, RoomMessageText: message_callback, RoomMemberEvent: roommember_callback, -} \ No newline at end of file +} diff --git a/src/gptbot/callbacks/test.py b/src/gptbot/callbacks/test.py deleted file mode 100644 index 137b61d..0000000 --- a/src/gptbot/callbacks/test.py +++ /dev/null @@ -1,11 +0,0 @@ -from nio import MatrixRoom, Event - -async def test_callback(room: MatrixRoom, event: Event, bot): - """Test callback for debugging purposes. - - Args: - room (MatrixRoom): The room the event was sent in. - event (Event): The event that was sent. - """ - - bot.logger.log(f"Test callback called: {room.room_id} {event.event_id} {event.sender} {event.__class__}") \ No newline at end of file diff --git a/src/gptbot/callbacks/test_response.py b/src/gptbot/callbacks/test_response.py deleted file mode 100644 index b0ed1c4..0000000 --- a/src/gptbot/callbacks/test_response.py +++ /dev/null @@ -1,11 +0,0 @@ -from nio import ErrorResponse - - -async def test_response_callback(response, bot): - if isinstance(response, ErrorResponse): - bot.logger.log( - f"Error response received ({response.__class__.__name__}): {response.message}", - "warning", - ) - else: - bot.logger.log(f"{response.__class__} response received", "debug")