mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 04:37:27 +00:00
Feishu: normalize group slash command probing
- Feishu/group slash command detection: normalize group mention wrappers before command-authorization probing so mention-prefixed commands are recognized in group routing.\n- Source PR: #36011\n- Contributor: @liuxiaopai-ai\n\nCo-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>\nCo-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
- iMessage/cron completion announces: strip leaked inline reply tags (for example `[[reply_to:6100]]`) from user-visible completion text so announcement deliveries do not expose threading metadata. (#24600) Thanks @vincentkoc.
|
- iMessage/cron completion announces: strip leaked inline reply tags (for example `[[reply_to:6100]]`) from user-visible completion text so announcement deliveries do not expose threading metadata. (#24600) Thanks @vincentkoc.
|
||||||
|
- Feishu/group slash command detection: normalize group mention wrappers before command-authorization probing so mention-prefixed commands (for example `@Bot/model` and `@Bot /reset`) are recognized as gateway commands instead of being forwarded to the agent. (#35994) Thanks @liuxiaopai-ai.
|
||||||
- Agents/context pruning: guard assistant thinking/text char estimation against malformed blocks (missing `thinking`/`text` strings or null entries) so pruning no longer crashes with malformed provider content. (openclaw#35146) thanks @Sid-Qin.
|
- Agents/context pruning: guard assistant thinking/text char estimation against malformed blocks (missing `thinking`/`text` strings or null entries) so pruning no longer crashes with malformed provider content. (openclaw#35146) thanks @Sid-Qin.
|
||||||
- Agents/schema cleaning: detect Venice + Grok model IDs as xAI-proxied targets so unsupported JSON Schema keywords are stripped before requests, preventing Venice/Grok `Invalid arguments` failures. (openclaw#35355) thanks @Sid-Qin.
|
- Agents/schema cleaning: detect Venice + Grok model IDs as xAI-proxied targets so unsupported JSON Schema keywords are stripped before requests, preventing Venice/Grok `Invalid arguments` failures. (openclaw#35355) thanks @Sid-Qin.
|
||||||
- Skills/native command deduplication: centralize skill command dedupe by canonical `skillName` in `listSkillCommandsForAgents` so duplicate suffixed variants (for example `_2`) are no longer surfaced across interfaces outside Discord. (#27521) thanks @shivama205.
|
- Skills/native command deduplication: centralize skill command dedupe by canonical `skillName` in `listSkillCommandsForAgents` so duplicate suffixed variants (for example `_2`) are no longer surfaced across interfaces outside Discord. (#27521) thanks @shivama205.
|
||||||
|
|||||||
@@ -521,6 +521,42 @@ describe("handleFeishuMessage command authorization", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("normalizes group mention-prefixed slash commands before command-auth probing", async () => {
|
||||||
|
mockShouldComputeCommandAuthorized.mockReturnValue(true);
|
||||||
|
|
||||||
|
const cfg: ClawdbotConfig = {
|
||||||
|
channels: {
|
||||||
|
feishu: {
|
||||||
|
groups: {
|
||||||
|
"oc-group": {
|
||||||
|
requireMention: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as ClawdbotConfig;
|
||||||
|
|
||||||
|
const event: FeishuMessageEvent = {
|
||||||
|
sender: {
|
||||||
|
sender_id: {
|
||||||
|
open_id: "ou-attacker",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
message_id: "msg-group-mention-command-probe",
|
||||||
|
chat_id: "oc-group",
|
||||||
|
chat_type: "group",
|
||||||
|
message_type: "text",
|
||||||
|
content: JSON.stringify({ text: "@_user_1/model" }),
|
||||||
|
mentions: [{ key: "@_user_1", id: { open_id: "ou-bot" }, name: "Bot", tenant_key: "" }],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
await dispatchMessage({ cfg, event });
|
||||||
|
|
||||||
|
expect(mockShouldComputeCommandAuthorized).toHaveBeenCalledWith("/model", cfg);
|
||||||
|
});
|
||||||
|
|
||||||
it("falls back to top-level allowFrom for group command authorization", async () => {
|
it("falls back to top-level allowFrom for group command authorization", async () => {
|
||||||
mockShouldComputeCommandAuthorized.mockReturnValue(true);
|
mockShouldComputeCommandAuthorized.mockReturnValue(true);
|
||||||
mockResolveCommandAuthorizedFromAuthorizers.mockReturnValue(true);
|
mockResolveCommandAuthorizedFromAuthorizers.mockReturnValue(true);
|
||||||
|
|||||||
@@ -494,6 +494,17 @@ function normalizeMentions(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeFeishuCommandProbeBody(text: string): string {
|
||||||
|
if (!text) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
.replace(/<at\b[^>]*>[^<]*<\/at>/giu, " ")
|
||||||
|
.replace(/(^|\s)@[^/\s]+(?=\s|$|\/)/gu, "$1")
|
||||||
|
.replace(/\s+/g, " ")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse media keys from message content based on message type.
|
* Parse media keys from message content based on message type.
|
||||||
*/
|
*/
|
||||||
@@ -1069,8 +1080,9 @@ export async function handleFeishuMessage(params: {
|
|||||||
channel: "feishu",
|
channel: "feishu",
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
});
|
});
|
||||||
|
const commandProbeBody = isGroup ? normalizeFeishuCommandProbeBody(ctx.content) : ctx.content;
|
||||||
const shouldComputeCommandAuthorized = core.channel.commands.shouldComputeCommandAuthorized(
|
const shouldComputeCommandAuthorized = core.channel.commands.shouldComputeCommandAuthorized(
|
||||||
ctx.content,
|
commandProbeBody,
|
||||||
cfg,
|
cfg,
|
||||||
);
|
);
|
||||||
const storeAllowFrom =
|
const storeAllowFrom =
|
||||||
|
|||||||
Reference in New Issue
Block a user