|
1 | 1 | /** |
2 | 2 | * Media type detection — pure functions for classifying files by MIME or extension. |
3 | 3 | * |
4 | | - * These replace the inline `isImageFile`, `isVideoFile`, `isAudioFile` helpers |
5 | | - * scattered across `outbound.ts`. Centralizing them here ensures consistent |
6 | | - * detection across both the built-in and standalone versions. |
| 4 | + * These replace the inline `isImageFile` and `isVideoFile` helpers scattered |
| 5 | + * across `outbound.ts`. Centralizing them here keeps detection consistent. |
7 | 6 | */ |
8 | 7 | |
9 | | -/** Supported media kind for QQ Bot outbound routing. */ |
10 | | -export type MediaKind = "image" | "voice" | "video" | "file"; |
11 | | - |
12 | 8 | const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"]); |
13 | 9 | const VIDEO_EXTENSIONS = new Set([".mp4", ".mov", ".avi", ".mkv", ".webm", ".flv", ".wmv"]); |
14 | | -const AUDIO_EXTENSIONS = new Set([ |
15 | | -".mp3", |
16 | | -".wav", |
17 | | -".ogg", |
18 | | -".flac", |
19 | | -".aac", |
20 | | -".m4a", |
21 | | -".wma", |
22 | | -".opus", |
23 | | -".amr", |
24 | | -".silk", |
25 | | -".slk", |
26 | | -".pcm", |
27 | | -]); |
28 | 10 | |
29 | 11 | /** |
30 | 12 | * Extract a lowercase file extension from a path or URL, ignoring query and hash. |
@@ -53,18 +35,3 @@ export function isVideoFile(filePath: string, mimeType?: string): boolean {
|
53 | 35 | } |
54 | 36 | return VIDEO_EXTENSIONS.has(getCleanExtension(filePath)); |
55 | 37 | } |
56 | | - |
57 | | -/** Check whether a file is audio using MIME first and extension as fallback. */ |
58 | | -export function isAudioFile(filePath: string, mimeType?: string): boolean { |
59 | | -if (mimeType) { |
60 | | -if ( |
61 | | -mimeType.startsWith("audio/") || |
62 | | -mimeType === "voice" || |
63 | | -mimeType.includes("silk") || |
64 | | -mimeType.includes("amr") |
65 | | -) { |
66 | | -return true; |
67 | | -} |
68 | | -} |
69 | | -return AUDIO_EXTENSIONS.has(getCleanExtension(filePath)); |
70 | | -} |