From fbce558a636efc78bf0cbc4b4009b58de15e46ec Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 9 Nov 2024 20:40:03 +0100 Subject: [PATCH] fix(bot): handle missing room ID in protect command Improved error handling for the protect command by logging an error message when a room ID is missing, preventing potential crashes from an IndexError. Also, updated ticket naming convention to use "Application" for better clarity. --- src/matrix_applicationbot/classes/bot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/matrix_applicationbot/classes/bot.py b/src/matrix_applicationbot/classes/bot.py index 4d45a3e..b3d4de6 100644 --- a/src/matrix_applicationbot/classes/bot.py +++ b/src/matrix_applicationbot/classes/bot.py @@ -203,8 +203,11 @@ class ApplicationBot: return await self.remove_monitored_room(command.split()[2]) elif command.startswith("!supportbot monitored"): return await self.list_monitored_rooms(room) - elif command.startswith("!supportbot protect"): - return await self.add_protected_room(command.split()[2]) + elif command.startswith("!supportbot protect "): + try: + return await self.add_protected_room(command.split()[2]) + except IndexError: + logging.error(f"No room ID specified for protect command: {command}") elif command.startswith("!supportbot unprotect"): return await self.remove_protected_room(command.split()[2]) elif command.startswith("!supportbot protected"): @@ -498,7 +501,7 @@ class ApplicationBot: async def open_ticket(self, room, sender): ticket_id = self.generate_ticket_id() - customer_room_alias = f"Ticket-{ticket_id}" + customer_room_alias = f"Application-{ticket_id}" operator_room_alias = f"Operator-Ticket-{ticket_id}" # Create customer-facing room