Skip to content

Commit 995ae73

Browse files
authored
synthesis: fix Feishu group mention slash parsing
## Summary\n\nFeishu group slash command parsing is fixed for mentions and command probes across authorization paths.\n\nThis includes:\n- Normalizing bot mention text in group context for reliable slash detection in message parsing.\n- Adding command-probe normalization for group slash invocations.\n\nCo-authored-by: Sid Qin <[email protected]>\nCo-authored-by: Tak Hoffman <[email protected]>
1 parent 2972d6f commit 995ae73

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

extensions/feishu/src/bot.stripBotMention.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
3737
expect(ctx.content).toBe("hello");
3838
});
3939

40-
it("normalizes bot mention to <at> tag in group (semantic content)", () => {
40+
it("strips bot mention in group so slash commands work (#35994)", () => {
4141
const ctx = parseFeishuMessageEvent(
4242
makeEvent(
4343
"@_bot_1 hello",
@@ -46,7 +46,19 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
4646
) as any,
4747
BOT_OPEN_ID,
4848
);
49-
expect(ctx.content).toBe('<at user_id="ou_bot">Bot</at> hello');
49+
expect(ctx.content).toBe("hello");
50+
});
51+
52+
it("strips bot mention in group preserving slash command prefix (#35994)", () => {
53+
const ctx = parseFeishuMessageEvent(
54+
makeEvent(
55+
"@_bot_1 /model",
56+
[{ key: "@_bot_1", name: "Bot", id: { open_id: "ou_bot" } }],
57+
"group",
58+
) as any,
59+
BOT_OPEN_ID,
60+
);
61+
expect(ctx.content).toBe("/model");
5062
});
5163

5264
it("strips bot mention but normalizes other mentions in p2p (mention-forward)", () => {

extensions/feishu/src/bot.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,12 @@ export function parseFeishuMessageEvent(
764764
const rawContent = parseMessageContent(event.message.content, event.message.message_type);
765765
const mentionedBot = checkBotMentioned(event, botOpenId);
766766
const hasAnyMention = (event.message.mentions?.length ?? 0) > 0;
767-
// In p2p, the bot mention is a pure addressing prefix with no semantic value;
768-
// strip it so slash commands like @Bot /help still have a leading /.
767+
// Strip the bot's own mention so slash commands like @Bot /help retain
768+
// the leading /. This applies in both p2p *and* group contexts — the
769+
// mentionedBot flag already captures whether the bot was addressed, so
770+
// keeping the mention tag in content only breaks command detection (#35994).
769771
// Non-bot mentions (e.g. mention-forward targets) are still normalized to <at> tags.
770-
const content = normalizeMentions(
771-
rawContent,
772-
event.message.mentions,
773-
event.message.chat_type === "p2p" ? botOpenId : undefined,
774-
);
772+
const content = normalizeMentions(rawContent, event.message.mentions, botOpenId);
775773
const senderOpenId = event.sender.sender_id.open_id?.trim();
776774
const senderUserId = event.sender.sender_id.user_id?.trim();
777775
const senderFallbackId = senderOpenId || senderUserId || "";

0 commit comments

Comments
 (0)