feat(telegram): add disableAudioPreflight config for groups and topics

This commit is contained in:
gemini-3-flash
2026-02-22 07:26:58 +08:00
committed by Peter Steinberger
parent d89c25d69e
commit d3cb85eaf5
3 changed files with 62 additions and 1 deletions

View File

@@ -41,4 +41,53 @@ describe("buildTelegramMessageContext audio transcript body", () => {
expect(ctx?.ctxPayload?.Body).toContain("hey bot please help");
expect(ctx?.ctxPayload?.Body).not.toContain("<media:audio>");
});
it("skips preflight transcription when disableAudioPreflight is true", async () => {
transcribeFirstAudioMock.mockClear();
const ctx = await buildTelegramMessageContext({
primaryCtx: {
message: {
message_id: 2,
chat: { id: -1001234567891, type: "supergroup", title: "Test Group 2" },
date: 1700000100,
from: { id: 43, first_name: "Bob" },
voice: { file_id: "voice-2" },
},
me: { id: 7, username: "bot" },
} as never,
allMedia: [{ path: "/tmp/voice2.ogg", contentType: "audio/ogg" }],
storeAllowFrom: [],
options: { forceWasMentioned: true },
bot: {
api: {
sendChatAction: vi.fn(),
setMessageReaction: vi.fn(),
},
} as never,
cfg: {
agents: { defaults: { model: "anthropic/claude-opus-4-5", workspace: "/tmp/openclaw" } },
channels: { telegram: {} },
messages: { groupChat: { mentionPatterns: ["\\bbot\\b"] } },
} as never,
account: { accountId: "default" } as never,
historyLimit: 0,
groupHistories: new Map(),
dmPolicy: "open",
allowFrom: [],
groupAllowFrom: [],
ackReactionScope: "off",
logger: { info: vi.fn() },
resolveGroupActivation: () => true,
resolveGroupRequireMention: () => true,
resolveTelegramGroupConfig: () => ({
groupConfig: { requireMention: true, disableAudioPreflight: true },
topicConfig: undefined,
}),
});
expect(ctx).not.toBeNull();
expect(transcribeFirstAudioMock).not.toHaveBeenCalled();
expect(ctx?.ctxPayload?.Body).toContain("<media:audio>");
});
});