mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 00:23:33 +00:00
refactor(feishu): unify account-aware tool routing and message body
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { ClawdbotConfig, PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { FeishuMessageEvent } from "./bot.js";
|
||||
import { handleFeishuMessage } from "./bot.js";
|
||||
import { buildFeishuAgentBody, handleFeishuMessage } from "./bot.js";
|
||||
import { setFeishuRuntime } from "./runtime.js";
|
||||
|
||||
const {
|
||||
@@ -61,6 +61,30 @@ async function dispatchMessage(params: { cfg: ClawdbotConfig; event: FeishuMessa
|
||||
});
|
||||
}
|
||||
|
||||
describe("buildFeishuAgentBody", () => {
|
||||
it("builds message id, speaker, quoted content, mentions, and permission notice in order", () => {
|
||||
const body = buildFeishuAgentBody({
|
||||
ctx: {
|
||||
content: "hello world",
|
||||
senderName: "Sender Name",
|
||||
senderOpenId: "ou-sender",
|
||||
messageId: "msg-42",
|
||||
mentionTargets: [{ openId: "ou-target", name: "Target User", key: "@_user_1" }],
|
||||
},
|
||||
quotedContent: "previous message",
|
||||
permissionErrorForAgent: {
|
||||
code: 99991672,
|
||||
message: "permission denied",
|
||||
grantUrl: "https://open.feishu.cn/app/cli_test",
|
||||
},
|
||||
});
|
||||
|
||||
expect(body).toBe(
|
||||
'[message_id: msg-42]\nSender Name: [Replying to: "previous message"]\n\nhello world\n\n[System: Your reply will automatically @mention: Target User. Do not write @xxx yourself.]\n\n[System: The bot encountered a Feishu API permission error. Please inform the user about this issue and provide the permission grant URL for the admin to authorize. Permission grant URL: https://open.feishu.cn/app/cli_test]',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleFeishuMessage command authorization", () => {
|
||||
const mockFinalizeInboundContext = vi.fn((ctx: unknown) => ctx);
|
||||
const mockDispatchReplyFromConfig = vi
|
||||
|
||||
Reference in New Issue
Block a user