(msg: Api.Message)
| 202 | })) as Buffer | undefined; |
| 203 | if (!buf) return null; |
| 204 | return buf; |
| 205 | } |
| 206 | |
| 207 | async 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 | } |
no test coverage detected