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:
committed by
Peter Steinberger
parent
ce786762db
commit
9a7f050568
@@ -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})`,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user