fix(onboarding): remove # from display to prevent RC link rendering
- Onboarding message shows room names WITHOUT # (RC auto-links them) - Parser accepts both 'Name' and '#Name' (case-insensitive match) - Pattern: #? makes hash optional, matching against lstrip(#)
This commit is contained in:
+20
-14
@@ -676,14 +676,15 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
logger.warning("[rocketchat] Operator-DM-Raum nicht gefunden, kann Onboarding nicht starten")
|
logger.warning("[rocketchat] Operator-DM-Raum nicht gefunden, kann Onboarding nicht starten")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Text erstellen — echte Zeilenumbrüche via Liste + join
|
# Text erstellen — OHNE # (Rocket.Chat macht Links daraus, blockiert Editieren)
|
||||||
lines = ["Folgende Räume fehlen in der Raum-Map.",
|
lines = ["Folgende Räume fehlen in der Raum-Map.",
|
||||||
"Wofür ist jeder Raum da? Antworte pro Raum mit: `#Name = Thema`",
|
"Wofür ist jeder Raum da? Antworte pro Raum mit: `Name = Thema`",
|
||||||
""]
|
""]
|
||||||
for room in missing_rooms:
|
for room in missing_rooms:
|
||||||
lines.append(f"{room['name']} = ")
|
clean_name = room['name'].lstrip("#")
|
||||||
|
lines.append(f"{clean_name} = ")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append("Beispiel: `#BAT-Team = Trading, Bot Agent Team, Austausch und Status zum Projekt BAT`")
|
lines.append("Beispiel: `BAT-Team = Trading, Bot Agent Team, Projekt BAT, Austausch und Status`")
|
||||||
text = "\n".join(lines)
|
text = "\n".join(lines)
|
||||||
|
|
||||||
# Nachricht senden
|
# Nachricht senden
|
||||||
@@ -709,10 +710,11 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Pattern für beide Varianten — „Raum:"-Präfix ist optional
|
# Pattern: # ist optional (Rocket.Chat macht sonst Links daraus)
|
||||||
|
# Akzeptiert: "Name = Thema", "#Name = Thema", "Raum: Name = Thema"
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
r"(?:Raum:\s*)?"
|
r"(?:Raum:\s*)?"
|
||||||
r"(?P<name>#[^\s=]+)\s*=\s*"
|
r"(?P<name>#?[^\s=]+)\s*=\s*"
|
||||||
r"(?P<theme>[^,]+?)"
|
r"(?P<theme>[^,]+?)"
|
||||||
r"(?:,\s*(?:Keywords|Stichworte|Schlagworte):\s*(?P<keywords>.*?))?$",
|
r"(?:,\s*(?:Keywords|Stichworte|Schlagworte):\s*(?P<keywords>.*?))?$",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
@@ -725,39 +727,43 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
# Skip empty lines and non-matching lines
|
# Skip empty lines and lines without obvious room assignment
|
||||||
if not line or not (line.startswith("#") or line.lower().startswith("raum:")):
|
if not line or "=" not in line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = pattern.match(line)
|
match = pattern.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
room_name = match.group("name")
|
raw_name = match.group("name")
|
||||||
theme = match.group("theme").strip()
|
theme = match.group("theme").strip()
|
||||||
keywords_str = match.group("keywords")
|
keywords_str = match.group("keywords")
|
||||||
|
|
||||||
if keywords_str:
|
if keywords_str:
|
||||||
keywords = [kw.strip() for kw in keywords_str.split(",") if kw.strip()]
|
keywords = [kw.strip() for kw in keywords_str.split(",") if kw.strip()]
|
||||||
else:
|
else:
|
||||||
keywords = self._derive_keywords(room_name, theme)
|
keywords = self._derive_keywords(raw_name, theme)
|
||||||
|
|
||||||
# Finde den Raum in den subscribed rooms
|
# Finde den Raum — probiere sowohl mit als auch ohne #
|
||||||
room_id_to_add = None
|
room_id_to_add = None
|
||||||
for rid, info in self._room_info.items():
|
for rid, info in self._room_info.items():
|
||||||
if info.get("name") == room_name and info.get("type") in ("c", "p"):
|
if info.get("type") not in ("c", "p"):
|
||||||
|
continue
|
||||||
|
rc_name = info.get("name", "")
|
||||||
|
# Match: "BAT-Team" == "#BAT-Team", "#BAT-Team" == "BAT-Team"
|
||||||
|
if raw_name == rc_name or raw_name.lstrip("#") == rc_name.lstrip("#"):
|
||||||
room_id_to_add = rid
|
room_id_to_add = rid
|
||||||
break
|
break
|
||||||
|
|
||||||
if room_id_to_add:
|
if room_id_to_add:
|
||||||
self.archivar._room_map.add_or_update_room(
|
self.archivar._room_map.add_or_update_room(
|
||||||
room_id=room_id_to_add,
|
room_id=room_id_to_add,
|
||||||
name=room_name,
|
name=raw_name,
|
||||||
theme=theme,
|
theme=theme,
|
||||||
keywords=keywords
|
keywords=keywords
|
||||||
)
|
)
|
||||||
processed_count += 1
|
processed_count += 1
|
||||||
logger.info("[rocketchat] Raum hinzugefügt: %s = %s (keywords: %s)", room_name, theme, keywords)
|
logger.info("[rocketchat] Raum hinzugefügt: %s = %s (keywords: %s)", raw_name, theme, keywords)
|
||||||
|
|
||||||
if processed_count > 0:
|
if processed_count > 0:
|
||||||
# RoomMap speichern und reloaden
|
# RoomMap speichern und reloaden
|
||||||
|
|||||||
Reference in New Issue
Block a user