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.
This commit is contained in:
Kumi 2024-11-09 20:40:03 +01:00
parent 51a56c0949
commit fbce558a63
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -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