diff --git a/src/gptbot/callbacks/roommember.py b/src/gptbot/callbacks/roommember.py index 3016f03..8702516 100644 --- a/src/gptbot/callbacks/roommember.py +++ b/src/gptbot/callbacks/roommember.py @@ -1,7 +1,10 @@ -from nio import RoomMemberEvent, MatrixRoom +from nio import RoomMemberEvent, MatrixRoom, KeysUploadError async def roommember_callback(room: MatrixRoom, event: RoomMemberEvent, bot): - await bot.matrix_client.keys_upload() + try: + await bot.matrix_client.keys_upload() + except KeysUploadError as e: + bot.logger.log(f"Failed to upload keys: {e.message}") if event.membership == "leave": bot.logger.log(f"User {event.state_key} left room {room.room_id} - am I alone now?") diff --git a/src/gptbot/classes/openai.py b/src/gptbot/classes/openai.py index f4088fc..d9a1c99 100644 --- a/src/gptbot/classes/openai.py +++ b/src/gptbot/classes/openai.py @@ -294,8 +294,8 @@ class OpenAI: "tool_call_id": tool_call.id, "content": str(tool_response) }) - except StopProcessing: - return False, 0 + except StopProcessing as e: + return (e.args[0] if e.args else False), 0 except Handover: return await self.generate_chat_response(original_messages, user, room, allow_override=False, use_tools=False) diff --git a/src/gptbot/tools/newroom.py b/src/gptbot/tools/newroom.py index c874aea..6f37eba 100644 --- a/src/gptbot/tools/newroom.py +++ b/src/gptbot/tools/newroom.py @@ -1,4 +1,4 @@ -from .base import BaseTool +from .base import BaseTool, StopProcessing from nio import RoomCreateError, RoomInviteError @@ -54,4 +54,4 @@ class Newroom(BaseTool): await self.bot.matrix_client.room_put_state( new_room.room_id, "m.room.power_levels", {"users": {self.user: 100, self.bot.matrix_client.user_id: 100}}) - return "Created new Matrix room with ID " + new_room.room_id + " and invited user." \ No newline at end of file + raise StopProcessing("Created new Matrix room with ID " + new_room.room_id + " and invited user.") \ No newline at end of file