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

View file

@ -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 <ticket_id>` - Invite an operator to a ticket room.\n"
"4. `!supportbot close <ticket_id>` - Close a support ticket.\n"
"5. `!supportbot approve <user_id>` - Approve an application and invite to protected rooms.\n"
"6. `!supportbot reject <user_id>` - Reject an application.\n"
"7. `!supportbot list` - List open tickets.\n"
"8. `!supportbot monitor <room_id>` - Monitor a room for automatic ticket creation.\n"
"9. `!supportbot unmonitor <room_id>` - Stop monitoring a room.\n"
"10. `!supportbot monitored` - List monitored rooms.\n"
"11. `!supportbot protect <room_id>` - Protect a room.\n"
"12. `!supportbot unprotect <room_id>` - 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 <ticket_id>` - Invite an operator to a ticket room.\n"
"4. `!applicationbot close <ticket_id>` - Close a support ticket.\n"
"5. `!applicationbot approve <user_id>` - Approve an application and invite to protected rooms.\n"
"6. `!applicationbot reject <user_id>` - Reject an application.\n"
"7. `!applicationbot list` - List open tickets.\n"
"8. `!applicationbot monitor <room_id>` - Monitor a room for automatic ticket creation.\n"
"9. `!applicationbot unmonitor <room_id>` - Stop monitoring a room.\n"
"10. `!applicationbot monitored` - List monitored rooms.\n"
"11. `!applicationbot protect <room_id>` - Protect a room.\n"
"12. `!applicationbot unprotect <room_id>` - 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(