fix(telegram): guard voice note sends
This commit is contained in:
committed by
Peter Steinberger
parent
2f036f7173
commit
ce786762db
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user