Render !rooms as preview blocks (name/topic/address) instead of list lines; v2.1.0

This commit is contained in:
Eddy de Vink 2026-09-02 08:19:22 +02:00
commit 21eff14d8d
3 changed files with 6 additions and 4 deletions

View file

@ -1,6 +1,6 @@
maubot: 0.1.0
id: nl.roomsoverview
version: 2.0.5
version: 2.1.0
license: MIT
modules:
- roomsoverview

Binary file not shown.

View file

@ -312,10 +312,12 @@ class RoomsOverviewPlugin(Plugin):
member_count = r.get("member_count")
topic = _escape_md((r.get("topic") or "").strip().replace("\n", " "))
suffix = f" ({member_count} leden)" if member_count is not None else ""
line = f"* [{name}](https://matrix.to/#/{link_target}){suffix}"
addr = f"[{alias if alias else room_id}](https://matrix.to/#/{link_target})"
if topic:
line += f" — {topic}"
lines.append(line)
block = f"**{name}**{suffix}\n{topic}\n{addr}"
else:
block = f"**{name}**{suffix}\n{addr}"
lines.append(block)
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)]