fix(telegram): guard voice note sends

This commit is contained in:
Jarvis
2026-01-08 13:55:36 +00:00
committed by Peter Steinberger
parent 2f036f7173
commit ce786762db
4 changed files with 75 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ import { resolveTelegramAccount } from "./accounts.js";
import { createTelegramDraftStream } from "./draft-stream.js";
import { resolveTelegramFetch } from "./fetch.js";
import { markdownToTelegramHtml } from "./format.js";
import { isTelegramVoiceCompatible } from "./voice.js";
import {
readTelegramAllowFromStore,
upsertTelegramPairingRequest,
@@ -1387,7 +1388,19 @@ async function deliverReplies(params: {
...mediaParams,
});
} else if (kind === "audio") {
const useVoice = reply.audioAsVoice === true; // default false (backward compatible)
const wantsVoice = reply.audioAsVoice === true; // default false (backward compatible)
const canVoice = wantsVoice
? isTelegramVoiceCompatible({
contentType: media.contentType,
fileName,
})
: false;
const useVoice = wantsVoice && canVoice;
if (wantsVoice && !canVoice) {
logVerbose(
`Telegram voice requested but media is ${media.contentType ?? "unknown"} (${fileName}); sending as audio file instead.`,
);
}
if (useVoice) {
// Voice message - displays as round playable bubble (opt-in via [[audio_as_voice]])
await bot.api.sendVoice(chatId, file, {