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

Function downloadMedia

eat/eat.ts:204–220  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

202 })) as Buffer | undefined;
203 if (!buf) return null;
204 return buf;
205}
206
207async function downloadMedia(msg: Api.Message): Promise<Buffer | null> {
208 const replied = await safeGetReplyMessage(msg);
209 if (!replied) {
210 await msg.edit({ text: "请回复一条图片消息" });
211 return null;
212 }
213 if (!replied.media) {
214 await msg.edit({ text: "请回复一条图片消息" });
215 return null;
216 }
217 const mimeType = (replied.media as any).document?.mimeType;
218 const buf = (await msg.client?.downloadMedia(replied, {
219 thumb: ["video/webm"].includes(mimeType) ? 0 : 1,
220 })) as Buffer | undefined;
221 if (!buf) return null;
222 return buf;
223}

Callers 1

downloadAvatarFunction · 0.85

Calls 2

editMethod · 0.45
downloadMediaMethod · 0.45

Tested by

no test coverage detected