Update bot.py

This commit is contained in:
2026-04-09 23:08:19 +02:00
committed by GitHub
parent a030288e2d
commit d6ab470ed0
+10 -6
View File
@@ -1020,17 +1020,19 @@ class CommunityBot(Plugin):
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"
) )
room_name_text = getattr(roomnamestate, "name", str(evt.room_id))
room_text = getattr(roomnamestate, "name", str(evt.room_id))
except Exception: except Exception:
room_name_text = str(evt.room_id) room_text = str(evt.room_id)
room_link = f"<a href='https://look.ztfr.eu/#/{evt.room_id}'>{room_name_text}</a>" room_link = f"<a href='https://matrix.to/#/{evt.room_id}'>{room_text}</a>"
notification_message = self.config[ notification_message = self.config[
"join_notification_message" "join_notification_message"
].format( ].format(
user=evt.sender, user=evt.sender,
room=room_link, room=room_text,
room_link=room_link,
room_id=evt.room_id room_id=evt.room_id
) )
await self.client.send_notice( await self.client.send_notice(
@@ -1341,13 +1343,15 @@ class CommunityBot(Plugin):
try: try:
roomnamestate = await self.client.get_state_event(evt.room_id, "m.room.name") roomnamestate = await self.client.get_state_event(evt.room_id, "m.room.name")
# Wir nennen es intern erst einmal room_text
room_text = roomnamestate.get("name") if roomnamestate else str(evt.room_id) room_text = roomnamestate.get("name") if roomnamestate else str(evt.room_id)
except: except:
room_text = str(evt.room_id) room_text = str(evt.room_id)
# Klickable Links # Klickable Links
room_link = f"<a href='https://look.ztfr.eu/#/{evt.room_id}'>{room_text}</a>" room = room_text
message_link = f"https://look.ztfr.eu/#/{evt.room_id}/{target_event_id}" room_link = f"<a href='https://matrix.to/#/{evt.room_id}'>{room_text}</a>"
message_link = f"https://matrix.to/#/{evt.room_id}/{target_event_id}"
# --- AUTO-REDACT LOGIC --- # --- AUTO-REDACT LOGIC ---
if self.config.get("auto_redact_majority", False): if self.config.get("auto_redact_majority", False):