Skip to content

Commit f4f5310

Browse files
steipeteTakhoffman
andcommitted
fix(telegram): restore account-scoped reply mode
Resolve reply mode through the selected Telegram account so account overrides and top-level inheritance reach outbound reply context. Co-authored-by: Tak Hoffman <[email protected]>
1 parent 9fdc266 commit f4f5310

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎extensions/telegram/src/channel.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,11 @@ export const telegramPlugin = createChatChannelPlugin({
12461246
},
12471247
security: telegramSecurityAdapter,
12481248
threading: {
1249-
topLevelReplyToMode: "telegram",
1249+
scopedAccountReplyToMode: {
1250+
resolveAccount: (cfg, accountId) => resolveTelegramAccount({ cfg, accountId }),
1251+
resolveReplyToMode: (account) => account.config.replyToMode,
1252+
fallback: "off",
1253+
},
12501254
buildToolContext: (params) => buildTelegramThreadingToolContext(params),
12511255
resolveAutoThreadId: ({ to, toolContext }) => resolveTelegramAutoThreadId({ to, toolContext }),
12521256
resolveCurrentChannelId: ({ to, threadId }) => {

‎extensions/telegram/src/threading-tool-context.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11
// Telegram tests cover threading tool context plugin behavior.
22
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
33
import { describe, expect, it } from "vitest";
4+
import { telegramPlugin } from "./channel.js";
45
import { buildTelegramThreadingToolContext } from "./threading-tool-context.js";
56

7+
describe("telegramPlugin reply threading", () => {
8+
it.each([
9+
{
10+
name: "uses an account override",
11+
telegram: {
12+
botToken: "token-default",
13+
accounts: { sut: { botToken: "token-sut", replyToMode: "first" as const } },
14+
},
15+
expected: "first",
16+
},
17+
{
18+
name: "inherits the top-level mode",
19+
telegram: {
20+
botToken: "token-default",
21+
replyToMode: "all" as const,
22+
accounts: { sut: { botToken: "token-sut" } },
23+
},
24+
expected: "all",
25+
},
26+
{
27+
name: "allows an account to disable replies",
28+
telegram: {
29+
botToken: "token-default",
30+
replyToMode: "all" as const,
31+
accounts: { sut: { botToken: "token-sut", replyToMode: "off" as const } },
32+
},
33+
expected: "off",
34+
},
35+
])("$name", ({ telegram, expected }) => {
36+
const resolveReplyToMode = telegramPlugin.threading?.resolveReplyToMode;
37+
if (!resolveReplyToMode) {
38+
throw new Error("Telegram reply mode resolver is unavailable");
39+
}
40+
41+
const cfg = { channels: { telegram } } as OpenClawConfig;
42+
expect(resolveReplyToMode({ cfg, accountId: "sut" })).toBe(expected);
43+
});
44+
});
45+
646
describe("buildTelegramThreadingToolContext", () => {
747
it("keeps topic thread state in plugin-owned tool context", () => {
848
const hasRepliedRef = { value: false };

0 commit comments

Comments
 (0)