fix(bot): ensure command handling returns awaitables
Refactored command handling methods to return awaitables directly rather than awaiting them in place. This approach facilitates easier testing and future integration with event loop management strategies. Improves asynchronous function chaining and consistent handling of command execution results.
This commit is contained in:
parent
ac18806308
commit
c5acd76c0a
1 changed files with 13 additions and 14 deletions
|
@ -88,37 +88,36 @@ class ApplicationBot:
|
||||||
|
|
||||||
async def handle_command(self, room, sender, command):
|
async def handle_command(self, room, sender, command):
|
||||||
if command == "!supportbot help":
|
if command == "!supportbot help":
|
||||||
await self.help_command(room, sender)
|
return await self.help_command(room, sender)
|
||||||
elif command == "!supportbot openticket":
|
elif command == "!supportbot openticket":
|
||||||
await self.open_ticket(room, sender)
|
return await self.open_ticket(room, sender)
|
||||||
elif await self.is_operator(sender):
|
elif await self.is_operator(sender):
|
||||||
if command.startswith("!supportbot invite"):
|
if command.startswith("!supportbot invite"):
|
||||||
await self.invite_operator(room, sender, command)
|
return await self.invite_operator(room, sender, command)
|
||||||
elif command.startswith("!supportbot close"):
|
elif command.startswith("!supportbot close"):
|
||||||
await self.close_ticket(room, sender, command)
|
return await self.close_ticket(room, sender, command)
|
||||||
elif command.startswith("!supportbot approve"):
|
elif command.startswith("!supportbot approve"):
|
||||||
await self.approve_or_reject_application(
|
return await self.approve_or_reject_application(
|
||||||
room, sender, command, approved=True
|
room, sender, command, approved=True
|
||||||
)
|
)
|
||||||
elif command.startswith("!supportbot reject"):
|
elif command.startswith("!supportbot reject"):
|
||||||
await self.approve_or_reject_application(
|
return await self.approve_or_reject_application(
|
||||||
room, sender, command, approved=False
|
room, sender, command, approved=False
|
||||||
)
|
)
|
||||||
elif command == "!supportbot list":
|
elif command == "!supportbot list":
|
||||||
await self.list_tickets(room)
|
return await self.list_tickets(room)
|
||||||
elif command.startswith("!supportbot monitor"):
|
elif command.startswith("!supportbot monitor"):
|
||||||
await self.add_monitored_room(command.split()[2])
|
return await self.add_monitored_room(command.split()[2])
|
||||||
elif command.startswith("!supportbot unmonitor"):
|
elif command.startswith("!supportbot unmonitor"):
|
||||||
await self.remove_monitored_room(command.split()[2])
|
return await self.remove_monitored_room(command.split()[2])
|
||||||
elif command.startswith("!supportbot monitored"):
|
elif command.startswith("!supportbot monitored"):
|
||||||
await self.list_monitored_rooms(room)
|
return await self.list_monitored_rooms(room)
|
||||||
elif command.startswith("!supportbot protect"):
|
elif command.startswith("!supportbot protect"):
|
||||||
await self.add_protected_room(command.split()[2])
|
return await self.add_protected_room(command.split()[2])
|
||||||
elif command.startswith("!supportbot unprotect"):
|
elif command.startswith("!supportbot unprotect"):
|
||||||
await self.remove_protected_room(command.split()[2])
|
return await self.remove_protected_room(command.split()[2])
|
||||||
elif command.startswith("!supportbot protected"):
|
elif command.startswith("!supportbot protected"):
|
||||||
await self.list_protected_rooms(room)
|
return await self.list_protected_rooms(room)
|
||||||
return
|
|
||||||
|
|
||||||
await self.client.room_send(
|
await self.client.room_send(
|
||||||
room.room_id,
|
room.room_id,
|
||||||
|
|
Loading…
Reference in a new issue