


























@@ -92,6 +92,45 @@ describe("parseFeishuMessageEvent – mentionedBot", () => {
9292expect(ctx.mentionedBot).toBe(false);
9393});
949495+it("returns mentionedBot=false for broadcast-only @_all text", () => {
96+const event = makeEvent("group", [], "@_all please review");
97+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
98+expect(ctx.mentionedBot).toBe(false);
99+});
100+101+it("returns mentionedBot=false for broadcast-only @all mention metadata", () => {
102+const event = makeEvent("group", [{ key: "@_all", name: "all", id: { open_id: "all" } }]);
103+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
104+expect(ctx.mentionedBot).toBe(false);
105+});
106+107+it("returns mentionedBot=false for @all even when botOpenId is the broadcast id", () => {
108+const event = makeEvent("group", [{ key: "@_all", name: "all", id: { open_id: "all" } }]);
109+const ctx = parseFeishuMessageEvent(event, "all");
110+expect(ctx.mentionedBot).toBe(false);
111+});
112+113+it("returns mentionedBot=true when bot is mentioned alongside @all", () => {
114+const event = makeEvent("group", [
115+{ key: "@_all", name: "all", id: { open_id: "all" } },
116+{ key: "@_bot_1", name: "Bot", id: { open_id: BOT_OPEN_ID } },
117+]);
118+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
119+expect(ctx.mentionedBot).toBe(true);
120+expect(ctx.mentionTargets).toBeUndefined();
121+});
122+123+it("does not include @all in mention-forward targets", () => {
124+const event = makeEvent("group", [
125+{ key: "@_all", name: "all", id: { open_id: "all" } },
126+{ key: "@_bot_1", name: "Bot", id: { open_id: BOT_OPEN_ID } },
127+{ key: "@_user_1", name: "Alice", id: { open_id: "ou_alice" } },
128+]);
129+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
130+expect(ctx.mentionedBot).toBe(true);
131+expect(ctx.mentionTargets).toEqual([{ openId: "ou_alice", name: "Alice", key: "@_user_1" }]);
132+});
133+95134it("returns mentionedBot=false when botOpenId is undefined (unknown bot)", () => {
96135const event = makeEvent("group", [
97136{ key: "@_user_1", name: "Alice", id: { open_id: "ou_alice" } },
@@ -159,6 +198,39 @@ describe("parseFeishuMessageEvent – mentionedBot", () => {
159198expect(ctx.mentionedBot).toBe(false);
160199});
161200201+it("returns mentionedBot=false for post message with broadcast-only @all", () => {
202+const event = makePostEvent({
203+content: [
204+[{ tag: "at", user_id: "all", user_name: "all" }],
205+[{ tag: "text", text: "hello" }],
206+],
207+});
208+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
209+expect(ctx.mentionedBot).toBe(false);
210+});
211+212+it("returns mentionedBot=false for post @all even when botOpenId is the broadcast id", () => {
213+const event = makePostEvent({
214+content: [[{ tag: "at", user_id: "all", user_name: "all" }]],
215+});
216+const ctx = parseFeishuMessageEvent(event, "all");
217+expect(ctx.mentionedBot).toBe(false);
218+});
219+220+it("returns mentionedBot=true for post message with bot mention and broadcast @all", () => {
221+const event = makePostEvent({
222+content: [
223+[
224+{ tag: "at", user_id: "all", user_name: "all" },
225+{ tag: "text", text: " " },
226+{ tag: "at", user_id: BOT_OPEN_ID, user_name: "claw" },
227+],
228+],
229+});
230+const ctx = parseFeishuMessageEvent(event, BOT_OPEN_ID);
231+expect(ctx.mentionedBot).toBe(true);
232+});
233+162234it("preserves post code and code_block content", () => {
163235const event = makePostEvent({
164236content: [
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。