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

Function prepareQuoteMedia

quote/quote.ts:661–676  ·  view source on GitHub ↗
(msg: Api.Message, args: QuoteArgs)

Source from the content-addressed store, hash-verified

659}
660
661function 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
673function 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";

Callers 2

replyPreviewFunction · 0.85
toQuoteMessageFunction · 0.85

Calls 4

getMediaKindFunction · 0.85
voiceWaveformFunction · 0.85
downloadMessageMediaFunction · 0.85
mediaBufferToCanvasFunction · 0.85

Tested by

no test coverage detected