(msg: Api.Message, args: QuoteArgs)
| 659 | } |
| 660 | |
| 661 | function voiceWaveform(msg: Api.Message): number[] | undefined { |
| 662 | const attr = audioAttribute(msg); |
| 663 | const raw = attr?.waveform; |
| 664 | if (!raw) return undefined; |
| 665 | let arr: number[]; |
| 666 | if (Array.isArray(raw)) arr = raw.map((x: any) => Number(x) || 0); |
| 667 | else if (Buffer.isBuffer(raw) || raw instanceof Uint8Array) arr = Array.from(raw as Uint8Array).map((x) => Number(x) || 0); |
| 668 | else return undefined; |
| 669 | if (!arr.length) return undefined; |
| 670 | return arr.map((x) => Math.max(0, Math.min(31, x))); |
| 671 | } |
| 672 | |
| 673 | function getMediaKind(msg: Api.Message): string | undefined { |
| 674 | const media: any = (msg as any).media; |
| 675 | if (!media) return undefined; |
| 676 | const cls = media.className || media.constructor?.name || ""; |
| 677 | const attrs = getDocumentAttributes(msg); |
| 678 | if (attrs.some((a: any) => (a.className || "").includes("Sticker"))) return "sticker"; |
| 679 | if (attrs.some((a: any) => (a.className || "").includes("Animated")) || cls.includes("Dice")) return "animation"; |
no test coverage detected