diff --git a/extensions/feishu/src/bot.stripBotMention.test.ts b/extensions/feishu/src/bot.stripBotMention.test.ts index 543af29a0eb..1c23c8fced9 100644 --- a/extensions/feishu/src/bot.stripBotMention.test.ts +++ b/extensions/feishu/src/bot.stripBotMention.test.ts @@ -37,7 +37,7 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => { expect(ctx.content).toBe("hello"); }); - it("normalizes bot mention to tag in group (semantic content)", () => { + it("strips bot mention in group so slash commands work (#35994)", () => { const ctx = parseFeishuMessageEvent( makeEvent( "@_bot_1 hello", @@ -46,7 +46,19 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => { ) as any, BOT_OPEN_ID, ); - expect(ctx.content).toBe('Bot hello'); + expect(ctx.content).toBe("hello"); + }); + + it("strips bot mention in group preserving slash command prefix (#35994)", () => { + const ctx = parseFeishuMessageEvent( + makeEvent( + "@_bot_1 /model", + [{ key: "@_bot_1", name: "Bot", id: { open_id: "ou_bot" } }], + "group", + ) as any, + BOT_OPEN_ID, + ); + expect(ctx.content).toBe("/model"); }); it("strips bot mention but normalizes other mentions in p2p (mention-forward)", () => { diff --git a/extensions/feishu/src/bot.ts b/extensions/feishu/src/bot.ts index de382d7efab..32423d7f176 100644 --- a/extensions/feishu/src/bot.ts +++ b/extensions/feishu/src/bot.ts @@ -764,14 +764,12 @@ export function parseFeishuMessageEvent( const rawContent = parseMessageContent(event.message.content, event.message.message_type); const mentionedBot = checkBotMentioned(event, botOpenId); const hasAnyMention = (event.message.mentions?.length ?? 0) > 0; - // In p2p, the bot mention is a pure addressing prefix with no semantic value; - // strip it so slash commands like @Bot /help still have a leading /. + // Strip the bot's own mention so slash commands like @Bot /help retain + // the leading /. This applies in both p2p *and* group contexts — the + // mentionedBot flag already captures whether the bot was addressed, so + // keeping the mention tag in content only breaks command detection (#35994). // Non-bot mentions (e.g. mention-forward targets) are still normalized to tags. - const content = normalizeMentions( - rawContent, - event.message.mentions, - event.message.chat_type === "p2p" ? botOpenId : undefined, - ); + const content = normalizeMentions(rawContent, event.message.mentions, botOpenId); const senderOpenId = event.sender.sender_id.open_id?.trim(); const senderUserId = event.sender.sender_id.user_id?.trim(); const senderFallbackId = senderOpenId || senderUserId || "";