mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
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 <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -1246,7 +1246,11 @@ export const telegramPlugin = createChatChannelPlugin({
|
||||
},
|
||||
security: telegramSecurityAdapter,
|
||||
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 }),
|
||||
resolveCurrentChannelId: ({ to, threadId }) => {
|
||||
|
||||
@@ -1,8 +1,48 @@
|
||||
// Telegram tests cover threading tool context plugin behavior.
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { telegramPlugin } from "./channel.js";
|
||||
import { buildTelegramThreadingToolContext } from "./threading-tool-context.js";
|
||||
|
||||
describe("telegramPlugin reply threading", () => {
|
||||
it.each([
|
||||
{
|
||||
name: "uses an account override",
|
||||
telegram: {
|
||||
botToken: "token-default",
|
||||
accounts: { sut: { botToken: "token-sut", replyToMode: "first" as const } },
|
||||
},
|
||||
expected: "first",
|
||||
},
|
||||
{
|
||||
name: "inherits the top-level mode",
|
||||
telegram: {
|
||||
botToken: "token-default",
|
||||
replyToMode: "all" as const,
|
||||
accounts: { sut: { botToken: "token-sut" } },
|
||||
},
|
||||
expected: "all",
|
||||
},
|
||||
{
|
||||
name: "allows an account to disable replies",
|
||||
telegram: {
|
||||
botToken: "token-default",
|
||||
replyToMode: "all" as const,
|
||||
accounts: { sut: { botToken: "token-sut", replyToMode: "off" as const } },
|
||||
},
|
||||
expected: "off",
|
||||
},
|
||||
])("$name", ({ telegram, expected }) => {
|
||||
const resolveReplyToMode = telegramPlugin.threading?.resolveReplyToMode;
|
||||
if (!resolveReplyToMode) {
|
||||
throw new Error("Telegram reply mode resolver is unavailable");
|
||||
}
|
||||
|
||||
const cfg = { channels: { telegram } } as OpenClawConfig;
|
||||
expect(resolveReplyToMode({ cfg, accountId: "sut" })).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildTelegramThreadingToolContext", () => {
|
||||
it("keeps topic thread state in plugin-owned tool context", () => {
|
||||
const hasRepliedRef = { value: false };
|
||||
|
||||
Reference in New Issue
Block a user