feat(bot): add help command for user and operator roles

Introduced a `help_command` method to provide users and operators with a list of available commands specific to their roles. This enhancement improves user experience by offering quick access to critical command information directly within the chat environment.
This commit is contained in:
Kumi 2024-11-08 08:25:48 +01:00
parent 45e0f82285
commit ddc9b05fed
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -496,3 +496,37 @@ class ApplicationBot:
await self.client.room_send( await self.client.room_send(
target_room_id, "m.room.message", event.source["content"] target_room_id, "m.room.message", event.source["content"]
) )
async def help_command(self, room, sender):
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."
)
else:
help_message = (
"User Commands:\n"
"1. `!supportbot help` - Show this help message.\n"
"2. `!supportbot openticket` - Open a support ticket."
)
await self.client.room_send(
room.room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": help_message,
},
)