From b4e01e0f359f9b9ec3bcf3d4bc8f654f72aa46c1 Mon Sep 17 00:00:00 2001 From: ctrlcvs <1509167646@qq.com> Date: Wed, 18 Jan 2023 22:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=8B=E5=8A=A8=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=88=B7=E6=96=B0=E5=9C=B0=E5=9B=BE=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=81=BF=E5=85=8D=E4=B8=8B=E8=BD=BD=E7=9A=84?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6=E4=B8=8D=E6=98=AF=E6=9C=80?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E4=BE=8B=EF=BC=9A`#=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=90=BD=E8=90=BD=E8=8E=93=E5=9C=A8=E5=93=AA=E9=87=8C`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/index.js | 13 ++++++------- apps/map.js | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/apps/index.js b/apps/index.js index 22fffc0..d541d45 100644 --- a/apps/index.js +++ b/apps/index.js @@ -8,7 +8,8 @@ import { help } from "./help.js"; import { - genShenMap + rule as mapRule, + genShenMap,delMapData } from './map.js' import { Note, @@ -49,7 +50,7 @@ import { } from './mhyTopUpLogin.js' export { updateRes, updateTemp, - delSign, gcPaylog, + delSign, gcPaylog,delMapData, cloudSign,qrCodeLogin, seach, bindLogin_ticket,payOrder, bbsSign,UserPassMsg,UserPassLogin, @@ -102,10 +103,7 @@ let rule = { reg: "^#(体力模板(设置(.*)|列表(.*))|(我的体力模板列表|体力模板移除(.*)))$", describe: "体力模板设置", }, - genShenMap: { - reg: "^#(.*)(在(哪|那)里*)$", - describe: "地图资源查询 #**在哪里", - }, + pokeNote: { reg: "#poke#", describe: "体力", @@ -117,7 +115,8 @@ let rule = { ...userRule, ...signRule, ...adminRule, - ...topupLoginRule + ...topupLoginRule, + ...mapRule }; lodash.forEach(rule, (r) => { diff --git a/apps/map.js b/apps/map.js index 7feb426..7e3955a 100644 --- a/apps/map.js +++ b/apps/map.js @@ -14,11 +14,38 @@ let getPath={ "&map_id=7":["渊下宫",'渊下'], "&map_id=9":['璃月地下','层岩地下','层岩'] } +export const rule = { + genShenMap: { + reg: "^#(刷新|更新)?(.*)(在(哪|那)里*)$", + describe: "地图资源查询 #**在哪里", + }, + delMapData: { + reg: "^#(清空|清除)地图(缓存)?数据$", + describe: "清空地图下载数据", + }, +} + +export async function delMapData(e){ + let urlFile = fs.readdirSync(path); + let count=0; + for (const item of urlFile) { + try { + await fs.unlinkSync(`${path}/${item}`) + count++; + } catch (error) { + e.reply('清空地图数据异常~') + } + } + e.reply(`共清除${count}个地图数据~\n您后续可通过直接重新获取地图资源数据~`) + return true +} + export async function genShenMap(e){ - let msg= e.msg.replace(/#|(哪|那)|里|在/g,"") - var urlFile = fs.readdirSync(`./data/map/`); + let isBool=/刷新|更新/.test(e.msg) + let msg= e.msg.replace(/#|(哪|那)|里|在|刷新|更新/g,"") + let urlFile = fs.readdirSync(path); let msgPath=`${path}/${msg}.jpg` - if(urlFile.includes(`${msg}.jpg`)){ + if(urlFile.includes(`${msg}.jpg`)&&!isBool){ await e.reply(segment.image(`file://${msgPath}`)) return true; }