fix: await resolve_room_id for async handling

Switch resolve_room_id to an async call in command handling to prevent blocking operations and enhance performance. This change ensures the bot can handle room ID resolutions non-blockingly, particularly during monitoring and protection operations. It improves the overall responsiveness and reliability of the bot when processing commands that require room ID resolution.
This commit is contained in:
Kumi 2024-11-12 21:46:31 +01:00
parent 91f16b3a99
commit 2e381a4c66
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -205,7 +205,7 @@ class ApplicationBot:
elif command == "list":
return await self.list_tickets(room)
elif command.startswith("monitor "):
room_id = self.resolve_room_id(command.split()[1])
room_id = await self.resolve_room_id(command.split()[1])
await self.add_monitored_room(room_id)
return await self.client.room_send(
room.room_id,
@ -216,7 +216,7 @@ class ApplicationBot:
},
)
elif command.startswith("unmonitor"):
room_id = self.resolve_room_id(command.split()[1])
room_id = await self.resolve_room_id(command.split()[1])
await self.remove_monitored_room(room_id)
return await self.client.room_send(
room.room_id,
@ -253,7 +253,7 @@ class ApplicationBot:
},
)
elif command.startswith("unprotect"):
room_id = self.resolve_room_id(command.split()[1])
room_id = await self.resolve_room_id(command.split()[1])
await self.remove_protected_room(room_id)
return await self.client.room_send(
room.room_id,