From c9a04619dea9723bcb684c27c69d38c20eae45f9 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 9 Nov 2024 20:42:02 +0100 Subject: [PATCH] refactor(bot): rename command prefix to `!applicationbot` Updated the command prefix from `!supportbot` to `!applicationbot` to ensure consistent naming across the application, thereby avoiding user confusion. This change applies to all related commands including help, open ticket, invite, close, approve, reject, list, monitor, unmonitor, and protected room actions. This refactor aims to improve clarity and maintain a coherent command structure for users interacting with the bot. --- src/matrix_applicationbot/classes/bot.py | 64 ++++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/matrix_applicationbot/classes/bot.py b/src/matrix_applicationbot/classes/bot.py index b3d4de6..af40fc2 100644 --- a/src/matrix_applicationbot/classes/bot.py +++ b/src/matrix_applicationbot/classes/bot.py @@ -62,7 +62,7 @@ class ApplicationBot: sender = event.sender body = event.body if hasattr(event, "body") else None - if body and body.startswith("!supportbot"): + if body and body.startswith("!applicationbot"): await self.handle_command(room, sender, body) elif body and body.startswith("!apply") and not sender == self.client.user_id: await self.process_application(room, sender, event) @@ -79,7 +79,7 @@ class ApplicationBot: "m.room.message", { "msgtype": "m.text", - "body": "Hello! To open a support ticket, please type `!supportbot openticket`.", + "body": "Hello! To open a support ticket, please type `!applicationbot openticket`.", }, ) @@ -125,7 +125,7 @@ class ApplicationBot: await self.approve_or_reject_application( room, sender, - command=f"!supportbot approve {user_id}", + command=f"!applicationbot approve {user_id}", approved=True, ) @@ -133,7 +133,7 @@ class ApplicationBot: await self.approve_or_reject_application( room, sender, - command=f"!supportbot reject {user_id}", + command=f"!applicationbot reject {user_id}", approved=False, ) @@ -178,39 +178,39 @@ class ApplicationBot: ) async def handle_command(self, room, sender, command): - if command == "!supportbot help": + if command == "!applicationbot help": return await self.help_command(room, sender) - elif command == "!supportbot openticket": + elif command == "!applicationbot openticket": return await self.open_ticket(room, sender) elif await self.is_operator(sender): - if command.startswith("!supportbot invite"): + if command.startswith("!applicationbot invite"): return await self.invite_operator(room, sender, command) - elif command.startswith("!supportbot close"): + elif command.startswith("!applicationbot close"): return await self.close_ticket(room, sender, command) - elif command.startswith("!supportbot approve"): + elif command.startswith("!applicationbot approve"): return await self.approve_or_reject_application( room, sender, command, approved=True ) - elif command.startswith("!supportbot reject"): + elif command.startswith("!applicationbot reject"): return await self.approve_or_reject_application( room, sender, command, approved=False ) - elif command == "!supportbot list": + elif command == "!applicationbot list": return await self.list_tickets(room) - elif command.startswith("!supportbot monitor"): + elif command.startswith("!applicationbot monitor"): return await self.add_monitored_room(command.split()[2]) - elif command.startswith("!supportbot unmonitor"): + elif command.startswith("!applicationbot unmonitor"): return await self.remove_monitored_room(command.split()[2]) - elif command.startswith("!supportbot monitored"): + elif command.startswith("!applicationbot monitored"): return await self.list_monitored_rooms(room) - elif command.startswith("!supportbot protect "): + elif command.startswith("!applicationbot 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"): + elif command.startswith("!applicationbot unprotect"): return await self.remove_protected_room(command.split()[2]) - elif command.startswith("!supportbot protected"): + elif command.startswith("!applicationbot protected"): return await self.list_protected_rooms(room) await self.client.room_send( @@ -715,25 +715,25 @@ class ApplicationBot: if await self.is_operator(sender): help_message = ( "Operator Commands:\n" - "1. `!supportbot help` - Show this help message.\n" - "2. `!supportbot openticket` - Open a support ticket.\n" - "3. `!supportbot invite ` - Invite an operator to a ticket room.\n" - "4. `!supportbot close ` - Close a support ticket.\n" - "5. `!supportbot approve ` - Approve an application and invite to protected rooms.\n" - "6. `!supportbot reject ` - Reject an application.\n" - "7. `!supportbot list` - List open tickets.\n" - "8. `!supportbot monitor ` - Monitor a room for automatic ticket creation.\n" - "9. `!supportbot unmonitor ` - Stop monitoring a room.\n" - "10. `!supportbot monitored` - List monitored rooms.\n" - "11. `!supportbot protect ` - Protect a room.\n" - "12. `!supportbot unprotect ` - Unprotect a room.\n" - "13. `!supportbot protected` - List protected rooms." + "1. `!applicationbot help` - Show this help message.\n" + "2. `!applicationbot openticket` - Open a support ticket.\n" + "3. `!applicationbot invite ` - Invite an operator to a ticket room.\n" + "4. `!applicationbot close ` - Close a support ticket.\n" + "5. `!applicationbot approve ` - Approve an application and invite to protected rooms.\n" + "6. `!applicationbot reject ` - Reject an application.\n" + "7. `!applicationbot list` - List open tickets.\n" + "8. `!applicationbot monitor ` - Monitor a room for automatic ticket creation.\n" + "9. `!applicationbot unmonitor ` - Stop monitoring a room.\n" + "10. `!applicationbot monitored` - List monitored rooms.\n" + "11. `!applicationbot protect ` - Protect a room.\n" + "12. `!applicationbot unprotect ` - Unprotect a room.\n" + "13. `!applicationbot protected` - List protected rooms." ) else: help_message = ( "User Commands:\n" - "1. `!supportbot help` - Show this help message.\n" - "2. `!supportbot openticket` - Open a support ticket." + "1. `!applicationbot help` - Show this help message.\n" + "2. `!applicationbot openticket` - Open a support ticket." ) await self.client.room_send(