| 12 | } |
| 13 | |
| 14 | class MoyuPlugin extends Plugin { |
| 15 | |
| 16 | description: string = "摸鱼日报"; |
| 17 | cmdHandlers: Record<string, (msg: Api.Message) => Promise<void>> = { |
| 18 | moyu: async (msg) => { |
| 19 | try { |
| 20 | await msg.edit({ text: "开摸..." }); |
| 21 | const caption = `摸鱼日报 ${formatCN(new Date())}`; |
| 22 | |
| 23 | const res = await axios.get(url, { |
| 24 | responseType: "arraybuffer", |
| 25 | validateStatus: () => true, |
| 26 | }); |
| 27 | |
| 28 | const buf = Buffer.from(res.data); |
| 29 | const file = new CustomFile(`moyu.jpg`, buf.length, "", buf); |
| 30 | |
| 31 | await msg.client?.sendFile(msg.peerId, { |
| 32 | file, |
| 33 | caption, |
| 34 | forceDocument: false, |
| 35 | }); |
| 36 | await msg.delete(); |
| 37 | } catch (error) { |
| 38 | console.error("[MoyuPlugin] 执行失败:", error); |
| 39 | try { |
| 40 | await msg.edit({ text: "❌ 获取摸鱼日报失败,请稍后重试" }); |
| 41 | } catch (_) { |