惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
博客园 - 叶小钗
J
Java Code Geeks
博客园 - 聂微东
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
美团技术团队
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
罗磊的独立博客
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
小众软件
小众软件

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(telegram): honor topic requireMention precedence · op...
Panniantong · 2026-05-05 · via Recent Commits to openclaw:main

@@ -0,0 +1,112 @@

1+

import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";

2+

import { beforeEach, describe, expect, it, vi } from "vitest";

3+4+

const { defaultRouteConfig } = vi.hoisted(() => ({

5+

defaultRouteConfig: {

6+

agents: {

7+

list: [{ id: "main", default: true }],

8+

},

9+

channels: { telegram: {} },

10+

messages: { groupChat: { mentionPatterns: [] } },

11+

},

12+

}));

13+14+

vi.mock("openclaw/plugin-sdk/runtime-config-snapshot", async () => {

15+

const actual = await vi.importActual<

16+

typeof import("openclaw/plugin-sdk/runtime-config-snapshot")

17+

>("openclaw/plugin-sdk/runtime-config-snapshot");

18+

return {

19+

...actual,

20+

getRuntimeConfig: vi.fn(() => defaultRouteConfig),

21+

};

22+

});

23+24+

const { buildTelegramMessageContextForTest } =

25+

await import("./bot-message-context.test-harness.js");

26+27+

describe("buildTelegramMessageContext requireMention precedence", () => {

28+

function buildForumMessage(threadId = 99) {

29+

return {

30+

message_id: 1,

31+

chat: {

32+

id: -1001234567890,

33+

type: "supergroup" as const,

34+

title: "Forum",

35+

is_forum: true,

36+

},

37+

date: 1_700_000_000,

38+

text: "hello everyone",

39+

message_thread_id: threadId,

40+

from: { id: 42, first_name: "Alice" },

41+

};

42+

}

43+44+

beforeEach(() => {

45+

vi.mocked(getRuntimeConfig).mockReturnValue(defaultRouteConfig as never);

46+

});

47+48+

it("lets explicit topic requireMention=false override group requireMention=true", async () => {

49+

const ctx = await buildTelegramMessageContextForTest({

50+

message: buildForumMessage(),

51+

resolveGroupActivation: () => undefined,

52+

resolveGroupRequireMention: () => true,

53+

resolveTelegramGroupConfig: () => ({

54+

groupConfig: { requireMention: true },

55+

topicConfig: { requireMention: false },

56+

}),

57+

});

58+59+

expect(ctx).not.toBeNull();

60+

});

61+62+

it("lets explicit topic requireMention=false override mention activation", async () => {

63+

const resolveGroupActivation = vi.fn(() => true);

64+65+

const ctx = await buildTelegramMessageContextForTest({

66+

message: buildForumMessage(),

67+

resolveGroupActivation,

68+

resolveGroupRequireMention: () => true,

69+

resolveTelegramGroupConfig: () => ({

70+

groupConfig: { requireMention: true },

71+

topicConfig: { requireMention: false },

72+

}),

73+

});

74+75+

expect(ctx).not.toBeNull();

76+

expect(resolveGroupActivation).toHaveBeenCalledWith(

77+

expect.objectContaining({

78+

chatId: -1001234567890,

79+

messageThreadId: 99,

80+

sessionKey: "agent:main:telegram:group:-1001234567890:topic:99",

81+

}),

82+

);

83+

});

84+85+

it("lets explicit topic requireMention=true override always activation", async () => {

86+

const ctx = await buildTelegramMessageContextForTest({

87+

message: buildForumMessage(),

88+

resolveGroupActivation: () => false,

89+

resolveGroupRequireMention: () => false,

90+

resolveTelegramGroupConfig: () => ({

91+

groupConfig: { requireMention: false },

92+

topicConfig: { requireMention: true },

93+

}),

94+

});

95+96+

expect(ctx).toBeNull();

97+

});

98+99+

it("keeps activation fallback when no topic requireMention is configured", async () => {

100+

const ctx = await buildTelegramMessageContextForTest({

101+

message: buildForumMessage(),

102+

resolveGroupActivation: () => false,

103+

resolveGroupRequireMention: () => true,

104+

resolveTelegramGroupConfig: () => ({

105+

groupConfig: { requireMention: true },

106+

topicConfig: { agentId: "main" },

107+

}),

108+

});

109+110+

expect(ctx).not.toBeNull();

111+

});

112+

});