mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
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 <sidqin0410@gmail.com>\nCo-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -37,7 +37,7 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
|
||||
expect(ctx.content).toBe("hello");
|
||||
});
|
||||
|
||||
it("normalizes bot mention to <at> 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('<at user_id="ou_bot">Bot</at> 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)", () => {
|
||||
|
||||
@@ -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 <at> 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 || "";
|
||||
|
||||
Reference in New Issue
Block a user