mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:14:31 +00:00
fix: treat reply-to-bot as implicit mention across channels
This commit is contained in:
55
src/web/auto-reply/monitor/group-gating.test.ts
Normal file
55
src/web/auto-reply/monitor/group-gating.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { applyGroupGating } from "./group-gating.js";
|
||||
|
||||
const baseConfig = {
|
||||
channels: {
|
||||
whatsapp: {
|
||||
groupPolicy: "open",
|
||||
groups: { "*": { requireMention: true } },
|
||||
},
|
||||
},
|
||||
session: { store: "/tmp/clawdbot-sessions.json" },
|
||||
} as const;
|
||||
|
||||
describe("applyGroupGating", () => {
|
||||
it("treats reply-to-bot as implicit mention", () => {
|
||||
const groupHistories = new Map();
|
||||
const result = applyGroupGating({
|
||||
cfg: baseConfig as unknown as ReturnType<typeof import("../../../config/config.js").loadConfig>,
|
||||
msg: {
|
||||
id: "m1",
|
||||
from: "123@g.us",
|
||||
conversationId: "123@g.us",
|
||||
to: "+15550000",
|
||||
accountId: "default",
|
||||
body: "following up",
|
||||
timestamp: Date.now(),
|
||||
chatType: "group",
|
||||
chatId: "123@g.us",
|
||||
selfJid: "15551234567@s.whatsapp.net",
|
||||
selfE164: "+15551234567",
|
||||
replyToId: "m0",
|
||||
replyToBody: "bot said hi",
|
||||
replyToSender: "+15551234567",
|
||||
replyToSenderJid: "15551234567@s.whatsapp.net",
|
||||
replyToSenderE164: "+15551234567",
|
||||
sendComposing: async () => {},
|
||||
reply: async () => {},
|
||||
sendMedia: async () => {},
|
||||
},
|
||||
conversationId: "123@g.us",
|
||||
groupHistoryKey: "group:123@g.us",
|
||||
agentId: "main",
|
||||
sessionKey: "agent:main:whatsapp:group:123@g.us",
|
||||
baseMentionConfig: { mentionRegexes: [] },
|
||||
groupHistories,
|
||||
groupHistoryLimit: 10,
|
||||
groupMemberNames: new Map(),
|
||||
logVerbose: () => {},
|
||||
replyLogger: { debug: () => {} },
|
||||
});
|
||||
|
||||
expect(result.shouldProcess).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user