mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-23 10:42:00 +00:00
fix(slack): split csv mention pattern fallback
This commit is contained in:
parent
4966268764
commit
441bd6d8db
2 changed files with 11 additions and 3 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue