atlasbot: recognize prefix mentions
This commit is contained in:
parent
0ac0f920ca
commit
be7846572f
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user