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:
2026-04-09 09:44:10 +02:00
committed by GitHub
parent e33e8f0e02
commit de559f9111
+10 -3
View File
@@ -1010,14 +1010,21 @@ class CommunityBot(Plugin):
await self.client.send_notice(evt.room_id, html=greeting) await self.client.send_notice(evt.room_id, html=greeting)
else: else:
pass pass
if self.config["notification_room"]: if self.config["notification_room"]:
roomnamestate = await self.client.get_state_event( 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[ notification_message = self.config[
"join_notification_message" "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( await self.client.send_notice(
self.config["notification_room"], html=notification_message self.config["notification_room"], html=notification_message
) )