(buffer: Buffer | undefined, kind: string | undefined)
| 635 | // If status is a primitive (bigint, number, string), treat it as the direct document ID |
| 636 | if (typeof status !== "object") { |
| 637 | const id = status?.value ?? status; |
| 638 | return id ? String(id) : undefined; |
| 639 | } |
| 640 | const documentId = status.documentId ?? status.document_id ?? status.customEmojiId ?? status.custom_emoji_id ?? status.id; |
| 641 | if (!documentId) return undefined; |
| 642 | return String(documentId); |
| 643 | } |
| 644 | |
| 645 | function messageDate(msg: Api.Message): number | undefined { |
| 646 | const date = (msg as any).date; |
| 647 | if (date instanceof Date) return Math.floor(date.getTime() / 1000); |
| 648 | if (typeof date === "number") return date; |
| 649 | return undefined; |
| 650 | } |
| 651 | |
| 652 | function getDocumentAttributes(msg: Api.Message): any[] { |
| 653 | const doc = (msg as any).document ?? (msg as any).media?.document; |
| 654 | return doc?.attributes || []; |
| 655 | } |
| 656 | |
| 657 | function audioAttribute(msg: Api.Message): any | undefined { |
| 658 | return getDocumentAttributes(msg).find((a: any) => (a.className || a.constructor?.name || "").includes("Audio")); |
| 659 | } |
| 660 | |
| 661 | function voiceWaveform(msg: Api.Message): number[] | undefined { |
| 662 | const attr = audioAttribute(msg); |
no test coverage detected