fix: enforce requireMention setting for Feishu group chats#384
Open
yan-labs wants to merge 1 commit intoop7418:mainfrom
Open
fix: enforce requireMention setting for Feishu group chats#384yan-labs wants to merge 1 commit intoop7418:mainfrom
yan-labs wants to merge 1 commit intoop7418:mainfrom
Conversation
|
@yan-labs is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
The `bridge_feishu_require_mention` setting existed in the config UI and was loaded from the database, but was never actually checked in the message handling pipeline. Group chat messages were always processed regardless of whether the bot was @mentioned. Changes: - Fetch bot identity (open_id) on plugin startup via getBotInfo() - Check `message.mentions` against botOpenId when requireMention is enabled and the message comes from a group chat (chatId starts with 'oc_') - Strip the @bot mention placeholder from message text so the LLM receives clean input - Return null (skip message) when requireMention is true and the bot is not mentioned
eb45ee5 to
d6b959a
Compare
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.
Problem
The
bridge_feishu_require_mentionsetting exists in the config UI and is loaded from the database, but it was never actually checked in the message handling pipeline. This means the bot responds to all messages in group chats, even when "Require @mention" is enabled.The Discord adapter correctly implements this check, but the Feishu adapter was missing the equivalent logic.
Changes
src/lib/channels/feishu/inbound.tsisBotMentioned()helper that checksmessage.mentionsarray for the bot'sopen_idconfig.requireMentionistrueand the message is from a group chat (oc_prefix), skip messages where the bot is not @mentioned@botmention placeholder (e.g.@_user_1) from message text so the LLM receives clean inputsrc/lib/channels/feishu/index.tsgetBotInfo()after gateway starts, storingbotOpenIdbotOpenIdtoparseInboundMessage()for mention detectionHow it works
Feishu includes a
mentionsarray inim.message.receive_v1events:{ "message": { "mentions": [ { "key": "@_user_1", "id": { "open_id": "ou_xxx" }, "name": "MyBot" } ] } }The fix checks this array against the bot's
open_id(fetched at startup) whenrequireMentionis enabled.Test plan
@botplaceholder should be stripped from the input