Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plugins/platforms/feishu/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4333,9 +4333,16 @@ def _allow_group_message(
# --- Mention detection ----------------------------------------------------

def _mentions_self(self, message: Any) -> bool:
# @_all is Feishu's @everyone placeholder.
# @_all is Feishu's @everyone placeholder. By default Hermes treats
# @everyone as a mention of the bot (so the bot responds in groups
# where someone @everyone's). Set FEISHU_IGNORE_AT_ALL=true to make
# @everyone NOT trigger the bot — it will only respond to explicit
# @bot mentions.
raw_content = getattr(message, "content", "") or ""
if "@_all" in raw_content:
ignore_at_all = os.getenv("FEISHU_IGNORE_AT_ALL", "false").strip().lower() in {"true", "1", "yes", "on"}
if ignore_at_all:
return False
return True
mentions = getattr(message, "mentions", None) or []
if mentions and self._message_mentions_bot(mentions):
Expand Down
29 changes: 29 additions & 0 deletions tests/gateway/test_feishu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3567,6 +3567,35 @@ def test_at_all_still_requires_policy_gate(self):
allowed_sender = SimpleNamespace(open_id="ou_allowed", user_id=None)
self.assertTrue(_admits_group(adapter, message, allowed_sender, ""))

@patch.dict(os.environ, {"FEISHU_GROUP_POLICY": "open", "FEISHU_IGNORE_AT_ALL": "true"}, clear=True)
def test_at_all_ignored_when_env_set(self):
"""FEISHU_IGNORE_AT_ALL=true makes @_all NOT trigger the bot."""
from gateway.config import PlatformConfig
from plugins.platforms.feishu.adapter import FeishuAdapter

adapter = FeishuAdapter(PlatformConfig())
message = SimpleNamespace(
content='{"text":"@_all 请注意"}',
mentions=[],
)
sender_id = SimpleNamespace(open_id="ou_any", user_id=None)
# Should be rejected — @_all is no longer treated as a mention.
self.assertFalse(_admits_group(adapter, message, sender_id, ""))

@patch.dict(os.environ, {"FEISHU_GROUP_POLICY": "open", "FEISHU_IGNORE_AT_ALL": "false"}, clear=True)
def test_at_all_still_triggers_when_env_unset_or_false(self):
"""Default (env unset or false): @_all still triggers the bot."""
from gateway.config import PlatformConfig
from plugins.platforms.feishu.adapter import FeishuAdapter

adapter = FeishuAdapter(PlatformConfig())
message = SimpleNamespace(
content='{"text":"@_all 请注意"}',
mentions=[],
)
sender_id = SimpleNamespace(open_id="ou_any", user_id=None)
self.assertTrue(_admits_group(adapter, message, sender_id, ""))


@unittest.skipUnless(_HAS_LARK_OAPI, "lark-oapi not installed")
class TestSenderNameResolution(unittest.TestCase):
Expand Down