Merge pull request #2443 from NousResearch/hermes/hermes-31d7db3b
feat(gateway): add @-mention-only filter for Mattermost channels
This commit is contained in:
commit
cd6d24f111
1 changed files with 18 additions and 0 deletions
|
|
@ -580,6 +580,24 @@ class MattermostAdapter(BasePlatformAdapter):
|
||||||
# For DMs, user_id is sufficient. For channels, check for @mention.
|
# For DMs, user_id is sufficient. For channels, check for @mention.
|
||||||
message_text = post.get("message", "")
|
message_text = post.get("message", "")
|
||||||
|
|
||||||
|
# Mention-only mode: skip channel messages that don't @mention the bot.
|
||||||
|
# DMs (type "D") are always processed.
|
||||||
|
if channel_type_raw != "D":
|
||||||
|
mention_patterns = [
|
||||||
|
f"@{self._bot_username}",
|
||||||
|
f"@{self._bot_user_id}",
|
||||||
|
]
|
||||||
|
has_mention = any(
|
||||||
|
pattern.lower() in message_text.lower()
|
||||||
|
for pattern in mention_patterns
|
||||||
|
)
|
||||||
|
if not has_mention:
|
||||||
|
logger.debug(
|
||||||
|
"Mattermost: skipping non-DM message without @mention (channel=%s)",
|
||||||
|
channel_id,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# Resolve sender info.
|
# Resolve sender info.
|
||||||
sender_id = post.get("user_id", "")
|
sender_id = post.get("user_id", "")
|
||||||
sender_name = data.get("sender_name", "").lstrip("@") or sender_id
|
sender_name = data.get("sender_name", "").lstrip("@") or sender_id
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue