From 527ed2361291c05b76973b301d07209d58d82dcd Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Mon, 6 Mar 2023 23:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=B0=8F=E7=BA=A2=E4=B9=A6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 41 +++++++++++++++++++++++------------------ model/index.js | 1 + 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 6de5f88..92c5caf 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -507,27 +507,26 @@ export class tools extends plugin { timeout: 10000, proxy: false, }) - .then(resp => { + .then(async resp => { const reg = / { + const addr = `https:${item.split('"')[3]}`; + return axios.get(addr, { + headers: { + "User-Agent": + "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36", + }, + responseType: "stream", + }) .then(resp => { - const filepath = `${ downloadPath }/${ /com\/(.*)\?/.exec(addr)[1] }.jpg`; + const filepath = `${downloadPath}/${/com\/(.*)\?/.exec(addr)[1]}.jpg`; const writer = fs.createWriteStream(filepath); resp.data.pipe(writer); return new Promise((resolve, reject) => { @@ -535,11 +534,17 @@ export class tools extends plugin { writer.on("error", reject); }); }) - .then(filepath => { - e.reply(segment.image(fs.readFileSync(filepath))); - fs.unlinkSync(filepath); - }); - } + }) + const images = await Promise.all(imagesPath).then(paths => { + return paths.map(item => { + return { + message: segment.image(fs.readFileSync(item)), + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + } + }) + }) + await this.reply(await Bot.makeForwardMsg(images)); }); return true; diff --git a/model/index.js b/model/index.js index 6f35a0d..43feff4 100644 --- a/model/index.js +++ b/model/index.js @@ -60,6 +60,7 @@ class RConfig { const watcher = chokidar.watch(file) watcher.on('change', (path) => { + delete logger.mark(`[修改配置文件][${name}]`) }) }