



















@@ -1,14 +1,12 @@
11import { normalizeOptionalString } from "../shared/string-coerce.js";
22import { getFileExtension, normalizeMimeType } from "./mime.js";
334-export const TELEGRAM_VOICE_AUDIO_EXTENSIONS = new Set([".oga", ".ogg", ".opus", ".mp3", ".m4a"]);
4+export const VOICE_MESSAGE_AUDIO_EXTENSIONS = new Set([".oga", ".ogg", ".opus", ".mp3", ".m4a"]);
5566/**
77 * MIME types compatible with voice messages.
8- * Telegram sendVoice supports OGG/Opus, MP3, and M4A.
9- * https://core.telegram.org/bots/api#sendvoice
108 */
11-export const TELEGRAM_VOICE_MIME_TYPES = new Set([
9+export const VOICE_MESSAGE_MIME_TYPES = new Set([
1210"audio/ogg",
1311"audio/opus",
1412"audio/mpeg",
@@ -18,12 +16,12 @@ export const TELEGRAM_VOICE_MIME_TYPES = new Set([
1816"audio/m4a",
1917]);
201821-export function isTelegramVoiceCompatibleAudio(opts: {
19+export function isVoiceMessageCompatibleAudio(opts: {
2220contentType?: string | null;
2321fileName?: string | null;
2422}): boolean {
2523const mime = normalizeMimeType(opts.contentType);
26-if (mime && TELEGRAM_VOICE_MIME_TYPES.has(mime)) {
24+if (mime && VOICE_MESSAGE_MIME_TYPES.has(mime)) {
2725return true;
2826}
2927const fileName = normalizeOptionalString(opts.fileName);
@@ -34,16 +32,12 @@ export function isTelegramVoiceCompatibleAudio(opts: {
3432if (!ext) {
3533return false;
3634}
37-return TELEGRAM_VOICE_AUDIO_EXTENSIONS.has(ext);
35+return VOICE_MESSAGE_AUDIO_EXTENSIONS.has(ext);
3836}
393740-/**
41- * Backward-compatible alias used across plugin/runtime call sites.
42- * Keeps existing behavior while making Telegram-specific policy explicit.
43- */
4438export function isVoiceCompatibleAudio(opts: {
4539contentType?: string | null;
4640fileName?: string | null;
4741}): boolean {
48-return isTelegramVoiceCompatibleAudio(opts);
42+return isVoiceMessageCompatibleAudio(opts);
4943}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。