refactor(telegram): centralize voice decisions

- Share voice compatibility decision logic across send + bot flows
- Keep voice fallback logging consistent
- Simplify voice handling in the audio send path
This commit is contained in:
Jarvis
2026-01-08 14:00:55 +00:00
committed by Peter Steinberger
parent ce786762db
commit 9a7f050568
2 changed files with 23 additions and 11 deletions

View File

@@ -13,3 +13,18 @@ export function isTelegramVoiceCompatible(opts: {
const ext = path.extname(fileName).toLowerCase();
return ext === ".ogg" || ext === ".opus" || ext === ".oga";
}
export function resolveTelegramVoiceDecision(opts: {
wantsVoice: boolean;
contentType?: string | null;
fileName?: string | null;
}): { useVoice: boolean; reason?: string } {
if (!opts.wantsVoice) return { useVoice: false };
if (isTelegramVoiceCompatible(opts)) return { useVoice: true };
const contentType = opts.contentType ?? "unknown";
const fileName = opts.fileName ?? "unknown";
return {
useVoice: false,
reason: `media is ${contentType} (${fileName})`,
};
}