feat(feishu): add ignore_at_all config to opt out of @everyone triggering the bot - #96518
Open
DavidMetcalfe wants to merge 6 commits into
Open
DavidMetcalfe wants to merge 6 commits into
DavidMetcalfe wants to merge 6 commits into
Conversation
… tests Cross-vendor review findings (Gemini 3.1 Pro): extra.get() fallback ordering made YAML override env at read time, contradicting the _apply_yaml_config bridge contract. Also replaces manual os.environ.pop with patch.dict in the bridge tests to prevent env pollution across the suite.
Contributor
…oad_gateway_config Covers the gap the NousResearch#60910 review identified: the documented YAML key must reach FEISHU_IGNORE_AT_ALL through the real gateway config load path, not just the adapter's unit-level bridge.
Contributor
Author
|
@alt-glitch — thanks for the triage cross-link. Adding context for the maintainers, since the label understates the differences:
Given that, this is closer to a superseding implementation than a duplicate — but that's a maintainer call, so leaving the label decision with them. @glow1128's approach preserved the same default behavior, and if they return, the branch is trivially salvageable. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33723
Problem
In Feishu group chats, the bot always responds to
@所有人/@everyonementions because_mentions_self()inplugins/platforms/feishu/adapter.pyshort-circuits toTruewhenever@_allappears in the raw message content. In announcement-heavy groups this produces unwanted bot responses that can't be disabled.Solution
Adds an opt-in config so
@_allalone no longer triggers the bot:FEISHU_IGNORE_AT_ALL=truefeishu.ignore_at_all: true(bridged to the env var via the plugin'sapply_yaml_config_fnhook; env wins when both are set)false— behavior is unchanged for every existing userWhen enabled, the
@_allshort-circuit in_mentions_self()is skipped and only explicit bot mentions trigger the bot (both the rawmentions[]path and the post/rich-textis_selfref path remain fully intact — an@_allref never setsis_self, so the two paths don't interact).Precedence chain: explicit env var →
feishu.ignore_at_allYAML key → defaultfalse.Naming note
The issue proposed
FEISHU_IGNORE_MENTION_ALL/feishu.ignore_mention_all. This PR usesFEISHU_IGNORE_AT_ALL/feishu.ignore_at_all, the name that 3 of the 5 prior PRs for this issue converged on. Happy to rename if maintainers prefer.Docs
Documented in English and zh-Hans:
website/docs/user-guide/messaging/feishu.md(prose + table row),website/docs/reference/environment-variables.md, and both zh-Hans mirrors.Test plan
python -m pytest tests/gateway/test_feishu.py tests/gateway/test_feishu_bot_admission.py -q→ 89 passed, 18 skippedtest_feishu.py,test_feishu_bot_admission.py,test_feishu_bot_auth_bypass.py,test_feishu_approval_buttons.py) → 104 passed, 18 skipped_mentions_selfgating (all-only gated when enabled, explicit bot mention still triggers when enabled), admission-level rejection/admission, YAML→env bridge (bridge set, env wins, key absent leaves env untouched), and_to_booleanedge pins ("TRUE"/"1"→False)git diff --checkcleanNotes
Open question: the read path for
require_mentionin_load_settingsuses the sameextra.get(..., os.getenv(...))ordering that makes extra-config override the env var (contradicting theapply_yaml_config_fndocstring "Env vars take precedence over YAML"). This PR fixes the ordering for the new key only, following the narrowest-patch approach — whetherrequire_mention(and other keys using the same pattern) should be fixed too is a maintainer call.