From be7846572f1929e614890d3fd8ddc9e94a2073b5 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Mon, 26 Jan 2026 15:54:00 -0300 Subject: [PATCH] atlasbot: recognize prefix mentions --- services/comms/atlasbot-deployment.yaml | 2 +- services/comms/scripts/atlasbot/bot.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/services/comms/atlasbot-deployment.yaml b/services/comms/atlasbot-deployment.yaml index 031abb8..aa91dcb 100644 --- a/services/comms/atlasbot-deployment.yaml +++ b/services/comms/atlasbot-deployment.yaml @@ -78,7 +78,7 @@ spec: - name: BOT_USER value: atlasbot - name: BOT_MENTIONS - value: atlasbot + value: atlasbot,aatlasbot - name: OLLAMA_URL value: http://chat-ai-gateway.bstein-dev-home.svc.cluster.local/ - name: OLLAMA_MODEL diff --git a/services/comms/scripts/atlasbot/bot.py b/services/comms/scripts/atlasbot/bot.py index ff9019e..f4182cd 100644 --- a/services/comms/scripts/atlasbot/bot.py +++ b/services/comms/scripts/atlasbot/bot.py @@ -119,9 +119,21 @@ def normalize_user_id(token: str) -> str: MENTION_USER_IDS = {normalize_user_id(t).lower() for t in MENTION_TOKENS if normalize_user_id(t)} +def _body_mentions_token(body: str) -> bool: + lower = (body or "").strip().lower() + if not lower: + return False + for token in MENTION_LOCALPARTS: + for prefix in (token, f"@{token}"): + if lower.startswith(prefix + ":") or lower.startswith(prefix + ",") or lower.startswith(prefix + " "): + return True + return False + def is_mentioned(content: dict, body: str) -> bool: if MENTION_RE.search(body or "") is not None: return True + if _body_mentions_token(body or ""): + return True mentions = content.get("m.mentions", {}) user_ids = mentions.get("user_ids", []) if not isinstance(user_ids, list):