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

Function customEmojiThumbs

quote/quote.ts:917–923  ·  view source on GitHub ↗
(doc: any)

Source from the content-addressed store, hash-verified

915
916async function downloadMediaToBuffer(client: any, target: any): Promise<Buffer | undefined> {
917 if (!client || !target) return undefined;
918 const mediaPath = path.join(os.tmpdir(), `telebox_quote_media_${Date.now()}_${Math.random().toString(16).slice(2)}`);
919 try {
920 const downloaded = await withTimeout(client.downloadMedia(target, { outputFile: mediaPath }), QUOTE_RPC_TIMEOUT_MS, "downloadMediaToBuffer.downloadMedia");
921 let buffer: Buffer | undefined;
922 if (Buffer.isBuffer(downloaded)) buffer = downloaded;
923 else if (downloaded && typeof downloaded === "string" && fs.existsSync(downloaded)) buffer = await waitForStableFile(downloaded);
924 if (!buffer || buffer.length === 0) buffer = await waitForStableFile(mediaPath);
925 return buffer && buffer.length > 0 ? buffer : undefined;
926 } catch (err: any) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected