mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 11:41:08 +00:00
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
resolveTelegramGroupRequireMention,
|
|
resolveTelegramGroupToolPolicy,
|
|
} from "./group-policy.js";
|
|
|
|
describe("resolveTelegramGroupRequireMention", () => {
|
|
it("prefers topic overrides before group defaults", () => {
|
|
const cfg = {
|
|
channels: {
|
|
telegram: {
|
|
botToken: "telegram-test",
|
|
groups: {
|
|
"-1001": {
|
|
requireMention: true,
|
|
tools: { allow: ["message.send"] },
|
|
topics: {
|
|
"77": {
|
|
requireMention: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig;
|
|
|
|
expect(
|
|
resolveTelegramGroupRequireMention({
|
|
cfg,
|
|
groupId: "-1001:topic:77",
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("resolveTelegramGroupToolPolicy", () => {
|
|
it("uses chat-level tool policy for topic conversation ids", () => {
|
|
const cfg = {
|
|
channels: {
|
|
telegram: {
|
|
botToken: "telegram-test",
|
|
groups: {
|
|
"-1001": {
|
|
tools: { allow: ["message.send"] },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig;
|
|
|
|
expect(
|
|
resolveTelegramGroupToolPolicy({
|
|
cfg,
|
|
groupId: "-1001:topic:77",
|
|
}),
|
|
).toEqual({ allow: ["message.send"] });
|
|
});
|
|
});
|