feat(bot): enhance communication during user operations

Added messages to notify the operator room when user invitation or kick actions fail, improving operator awareness. Included notifications to both the monitored and operator rooms when a room starts being monitored, enhancing transparency. Updated ticket terminology to "application" to better reflect the context. Also, added notification to customers when a moderator wishes to join their room, improving user interaction. This enhances clarity and communication efficiency within the application bot's operations.
This commit is contained in:
Kumi 2024-11-08 09:08:21 +01:00
parent c5acd76c0a
commit 005a407d93
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -174,6 +174,15 @@ class ApplicationBot:
f"Failed to invite user {user_id} to protected room {protected_room}: {invite_response}" f"Failed to invite user {user_id} to protected room {protected_room}: {invite_response}"
) )
await self.client.room_send(
self.operator_room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": f"Failed to invite user {user_id} to protected room {protected_room}",
},
)
await self.client.room_send( await self.client.room_send(
room.room_id, room.room_id,
"m.room.message", "m.room.message",
@ -201,6 +210,15 @@ class ApplicationBot:
f"Failed to kick user {user_id} from monitored room {monitored_room}: {kick_response}" f"Failed to kick user {user_id} from monitored room {monitored_room}: {kick_response}"
) )
await self.client.room_send(
self.operator_room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": f"Failed to kick user {user_id} from monitored room {monitored_room}",
},
)
async def get_user_id_from_ticket_room(self, room_id): async def get_user_id_from_ticket_room(self, room_id):
# Find the user associated with the ticket id based on the room id # Find the user associated with the ticket id based on the room id
response = await self.client.room_get_state(self.operator_room_id) response = await self.client.room_get_state(self.operator_room_id)
@ -222,6 +240,24 @@ class ApplicationBot:
await self.set_monitored_rooms(monitored_rooms) await self.set_monitored_rooms(monitored_rooms)
logging.info(f"Added room {room_id} to monitored rooms") logging.info(f"Added room {room_id} to monitored rooms")
await self.client.room_send(
room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": "This room is now being monitored for applications.",
},
)
await self.client.room_send(
self.operator_room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": f"Room {room_id} is now being monitored for applications.",
},
)
async def remove_monitored_room(self, room_id): async def remove_monitored_room(self, room_id):
monitored_rooms = await self.get_monitored_rooms() monitored_rooms = await self.get_monitored_rooms()
if room_id in monitored_rooms: if room_id in monitored_rooms:
@ -364,7 +400,7 @@ class ApplicationBot:
"m.room.message", "m.room.message",
{ {
"msgtype": "m.text", "msgtype": "m.text",
"body": f"New ticket #{ticket_id} created by {sender}", "body": f"New application #{ticket_id} created by {sender}",
}, },
) )
@ -396,12 +432,23 @@ class ApplicationBot:
if isinstance(response, RoomGetStateEventResponse): if isinstance(response, RoomGetStateEventResponse):
operator_room_id = response.content["operator_room"] operator_room_id = response.content["operator_room"]
customer_room_id = response.content["customer_room"]
await self.client.room_send(
customer_room_id,
"m.room.message",
{
"msgtype": "m.text",
"body": "A moderator would like to join the room to discuss your application.",
},
)
await self.client.room_invite(operator_room_id, sender) await self.client.room_invite(operator_room_id, sender)
else: else:
await self.client.room_send( await self.client.room_send(
room.room_id, room.room_id,
"m.room.message", "m.room.message",
{"msgtype": "m.text", "body": f"Ticket #{ticket_id} does not exist."}, {"msgtype": "m.text", "body": f"Application #{ticket_id} does not exist."},
) )
async def close_ticket(self, room, sender, command): async def close_ticket(self, room, sender, command):