MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / mediaBufferToCanvas

Function mediaBufferToCanvas

quote/quote.ts:637–659  ·  view source on GitHub ↗
(buffer: Buffer | undefined, kind: string | undefined)

Source from the content-addressed store, hash-verified

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
645function 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
652function getDocumentAttributes(msg: Api.Message): any[] {
653 const doc = (msg as any).document ?? (msg as any).media?.document;
654 return doc?.attributes || [];
655}
656
657function audioAttribute(msg: Api.Message): any | undefined {
658 return getDocumentAttributes(msg).find((a: any) => (a.className || a.constructor?.name || "").includes("Audio"));
659}
660
661function voiceWaveform(msg: Api.Message): number[] | undefined {
662 const attr = audioAttribute(msg);

Callers 1

prepareQuoteMediaFunction · 0.85

Calls 5

looksLikeAnimatedEmojiFunction · 0.85
getSharpFunction · 0.85
getCanvasFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected