Exclude alias server name from !rooms over search: only match alias local part; v2.4.1

This commit is contained in:
Eddy de Vink 2026-09-06 15:08:07 +02:00
commit 2939951391
3 changed files with 10 additions and 3 deletions

View file

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

Binary file not shown.

View file

@ -545,16 +545,23 @@ class RoomsOverviewPlugin(Plugin):
async def _search_rooms(self, terms: str) -> List[Dict[str, Any]]:
"""Zoek rooms: alle termen moeten matchen (case-insensitive, substring)
in naam, alias of omschrijving."""
in naam, omschrijving of alias-lokaaldeel. De servernaam van een alias
(`#<lokaaldeel>:<server>`) telt NIET mee als zoektekst — anders geven
rooms op servers als `:linux020.net` false positives bij `over linux`."""
needles = [t for t in (part.lower() for part in terms.split()) if t]
if not needles:
return []
found = []
for r in await self._list_rooms():
alias = (r.get("canonical_alias") or "").strip()
alias_local = ""
if alias.startswith("#"):
alias_local = alias[1:].split(":", 1)[0]
hay = " ".join(
str(r.get(field) or "").lower()
for field in ("display_name", "canonical_alias", "topic")
for field in ("display_name", "topic")
)
hay += " " + alias_local.lower()
if all(n in hay for n in needles):
found.append(r)
return self._sort_rooms(found)