fix(bot): add sender info and error handling
Include the sender's name in bot notifications to enhance user communication. Introduce exception handling and logging when relaying messages to improve debugging and reliability.
This commit is contained in:
parent
0b32442011
commit
b33f905b3c
1 changed files with 8 additions and 4 deletions
|
@ -485,7 +485,7 @@ class ApplicationBot:
|
|||
"m.room.message",
|
||||
{
|
||||
"msgtype": "m.text",
|
||||
"body": f"Your application #{ticket_id} has been created. Please check your DMs.",
|
||||
"body": f"{sender} Your application #{ticket_id} has been created. Please check your DMs.",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -626,9 +626,13 @@ class ApplicationBot:
|
|||
)
|
||||
|
||||
# Relay the entire event content to the target room
|
||||
await self.client.room_send(
|
||||
target_room_id, "m.room.message", event.source["content"]
|
||||
)
|
||||
try:
|
||||
await self.client.room_send(
|
||||
target_room_id, "m.room.message", event.source["content"]
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to relay message: {e}")
|
||||
logging.debug(f"Event source: {event.source}")
|
||||
|
||||
async def help_command(self, room, sender):
|
||||
if await self.is_operator(sender):
|
||||
|
|
Loading…
Reference in a new issue