feat: add room_id placeholder to join notifications
- Enhanced the join notification logic to support the {room_id} placeholder.
- This allows administrators to include direct matrix.to deep links in notification messages.
- Added a safety fallback that uses the room ID as the name if the room has no display name set.
This commit is contained in:
+10
-3
@@ -1010,14 +1010,21 @@ class CommunityBot(Plugin):
|
||||
await self.client.send_notice(evt.room_id, html=greeting)
|
||||
else:
|
||||
pass
|
||||
|
||||
if self.config["notification_room"]:
|
||||
roomnamestate = await self.client.get_state_event(
|
||||
evt.room_id, "m.room.name"
|
||||
evt.room_id, "m.room.name"
|
||||
)
|
||||
roomname = roomnamestate["name"]
|
||||
|
||||
roomname = roomnamestate.get("name") if roomnamestate else str(evt.room_id)
|
||||
|
||||
notification_message = self.config[
|
||||
"join_notification_message"
|
||||
].format(user=evt.sender, room=roomname)
|
||||
].format(
|
||||
user=evt.sender,
|
||||
room=roomname,
|
||||
room_id=evt.room_id # <--- Das ist neu!
|
||||
)
|
||||
await self.client.send_notice(
|
||||
self.config["notification_room"], html=notification_message
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user