One-line preview rendering: bold name + link + topic, nameless rooms single link; v2.1.2
This commit is contained in:
parent
21eff14d8d
commit
89100b83aa
3 changed files with 15 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
maubot: 0.1.0
|
||||
id: nl.roomsoverview
|
||||
version: 2.1.0
|
||||
version: 2.1.2
|
||||
license: MIT
|
||||
modules:
|
||||
- roomsoverview
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -303,21 +303,25 @@ class RoomsOverviewPlugin(Plugin):
|
|||
|
||||
lines = []
|
||||
for r in rooms:
|
||||
name = _escape_md(
|
||||
r.get("display_name") or r.get("canonical_alias") or r["room_id"]
|
||||
)
|
||||
alias = r.get("canonical_alias")
|
||||
display = r.get("display_name") or ""
|
||||
alias = r.get("canonical_alias") or ""
|
||||
room_id = r["room_id"]
|
||||
link_target = quote(alias if alias else room_id, safe="!")
|
||||
member_count = r.get("member_count")
|
||||
topic = _escape_md((r.get("topic") or "").strip().replace("\n", " "))
|
||||
topic = (r.get("topic") or "").strip().replace("\n", " ")
|
||||
suffix = f" ({member_count} leden)" if member_count is not None else ""
|
||||
addr = f"[{alias if alias else room_id}](https://matrix.to/#/{link_target})"
|
||||
if topic:
|
||||
block = f"**{name}**{suffix}\n{topic}\n{addr}"
|
||||
if display:
|
||||
label = _escape_md(display)
|
||||
else:
|
||||
block = f"**{name}**{suffix}\n{addr}"
|
||||
lines.append(block)
|
||||
label = room_id
|
||||
link = f"[{_escape_md(alias) if alias else room_id}](https://matrix.to/#/{link_target})"
|
||||
if display:
|
||||
line = f"* **{label}**{suffix} — {link}"
|
||||
else:
|
||||
line = f"* {link}{suffix}"
|
||||
if topic:
|
||||
line += f" — {_escape_md(topic)}"
|
||||
lines.append(line)
|
||||
|
||||
chunk_size = max(1, int(self.config.get("rooms_per_message", 50) or 50))
|
||||
chunks = [lines[i : i + chunk_size] for i in range(0, len(lines), chunk_size)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue