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.
This commit is contained in:
Kumi 2024-05-18 21:36:06 +02:00
parent e2e31060ce
commit df567d005e
Signed by: kumi
GPG key ID: ECBCC9082395383F
3 changed files with 1 additions and 31 deletions

View file

@ -1,32 +1,24 @@
from nio import ( from nio import (
RoomMessageText, RoomMessageText,
InviteEvent, InviteEvent,
Event,
SyncResponse, SyncResponse,
JoinResponse, JoinResponse,
RoomMemberEvent, RoomMemberEvent,
Response,
MegolmEvent,
KeysQueryResponse
) )
from .test import test_callback
from .sync import sync_callback from .sync import sync_callback
from .invite import room_invite_callback from .invite import room_invite_callback
from .join import join_callback from .join import join_callback
from .message import message_callback from .message import message_callback
from .roommember import roommember_callback from .roommember import roommember_callback
from .test_response import test_response_callback
RESPONSE_CALLBACKS = { RESPONSE_CALLBACKS = {
#Response: test_response_callback,
SyncResponse: sync_callback, SyncResponse: sync_callback,
JoinResponse: join_callback, JoinResponse: join_callback,
} }
EVENT_CALLBACKS = { EVENT_CALLBACKS = {
#Event: test_callback,
InviteEvent: room_invite_callback, InviteEvent: room_invite_callback,
RoomMessageText: message_callback, RoomMessageText: message_callback,
RoomMemberEvent: roommember_callback, RoomMemberEvent: roommember_callback,
} }

View file

@ -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__}")

View file

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