diff --git a/src/matrix_applicationbot/classes/bot.py b/src/matrix_applicationbot/classes/bot.py index 8b0ea90..9ba5f67 100644 --- a/src/matrix_applicationbot/classes/bot.py +++ b/src/matrix_applicationbot/classes/bot.py @@ -480,12 +480,23 @@ class ApplicationBot: return [] async def set_monitored_rooms(self, rooms): - await self.client.room_put_state( + response = await self.client.room_put_state( room_id=self.operator_room_id, event_type="m.room.monitored", content={"rooms": rooms}, ) + if not isinstance(response, RoomPutStateResponse): + logging.error(f"Failed to update monitored rooms: {response}") + await self.client.room_send( + self.operator_room_id, + "m.room.message", + { + "msgtype": "m.text", + "body": "Failed to update monitored rooms.", + }, + ) + async def list_monitored_rooms(self, room): monitored_rooms = await self.get_monitored_rooms() if monitored_rooms: @@ -531,12 +542,23 @@ class ApplicationBot: return [] async def set_protected_rooms(self, rooms): - await self.client.room_put_state( + response = await self.client.room_put_state( room_id=self.operator_room_id, event_type="m.room.protected", content={"rooms": rooms}, ) + if not isinstance(response, RoomPutStateResponse): + logging.error(f"Failed to update protected rooms: {response}") + await self.client.room_send( + self.operator_room_id, + "m.room.message", + { + "msgtype": "m.text", + "body": "Failed to update protected rooms.", + }, + ) + async def list_protected_rooms(self, room): protected_rooms = await self.get_protected_rooms() if protected_rooms: