fix: honor telegram account replyToMode

This commit is contained in:
Tak Hoffman 2026-04-03 10:16:05 -05:00
parent 30c0dc3d47
commit a3541a1cce
No known key found for this signature in database
2 changed files with 32 additions and 1 deletions

View File

@ -220,6 +220,33 @@ describe("telegramPlugin messaging", () => {
});
});
describe("telegramPlugin threading", () => {
it("honors per-account replyToMode overrides", () => {
const resolveReplyToMode = telegramPlugin.threading?.resolveReplyToMode;
if (!resolveReplyToMode) {
throw new Error("Expected telegramPlugin.threading.resolveReplyToMode to be defined");
}
const cfg = {
channels: {
telegram: {
replyToMode: "all",
botToken: "token-default",
accounts: {
work: {
botToken: "token-work",
replyToMode: "first",
},
},
},
},
} as OpenClawConfig;
expect(resolveReplyToMode({ cfg, accountId: "work" })).toBe("first");
expect(resolveReplyToMode({ cfg, accountId: "default" })).toBe("all");
});
});
describe("telegramPlugin threading", () => {
it("keeps topic thread state in plugin-owned tool context", () => {
expect(

View File

@ -871,7 +871,11 @@ export const telegramPlugin = createChatChannelPlugin({
collectWarnings: collectTelegramSecurityWarnings,
},
threading: {
topLevelReplyToMode: "telegram",
scopedAccountReplyToMode: {
resolveAccount: (cfg, accountId) => resolveTelegramAccount({ cfg, accountId }),
resolveReplyToMode: (account) => account.config.replyToMode,
fallback: "off",
},
buildToolContext: (params) => buildTelegramThreadingToolContext(params),
resolveAutoThreadId: ({ to, toolContext }) => resolveTelegramAutoThreadId({ to, toolContext }),
},