From fa23cd27f18089ee91504a19241b767ec7f1d6f6 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Sat, 11 Mar 2023 21:01:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E#?= =?UTF-8?q?=E6=B8=85=E7=90=86data=E5=9E=83=E5=9C=BE=EF=BC=8C=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E4=BA=91=E5=B4=BD=E4=BA=A7=E7=94=9F=E7=9A=84=E5=9E=83?= =?UTF-8?q?=E5=9C=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 02a66a5..426c613 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -29,15 +29,15 @@ export class tools extends plugin { fnc: "trans", }, { - reg: "(.*)(v.douyin.com)", + reg: "(v.douyin.com)", fnc: "douyin", }, { - reg: "(.*)(www.tiktok.com)|(vt.tiktok.com)|(vm.tiktok.com)", + reg: "(www.tiktok.com)|(vt.tiktok.com)|(vm.tiktok.com)", fnc: "tiktok", }, { - reg: "(.*)(bilibili.com|b23.tv|t.bilibili.com)", + reg: "(bilibili.com|b23.tv|t.bilibili.com)", fnc: "bili", }, { @@ -53,7 +53,7 @@ export class tools extends plugin { fnc: "tx", }, { - reg: "(.*)(acfun.cn)", + reg: "(acfun.cn)", fnc: "acfun", }, { @@ -61,9 +61,14 @@ export class tools extends plugin { fnc: "redbook", }, { - reg: "(.*)(doi.org)", + reg: "(doi.org)", fnc: "literature", }, + { + reg: "^#清理data垃圾$", + fnc: "clearTrash", + permission: "master", + } ], }); // http://api.tuwei.space/girl @@ -616,6 +621,25 @@ export class tools extends plugin { }); } + // 清理垃圾文件 + async clearTrash(e) { + const directory = './data/'; + try { + fs.readdir(directory, (err, files) => { + for (const file of files) { + // 如果文件名符合规则,执行删除操作 + if (/^[0-9a-f]{32}$/.test(file)) { + fs.unlinkSync(directory + file); + } + } + }); + await e.reply(`清理完成!`); + } catch (err) { + console.log(err); + e.reply("清理失败,重试或者自动清理即可") + } + } + /** * 哔哩哔哩下载 * @param title