diff --git a/plugin/adapter.py b/plugin/adapter.py index e99bace..2a32b72 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -676,14 +676,15 @@ class RocketChatAdapter(BasePlatformAdapter): logger.warning("[rocketchat] Operator-DM-Raum nicht gefunden, kann Onboarding nicht starten") 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.", - "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: - lines.append(f"{room['name']} = ") + clean_name = room['name'].lstrip("#") + lines.append(f"{clean_name} = ") 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) # Nachricht senden @@ -709,10 +710,11 @@ class RocketChatAdapter(BasePlatformAdapter): """ 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( r"(?:Raum:\s*)?" - r"(?P#[^\s=]+)\s*=\s*" + r"(?P#?[^\s=]+)\s*=\s*" r"(?P[^,]+?)" r"(?:,\s*(?:Keywords|Stichworte|Schlagworte):\s*(?P.*?))?$", re.IGNORECASE, @@ -725,39 +727,43 @@ class RocketChatAdapter(BasePlatformAdapter): for line in lines: line = line.strip() - # Skip empty lines and non-matching lines - if not line or not (line.startswith("#") or line.lower().startswith("raum:")): + # Skip empty lines and lines without obvious room assignment + if not line or "=" not in line: continue match = pattern.match(line) if not match: continue - room_name = match.group("name") + raw_name = match.group("name") theme = match.group("theme").strip() keywords_str = match.group("keywords") if keywords_str: keywords = [kw.strip() for kw in keywords_str.split(",") if kw.strip()] 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 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 break if room_id_to_add: self.archivar._room_map.add_or_update_room( room_id=room_id_to_add, - name=room_name, + name=raw_name, theme=theme, keywords=keywords ) 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: # RoomMap speichern und reloaden