fix(telegram): guard voice note sends
This commit is contained in:
committed by
Peter Steinberger
parent
2f036f7173
commit
ce786762db
15
src/telegram/voice.ts
Normal file
15
src/telegram/voice.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import path from "node:path";
|
||||
|
||||
export function isTelegramVoiceCompatible(opts: {
|
||||
contentType?: string | null;
|
||||
fileName?: string | null;
|
||||
}): boolean {
|
||||
const mime = opts.contentType?.toLowerCase();
|
||||
if (mime && (mime.includes("ogg") || mime.includes("opus"))) {
|
||||
return true;
|
||||
}
|
||||
const fileName = opts.fileName?.trim();
|
||||
if (!fileName) return false;
|
||||
const ext = path.extname(fileName).toLowerCase();
|
||||
return ext === ".ogg" || ext === ".opus" || ext === ".oga";
|
||||
}
|
||||
Reference in New Issue
Block a user