From 2972fce02cd5c179d8b6eb29bd18911b027c6d46 Mon Sep 17 00:00:00 2001 From: Manuel Maly Date: Sun, 4 Jan 2026 22:16:39 +0100 Subject: [PATCH] fix: flip audio default to file (backward compat) - Default: sendAudio (file with metadata) - preserves old behavior - Opt-in: [[audio_as_voice]] tag for voice bubble This is non-breaking - existing integrations keep working. --- src/auto-reply/reply/audio-tags.ts | 17 +++++++++-------- src/telegram/bot.ts | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/auto-reply/reply/audio-tags.ts b/src/auto-reply/reply/audio-tags.ts index db9445d08..4ec9fc15c 100644 --- a/src/auto-reply/reply/audio-tags.ts +++ b/src/auto-reply/reply/audio-tags.ts @@ -1,22 +1,23 @@ /** * Extract audio mode tag from text. - * Supports [[audio_as_file]] to send audio as file instead of voice bubble. + * Supports [[audio_as_voice]] to send audio as voice bubble instead of file. + * Default is file (preserves backward compatibility). */ export function extractAudioTag(text?: string): { cleaned: string; audioAsVoice: boolean; hasTag: boolean; } { - if (!text) return { cleaned: "", audioAsVoice: true, hasTag: false }; + if (!text) return { cleaned: "", audioAsVoice: false, hasTag: false }; let cleaned = text; - let audioAsVoice = true; // default: voice bubble + let audioAsVoice = false; // default: audio file (backward compatible) let hasTag = false; - // [[audio_as_file]] -> send as file with metadata, not voice bubble - const fileMatch = cleaned.match(/\[\[audio_as_file\]\]/i); - if (fileMatch) { - cleaned = cleaned.replace(/\[\[audio_as_file\]\]/gi, " "); - audioAsVoice = false; + // [[audio_as_voice]] -> send as voice bubble (opt-in) + const voiceMatch = cleaned.match(/\[\[audio_as_voice\]\]/i); + if (voiceMatch) { + cleaned = cleaned.replace(/\[\[audio_as_voice\]\]/gi, " "); + audioAsVoice = true; hasTag = true; } diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index bacdabc98..d3de7c04c 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -1250,12 +1250,14 @@ async function deliverReplies(params: { ...mediaParams, }); } else if (kind === "audio") { - const useVoice = reply.audioAsVoice === true; // default false + const useVoice = reply.audioAsVoice === true; // default false (backward compatible) if (useVoice) { + // Voice message - displays as round playable bubble (opt-in via [[audio_as_voice]]) await bot.api.sendVoice(chatId, file, { ...mediaParams, }); } else { + // Audio file - displays with metadata (title, duration) - DEFAULT await bot.api.sendAudio(chatId, file, { ...mediaParams, });