2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2025-01-22 22:05:12 +08:00

支持手动指令刷新地图资源数据避免下载的本地文件不是最新,例:#更新落落莓在哪里

This commit is contained in:
ctrlcvs 2023-01-18 22:18:37 +08:00
parent fdddbe9c39
commit b4e01e0f35
2 changed files with 36 additions and 10 deletions

View File

@ -8,7 +8,8 @@ import {
help help
} from "./help.js"; } from "./help.js";
import { import {
genShenMap rule as mapRule,
genShenMap,delMapData
} from './map.js' } from './map.js'
import { import {
Note, Note,
@ -49,7 +50,7 @@ import {
} from './mhyTopUpLogin.js' } from './mhyTopUpLogin.js'
export { export {
updateRes, updateTemp, updateRes, updateTemp,
delSign, gcPaylog, delSign, gcPaylog,delMapData,
cloudSign,qrCodeLogin, cloudSign,qrCodeLogin,
seach, bindLogin_ticket,payOrder, seach, bindLogin_ticket,payOrder,
bbsSign,UserPassMsg,UserPassLogin, bbsSign,UserPassMsg,UserPassLogin,
@ -102,10 +103,7 @@ let rule = {
reg: "^#(体力模板(设置(.*)|列表(.*))|(我的体力模板列表|体力模板移除(.*)))$", reg: "^#(体力模板(设置(.*)|列表(.*))|(我的体力模板列表|体力模板移除(.*)))$",
describe: "体力模板设置", describe: "体力模板设置",
}, },
genShenMap: {
reg: "^#(.*)(在(哪|那)里*)$",
describe: "地图资源查询 #**在哪里",
},
pokeNote: { pokeNote: {
reg: "#poke#", reg: "#poke#",
describe: "体力", describe: "体力",
@ -117,7 +115,8 @@ let rule = {
...userRule, ...userRule,
...signRule, ...signRule,
...adminRule, ...adminRule,
...topupLoginRule ...topupLoginRule,
...mapRule
}; };
lodash.forEach(rule, (r) => { lodash.forEach(rule, (r) => {

View File

@ -14,11 +14,38 @@ let getPath={
"&map_id=7":["渊下宫",'渊下'], "&map_id=7":["渊下宫",'渊下'],
"&map_id=9":['璃月地下','层岩地下','层岩'] "&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){ export async function genShenMap(e){
let msg= e.msg.replace(/#|(哪|那)|里|在/g,"") let isBool=/刷新|更新/.test(e.msg)
var urlFile = fs.readdirSync(`./data/map/`); let msg= e.msg.replace(/#|(哪|那)|里|在|刷新|更新/g,"")
let urlFile = fs.readdirSync(path);
let msgPath=`${path}/${msg}.jpg` let msgPath=`${path}/${msg}.jpg`
if(urlFile.includes(`${msg}.jpg`)){ if(urlFile.includes(`${msg}.jpg`)&&!isBool){
await e.reply(segment.image(`file://${msgPath}`)) await e.reply(segment.image(`file://${msgPath}`))
return true; return true;
} }