fix(slack): split csv mention pattern fallback

This commit is contained in:
iaji 2026-06-22 08:33:53 -04:00 committed by Teknium
parent 4966268764
commit 441bd6d8db
2 changed files with 11 additions and 3 deletions

View file

@ -3838,9 +3838,7 @@ class SlackAdapter(BasePlatformAdapter):
import json as _json
patterns = _json.loads(raw)
except Exception:
patterns = [p.strip() for p in raw.splitlines() if p.strip()] or [
p.strip() for p in raw.split(",") if p.strip()
]
patterns = [p.strip() for p in raw.replace("\n", ",").split(",") if p.strip()]
if isinstance(patterns, str):
patterns = [patterns]

View file

@ -735,6 +735,16 @@ def test_mention_patterns_env_var_fallback(monkeypatch):
assert adapter._slack_message_matches_mention_patterns("hey hermes") is True
def test_mention_patterns_env_var_csv_fallback_splits_patterns(monkeypatch):
monkeypatch.setenv("SLACK_MENTION_PATTERNS", "hey hermes,hermes,")
adapter = _make_adapter() # no config value -> falls back to env
patterns = adapter._slack_mention_patterns()
assert [pattern.pattern for pattern in patterns] == ["hey hermes", "hermes"]
assert adapter._slack_message_matches_mention_patterns("hey hermes") is True
def test_mention_patterns_trigger_in_channel_without_literal_mention():
"""A wake word triggers the bot in a channel even with require_mention on."""
adapter = _make_adapter(require_mention=True, mention_patterns=["hey hermes"])