Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f585f9a0e7 | |||
| 1a4dab401d | |||
| 39a33ebc3c | |||
| f94d73585c | |||
| 49e9b3ec1f | |||
| eece2f9950 |
+115
-15
@@ -1033,6 +1033,9 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
# The router's _check_never_route_topic handles per-topic blocking now.
|
# The router's _check_never_route_topic handles per-topic blocking now.
|
||||||
# Clarify state: maps clarify_id → session_key for gateway resolution
|
# Clarify state: maps clarify_id → session_key for gateway resolution
|
||||||
self._clarify_state: Dict[str, str] = {}
|
self._clarify_state: Dict[str, str] = {}
|
||||||
|
# FIX 2 (P0): ISSUE 3 — Pending Clarify Dispatch Slot
|
||||||
|
# {room_id: {text, username, msg_id, msg_obj, is_button_response}}
|
||||||
|
self._pending_clarify_dispatch: Dict[str, dict] = {}
|
||||||
# Auto-Onboarding v2: structured interview state
|
# Auto-Onboarding v2: structured interview state
|
||||||
self._onboarding_state: Dict[str, Any] = {}
|
self._onboarding_state: Dict[str, Any] = {}
|
||||||
# FIX E: Raum-Map Summary für System-Prompt-Injection via chat_topic.
|
# FIX E: Raum-Map Summary für System-Prompt-Injection via chat_topic.
|
||||||
@@ -2196,6 +2199,30 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.warning("[rocketchat] Unknown ARCHIVAR_CLARIFY choice: %s", choice)
|
logger.warning("[rocketchat] Unknown ARCHIVAR_CLARIFY choice: %s", choice)
|
||||||
|
# ── FIX 2 (P0): ISSUE 3 — Pending Dispatch nach Klärung ──
|
||||||
|
# Nach der Klärung (Strategie/anderer_grund) den
|
||||||
|
# ursprünglichen Auftrag an den Agenten dispatchen.
|
||||||
|
pending = self._pending_clarify_dispatch.pop(room_id, None)
|
||||||
|
if pending:
|
||||||
|
_CURRENT_ORIGIN_ROOM.set(room_id)
|
||||||
|
_THEMATIC_TARGET_ROOM.set("")
|
||||||
|
routing_counter.increment('archivar_clarify_dispatched')
|
||||||
|
logger.info(
|
||||||
|
"[rocketchat] FIX 2: Clarify dispatch — "
|
||||||
|
"room=%s, text=%s",
|
||||||
|
room_id[:8], pending["text"][:80],
|
||||||
|
)
|
||||||
|
await self._dispatch_agent(
|
||||||
|
text=pending["text"],
|
||||||
|
room_id=room_id,
|
||||||
|
room_name=room_name,
|
||||||
|
room_type=room_type,
|
||||||
|
username=pending["username"],
|
||||||
|
msg_id=pending["msg_id"],
|
||||||
|
msg_obj=pending["msg_obj"],
|
||||||
|
is_button_response=pending.get("is_button_response", False),
|
||||||
|
category="",
|
||||||
|
)
|
||||||
return # Nachricht verarbeitet — keine weitere Verarbeitung
|
return # Nachricht verarbeitet — keine weitere Verarbeitung
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug("[rocketchat] Error processing ARCHIVAR_CLARIFY response: %s", e)
|
logger.debug("[rocketchat] Error processing ARCHIVAR_CLARIFY response: %s", e)
|
||||||
@@ -2313,12 +2340,36 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"timestamp": time.time(),
|
"timestamp": time.time(),
|
||||||
"origin_message_id": move_req.get("message_id", ""),
|
"origin_message_id": move_req.get("message_id", ""),
|
||||||
"target_message_id": "",
|
"target_message_id": "",
|
||||||
|
"source": "confirm", # FIX 4: confirm_move vs auto-route
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
"[rocketchat] V8.3-5: Topic-Scoped Sticky gesetzt — "
|
"[rocketchat] V8.3-5: Topic-Scoped Sticky gesetzt — "
|
||||||
"room=%s → target=%s, topic='%s' (30 Min, confirm_move)",
|
"room=%s → target=%s, topic='%s' (30 Min, confirm_move)",
|
||||||
room_id[:8], move_req.get("target_name", "?")[:20], move_sticky_topic,
|
room_id[:8], move_req.get("target_name", "?")[:20], move_sticky_topic,
|
||||||
)
|
)
|
||||||
|
# ── FIX 1 (P0): ISSUE 4 — Nachricht in Zielraum kopieren ──
|
||||||
|
# V8.1 hatte den Copy-Schritt fälschlich entfernt.
|
||||||
|
# DM-Aufträge werden NIE geroutet (DM-Guard).
|
||||||
|
if room_type != "d":
|
||||||
|
try:
|
||||||
|
prefix = f"*(Auftrag von @{username}, hierher kopiert)*\n"
|
||||||
|
target_copy_id = await self._post_message_with_retry(
|
||||||
|
move_req["target_room"],
|
||||||
|
prefix + move_req["text"],
|
||||||
|
)
|
||||||
|
if target_copy_id:
|
||||||
|
self._recent_auto_routes[room_id]["target_message_id"] = target_copy_id
|
||||||
|
routing_counter.increment('confirm_move_copied')
|
||||||
|
logger.info(
|
||||||
|
"[rocketchat] FIX 1: confirm_move copy → %s, "
|
||||||
|
"target_msg_id=%s",
|
||||||
|
move_req.get("target_name", "?")[:20],
|
||||||
|
target_copy_id or "N/A",
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
"[rocketchat] FIX 1: confirm_move copy failed — %s", e
|
||||||
|
)
|
||||||
elif choice in ("2", "2️⃣", "generell", "generell hier bleiben", "stay_here"):
|
elif choice in ("2", "2️⃣", "generell", "generell hier bleiben", "stay_here"):
|
||||||
# 2️⃣ Generell hier bleiben → Antwort im Ursprungsraum + Sticky-Eintrag
|
# 2️⃣ Generell hier bleiben → Antwort im Ursprungsraum + Sticky-Eintrag
|
||||||
# P0-B: Thematischer Sticky (v7) — Thema aus Match-Ergebnis extrahieren
|
# P0-B: Thematischer Sticky (v7) — Thema aus Match-Ergebnis extrahieren
|
||||||
@@ -2341,7 +2392,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("[rocketchat] Failed to persist sticky decision: %s", e)
|
logger.warning("[rocketchat] Failed to persist sticky decision: %s", e)
|
||||||
await self._post_message_with_retry(room_id, "🔒 Verstanden — dieser Raum wird nicht mehr automatisch geroutet. (Gilt dauerhaft)")
|
await self._post_message_with_retry(room_id, "🔒 Verstanden — dieses Thema bleibt jetzt hier im Raum. (Themenbezogen, verfällt nach 24h oder Themenwechsel)")
|
||||||
feedback_type = "never"
|
feedback_type = "never"
|
||||||
else:
|
else:
|
||||||
# 3️⃣ Nur diesmal → Antwort im Ursprungsraum (nur diesmal, kein Sticky)
|
# 3️⃣ Nur diesmal → Antwort im Ursprungsraum (nur diesmal, kein Sticky)
|
||||||
@@ -2370,6 +2421,19 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"[rocketchat] V8.2.1 A2: Nachklärung gesendet — "
|
"[rocketchat] V8.2.1 A2: Nachklärung gesendet — "
|
||||||
"Strategie-Buttons in room %s", room_id[:8],
|
"Strategie-Buttons in room %s", room_id[:8],
|
||||||
)
|
)
|
||||||
|
# FIX 2 (P0): ISSUE 3 — Persistenter Pending-Dispatch-Slot
|
||||||
|
# Speichere move_req-Daten für ARCHIVAR_CLARIFY-Handler.
|
||||||
|
self._pending_clarify_dispatch[room_id] = {
|
||||||
|
"text": move_req.get("text", ""),
|
||||||
|
"username": username,
|
||||||
|
"msg_id": msg_id,
|
||||||
|
"msg_obj": msg_obj,
|
||||||
|
"is_button_response": is_button_response,
|
||||||
|
}
|
||||||
|
logger.info(
|
||||||
|
"[rocketchat] FIX 2: Pending clarify dispatch saved — "
|
||||||
|
"room=%s", room_id[:8],
|
||||||
|
)
|
||||||
# Stay-Counter: Wenn der User 3× in 10 Min "Hier bleiben" klickt,
|
# Stay-Counter: Wenn der User 3× in 10 Min "Hier bleiben" klickt,
|
||||||
# wird der Raum automatisch auf "never_route" gesetzt.
|
# wird der Raum automatisch auf "never_route" gesetzt.
|
||||||
# P1-3: stay_tracker ist jetzt persistent in ArchivarState
|
# P1-3: stay_tracker ist jetzt persistent in ArchivarState
|
||||||
@@ -2384,7 +2448,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
self.archivar._state.set_never_route(room_id, topic)
|
self.archivar._state.set_never_route(room_id, topic)
|
||||||
# V7-2: _sticky_rooms entfernt — thematisches never_route reicht
|
# V7-2: _sticky_rooms entfernt — thematisches never_route reicht
|
||||||
logger.info("[rocketchat] Auto-promoted to never_route after %d stays in room %s, topic '%s'", count, room_id[:8], topic)
|
logger.info("[rocketchat] Auto-promoted to never_route after %d stays in room %s, topic '%s'", count, room_id[:8], topic)
|
||||||
await self._post_message_with_retry(room_id, "🔒 Ich habe gemerkt, dass du hier bleiben möchtest — dieser Raum wird ab jetzt nicht mehr automatisch geroutet.")
|
await self._post_message_with_retry(room_id, "🔒 Gut erkannt — dieses Thema bleibt ab jetzt hier. (Verfällt nach 24h oder Themenwechsel)")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("[rocketchat] Failed to auto-promote sticky: %s", e)
|
logger.warning("[rocketchat] Failed to auto-promote sticky: %s", e)
|
||||||
|
|
||||||
@@ -2445,11 +2509,13 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
|
|
||||||
# ── V8.3-3: Widerspruchs-Routine (RÜCKHOLEN) ──────────────────────
|
# ── V8.3-3: Widerspruchs-Routine (RÜCKHOLEN) ──────────────────────
|
||||||
# Prüft ob der User widerspricht ('Halt, das gehört hier her')
|
# Prüft ob der User widerspricht ('Halt, das gehört hier her')
|
||||||
# innerhalb 10 Min nach einer Auto-Route.
|
# innerhalb 10 Min nach einer Auto-Route, 30 Min nach confirm_move.
|
||||||
# V8.3.1 F2: Wortgrenzen-Match + Satzkontext-Whitelist.
|
# V8.3.1 F2: Wortgrenzen-Match + Satzkontext-Whitelist.
|
||||||
|
# FIX 4: Erweiterte Keywords + confirm_move-Support.
|
||||||
_WIDERSPRUCH_KEYWORDS = [
|
_WIDERSPRUCH_KEYWORDS = [
|
||||||
'halt', 'bleib hier', 'gehört hier her',
|
'halt', 'bleib hier', 'gehört hier her',
|
||||||
'nein', 'stop', 'falscher raum', 'zurück', 'roll back', 'rollback',
|
'nein', 'stop', 'falscher raum', 'zurück', 'roll back', 'rollback',
|
||||||
|
'passt hier nicht', 'gehört nicht hier', 'falsch', 'doch nicht',
|
||||||
]
|
]
|
||||||
text_lower = text.lower()
|
text_lower = text.lower()
|
||||||
|
|
||||||
@@ -2481,16 +2547,37 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
_widerspruch_matches_sentence_context(kw, text_lower)
|
_widerspruch_matches_sentence_context(kw, text_lower)
|
||||||
for kw in _WIDERSPRUCH_KEYWORDS
|
for kw in _WIDERSPRUCH_KEYWORDS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ── FIX 4: Erweiterte Widerspruchs-Erkennung ──────────────────
|
||||||
|
# Auto-Route: room_id == origin_room (direkter Lookup)
|
||||||
|
# confirm_move: room_id == target_room (inverser Lookup)
|
||||||
|
route_info = None
|
||||||
|
route_source = None
|
||||||
if is_widerspruch and room_id in self._recent_auto_routes:
|
if is_widerspruch and room_id in self._recent_auto_routes:
|
||||||
route_info = self._recent_auto_routes[room_id]
|
route_info = self._recent_auto_routes[room_id]
|
||||||
|
route_source = route_info.get("source", "auto")
|
||||||
|
elif is_widerspruch:
|
||||||
|
# Inverser Lookup: Suche nach confirm_move-Route,
|
||||||
|
# deren target_room == room_id (Rainer Architektur-Detail)
|
||||||
|
for origin_rid, entry in list(self._recent_auto_routes.items()):
|
||||||
|
if entry.get("target_room") == room_id and entry.get("source") == "confirm":
|
||||||
|
route_info = entry
|
||||||
|
route_source = "confirm"
|
||||||
|
# room_id ist der Zielraum, origin_room ist der Ursprungsraum
|
||||||
|
break
|
||||||
|
|
||||||
|
if is_widerspruch and route_info is not None:
|
||||||
elapsed = time.time() - route_info["timestamp"]
|
elapsed = time.time() - route_info["timestamp"]
|
||||||
if elapsed <= 600: # 10 Min Zeitfenster
|
# Auto-Route: 10 Min, confirm_move: 30 Min
|
||||||
|
max_window = 1800 if route_source == "confirm" else 600
|
||||||
|
if elapsed <= max_window:
|
||||||
logger.info(
|
logger.info(
|
||||||
"[rocketchat] V8.3-3: Widerspruch erkannt in room %s — "
|
"[rocketchat] V8.3-3: Widerspruch erkannt in room %s — "
|
||||||
"%.0fs nach Auto-Route, hole Thema zurück",
|
"%.0fs nach %s-Route, hole Thema zurück",
|
||||||
room_id[:8], elapsed,
|
room_id[:8], elapsed, route_source,
|
||||||
)
|
)
|
||||||
target_room_id = route_info["target_room"]
|
target_room_id = route_info["target_room"]
|
||||||
|
origin_room_id = route_info["origin_room"]
|
||||||
# a. Thema aus Zielraum entfernen (delete/edit)
|
# a. Thema aus Zielraum entfernen (delete/edit)
|
||||||
target_msg_id = route_info.get("target_message_id", "")
|
target_msg_id = route_info.get("target_message_id", "")
|
||||||
if target_msg_id:
|
if target_msg_id:
|
||||||
@@ -2499,34 +2586,45 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
target_room_id, target_msg_id, "_(Zurückgezogen)_"
|
target_room_id, target_msg_id, "_(Zurückgezogen)_"
|
||||||
)
|
)
|
||||||
# b. Thema im Ursprungsraum wieder aufnehmen
|
# b. Thema im Ursprungsraum wieder aufnehmen
|
||||||
|
if route_source == "confirm":
|
||||||
|
# FIX 4: Bei confirm_move — Rückhol-Text mit Original
|
||||||
|
origin_name = self._room_info.get(origin_room_id, {}).get("name", "Ursprungsraum")
|
||||||
|
target_name = self._room_info.get(target_room_id, {}).get("name", "Zielraum")
|
||||||
|
rueckhol_text = (
|
||||||
|
f"↩️ Zurückgeholt aus #{target_name.lstrip('#')}\n"
|
||||||
|
f"{display_text}"
|
||||||
|
)
|
||||||
|
await self._post_message_with_retry(origin_room_id, rueckhol_text)
|
||||||
|
routing_counter.increment('widerspruch_confirm_move_route')
|
||||||
|
else:
|
||||||
await self._post_message_with_retry(
|
await self._post_message_with_retry(
|
||||||
room_id,
|
room_id,
|
||||||
"👍 Verstanden — das Thema gehört hier her. Ich bleibe hier."
|
"👍 Verstanden — das Thema gehört hier her. Ich bleibe hier."
|
||||||
)
|
)
|
||||||
# c. _CURRENT_ORIGIN_ROOM zurück auf Ursprungsraum
|
# c. _CURRENT_ORIGIN_ROOM zurück auf Ursprungsraum
|
||||||
_CURRENT_ORIGIN_ROOM.set(room_id)
|
_CURRENT_ORIGIN_ROOM.set(origin_room_id)
|
||||||
_THEMATIC_TARGET_ROOM.set("")
|
_THEMATIC_TARGET_ROOM.set("")
|
||||||
# d. Sticky löschen
|
# d. Sticky löschen
|
||||||
self._session_room_preferences.pop(room_id, None)
|
self._session_room_preferences.pop(origin_room_id, None)
|
||||||
# e. Ring: move_gc(target → origin) — Rückholung
|
# e. Ring: move_gc(target → origin) — Rückholung
|
||||||
if _MULTIROOM() and self._multiroom_context is not None:
|
if _MULTIROOM() and self._multiroom_context is not None:
|
||||||
route_topic = route_info.get("topic", "")
|
route_topic = route_info.get("topic", "")
|
||||||
if route_topic:
|
if route_topic:
|
||||||
await self._multiroom_context.move_gc(
|
await self._multiroom_context.move_gc(
|
||||||
origin_room_id=target_room_id,
|
origin_room_id=target_room_id,
|
||||||
target_room_id=room_id,
|
target_room_id=origin_room_id,
|
||||||
topic=route_topic,
|
topic=route_topic,
|
||||||
room_name=self._room_info.get(room_id, {}).get("name", ""),
|
room_name=self._room_info.get(origin_room_id, {}).get("name", ""),
|
||||||
)
|
)
|
||||||
# f. KEIN Lernen
|
# f. KEIN Lernen
|
||||||
# g. Cleanup
|
# g. Cleanup
|
||||||
del self._recent_auto_routes[room_id]
|
del self._recent_auto_routes[origin_room_id]
|
||||||
# Dispatch im Ursprungsraum
|
# Dispatch im Ursprungsraum
|
||||||
await self._dispatch_agent(
|
await self._dispatch_agent(
|
||||||
text=display_text,
|
text=display_text,
|
||||||
room_id=room_id,
|
room_id=origin_room_id,
|
||||||
room_name=room_name,
|
room_name=self._room_info.get(origin_room_id, {}).get("name", room_name),
|
||||||
room_type=room_type,
|
room_type=self._room_info.get(origin_room_id, {}).get("type", room_type),
|
||||||
username=username,
|
username=username,
|
||||||
msg_id=msg_id,
|
msg_id=msg_id,
|
||||||
msg_obj=msg_obj,
|
msg_obj=msg_obj,
|
||||||
@@ -2536,7 +2634,8 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# Zeitfenster abgelaufen → aufräumen
|
# Zeitfenster abgelaufen → aufräumen
|
||||||
del self._recent_auto_routes[room_id]
|
origin_rid = route_info.get("origin_room", room_id)
|
||||||
|
self._recent_auto_routes.pop(origin_rid, None)
|
||||||
|
|
||||||
# ── V8.3-4: Expliziter Raumwechsel (BEWUSSTE ENTSCHEIDUNG) ────────
|
# ── V8.3-4: Expliziter Raumwechsel (BEWUSSTE ENTSCHEIDUNG) ────────
|
||||||
# V8.3.4 B3: Verb-basierte Erkennung statt #-Pflicht.
|
# V8.3.4 B3: Verb-basierte Erkennung statt #-Pflicht.
|
||||||
@@ -3017,6 +3116,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"timestamp": time.time(),
|
"timestamp": time.time(),
|
||||||
"origin_message_id": msg_id,
|
"origin_message_id": msg_id,
|
||||||
"target_message_id": target_message_id or "",
|
"target_message_id": target_message_id or "",
|
||||||
|
"source": "auto", # FIX 4: confirm_move vs auto-route
|
||||||
}
|
}
|
||||||
|
|
||||||
# _CURRENT_ORIGIN_ROOM wird NUR gesetzt wenn nicht forwarded.
|
# _CURRENT_ORIGIN_ROOM wird NUR gesetzt wenn nicht forwarded.
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ MOVE_REQUEST_TEMPLATE: dict = {
|
|||||||
"text": "Soll ich diese Nachricht nach {target_name} kopieren?",
|
"text": "Soll ich diese Nachricht nach {target_name} kopieren?",
|
||||||
"actions": [
|
"actions": [
|
||||||
{"text": "1️⃣ Rüber", "type": "confirm_move"},
|
{"text": "1️⃣ Rüber", "type": "confirm_move"},
|
||||||
{"text": "2️⃣ Generell hier", "type": "stay_here"},
|
{"text": "2️⃣ Thema hier lassen", "type": "stay_here"},
|
||||||
{"text": "3️⃣ Nur diesmal", "type": "stay_once"},
|
{"text": "3️⃣ Nur diesmal", "type": "stay_once"},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,26 @@ _QUOTE_AUTHOR_BLOCK_RE = re.compile(
|
|||||||
re.DOTALL | re.IGNORECASE,
|
re.DOTALL | re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ── FIX 5 (P1): ISSUE 2 — Archivar-Output-Marker ─────────────────────────
|
||||||
|
# Archivar-Phrasen, die auf eine Move-Request-Frage hindeuten.
|
||||||
|
# Bei Match wird die folgende Raumnamen-Erwähnung NICHT in routing_text
|
||||||
|
# aufgenommen, um Fehl-Routing durch Archivar-Output zu verhindern.
|
||||||
|
_ARCHIVAR_ARTIFACT_PHRASES = [
|
||||||
|
"Soll ich diese Nachricht nach",
|
||||||
|
"Soll ich den Auftrag dorthin",
|
||||||
|
"Möchtest du, dass ich",
|
||||||
|
"Soll ich das nach",
|
||||||
|
"Soll ich die Nachricht nach",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Regex: erkennt Raumnamen nach Archivar-Phrasen
|
||||||
|
# Pattern: Phrase + optional whitespace + #?Raumname
|
||||||
|
_ARCHIVAR_ARTIFACT_RE = re.compile(
|
||||||
|
r'(?:' + '|'.join(re.escape(p) for p in _ARCHIVAR_ARTIFACT_PHRASES) + r')'
|
||||||
|
r'\s+#?[\w-]+',
|
||||||
|
re.IGNORECASE,
|
||||||
|
)
|
||||||
|
|
||||||
# Rocket.Chat attachment types that indicate a reply quote
|
# Rocket.Chat attachment types that indicate a reply quote
|
||||||
_REPLY_ATTACHMENT_TYPES = frozenset({
|
_REPLY_ATTACHMENT_TYPES = frozenset({
|
||||||
'reply',
|
'reply',
|
||||||
@@ -113,6 +133,28 @@ def _strip_quote_blocks(text: str) -> str:
|
|||||||
return text.strip()
|
return text.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_archivar_artifact(text: str) -> Tuple[str, bool]:
|
||||||
|
"""FIX 5 (P1): Entferne Archivar-Output-Marker aus dem Text.
|
||||||
|
|
||||||
|
Erkennt Phrasen wie 'Soll ich diese Nachricht nach #LAN-Dokumentation
|
||||||
|
kopieren?' und entfernt den Raumnamen-Teil, damit der Router nicht
|
||||||
|
fälschlich auf den Raum-Namen matcht.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple aus (bereinigtem Text, ob ein Artifact erkannt wurde).
|
||||||
|
"""
|
||||||
|
if not text:
|
||||||
|
return text, False
|
||||||
|
|
||||||
|
match = _ARCHIVAR_ARTIFACT_RE.search(text)
|
||||||
|
if match:
|
||||||
|
# Entferne den gesamten Match (Phrase + Raumnamen)
|
||||||
|
result = text[:match.start()] + text[match.end():]
|
||||||
|
result = result.strip()
|
||||||
|
return result, True
|
||||||
|
return text, False
|
||||||
|
|
||||||
|
|
||||||
def strip_reply_quote(
|
def strip_reply_quote(
|
||||||
text: str,
|
text: str,
|
||||||
attachments: Optional[list] = None,
|
attachments: Optional[list] = None,
|
||||||
@@ -167,6 +209,14 @@ def strip_reply_quote(
|
|||||||
if result != before_bq:
|
if result != before_bq:
|
||||||
stripped = True
|
stripped = True
|
||||||
|
|
||||||
|
# ── FIX 5 (P1): Archivar-Output-Marker ──────────────────────────────
|
||||||
|
# Läuft immer (nicht nur wenn !stripped), weil Archivar-Output
|
||||||
|
# auch in Nachrichten ohne Quote vorkommen kann.
|
||||||
|
before_artifact = result
|
||||||
|
result, artifact_detected = _strip_archivar_artifact(result)
|
||||||
|
if artifact_detected:
|
||||||
|
stripped = True
|
||||||
|
|
||||||
# Clean up: collapse multiple blank lines, strip
|
# Clean up: collapse multiple blank lines, strip
|
||||||
result = re.sub(r'\n{3,}', '\n\n', result)
|
result = re.sub(r'\n{3,}', '\n\n', result)
|
||||||
result = result.strip()
|
result = result.strip()
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ def _build_mock_adapter(room_map_path: str):
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._onboarding_state = {}
|
adapter._onboarding_state = {}
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
|
|||||||
@@ -526,6 +526,7 @@ class TestFaktStoreOnboardingAdapter:
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._onboarding_state = {}
|
adapter._onboarding_state = {}
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ def _build_mock_adapter(room_map_path: str):
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._onboarding_state = {}
|
adapter._onboarding_state = {}
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ def _build_mock_adapter(room_map_path: str):
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._onboarding_state = {}
|
adapter._onboarding_state = {}
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ def _build_mock_adapter(room_map_path: str):
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._onboarding_state = {}
|
adapter._onboarding_state = {}
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ def _make_mock_adapter():
|
|||||||
adapter._recent_auto_routes = {}
|
adapter._recent_auto_routes = {}
|
||||||
adapter._explicit_switch_sticky = {}
|
adapter._explicit_switch_sticky = {}
|
||||||
adapter._clarify_state = {}
|
adapter._clarify_state = {}
|
||||||
|
adapter._pending_clarify_dispatch = {} # FIX 2 (P0): ISSUE 3
|
||||||
adapter._room_map_summary = ""
|
adapter._room_map_summary = ""
|
||||||
|
|
||||||
# Mock REST
|
# Mock REST
|
||||||
|
|||||||
Reference in New Issue
Block a user