Skip to content

fix: enforce requireMention setting for Feishu group chats#384

Open
yan-labs wants to merge 1 commit intoop7418:mainfrom
yan-labs:fix/feishu-require-mention
Open

fix: enforce requireMention setting for Feishu group chats#384
yan-labs wants to merge 1 commit intoop7418:mainfrom
yan-labs:fix/feishu-require-mention

Conversation

@yan-labs
Copy link

Problem

The bridge_feishu_require_mention setting 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.ts

  • Added isBotMentioned() helper that checks message.mentions array for the bot's open_id
  • When config.requireMention is true and the message is from a group chat (oc_ prefix), skip messages where the bot is not @mentioned
  • Strip the @bot mention placeholder (e.g. @_user_1) from message text so the LLM receives clean input

src/lib/channels/feishu/index.ts

  • Fetch bot identity via getBotInfo() after gateway starts, storing botOpenId
  • Pass botOpenId to parseInboundMessage() for mention detection

How it works

Feishu includes a mentions array in im.message.receive_v1 events:

{
  "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) when requireMention is enabled.

Test plan

  • Enable "Require @mention" in Feishu settings
  • Send a message in a group chat without @mentioning the bot → bot should not respond
  • Send a message in a group chat with @mention → bot should respond, and the @bot placeholder should be stripped from the input
  • Send a DM → bot should respond regardless of the setting
  • Disable "Require @mention" → bot should respond to all group messages again

@vercel
Copy link

vercel bot commented Mar 25, 2026

@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
@yan-labs yan-labs force-pushed the fix/feishu-require-mention branch from eb45ee5 to d6b959a Compare March 25, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant