2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

补充移除模板指令

This commit is contained in:
Ctrlcvs 2022-10-31 22:56:22 +08:00
parent b1708eb522
commit 7ee8fe567b
3 changed files with 22 additions and 10 deletions

View File

@ -3,7 +3,7 @@
* 用户可通过`#开启、关闭体力推送` 来对体力推送进行操作
* 管理员可通过`#体力设置群推送关闭、开启` 以及推送阈值设置`#体力设置群阈值120` 仅支持群操作
* 新增`#我的体力模板列表`
* 优化体力模板设置,支持多个设置
* 优化体力模板设置,支持多个设置、移除
* 新增`#图鉴模板更新`
* 用于更新体力模板具体来源由**@SunRyK** **@地球生物** **@逍遥** 三位作者上传
* 不会冲突已添加的模板数据,有需求可通过指令拉取

View File

@ -232,9 +232,13 @@ export async function Note(e, {
objFile = objFile[lodash.random(0, objFile.length - 1)]
}
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
if (tempData[e.user_id] && tempData[e.user_id].type > -1) {
if (tempData[e.user_id] && tempData[e.user_id].type > -1&&tempData[e.user_id]?.temp?.length!==0) {
// mb = tempData[e.user_id].type;
objFile = tempData[e.user_id].temp[lodash.random(0, tempData[e.user_id].temp.length - 1)];
if (typeof tempData[e.user_id]["temp"] === "string") {
objFile = tempData[e.user_id]["temp"]
} else {
objFile = tempData[e.user_id].temp[lodash.random(0, tempData[e.user_id].temp.length - 1)];
}
if (objFile.includes(".")) { //对于模板类型处理
mb = 0;
} else {
@ -400,8 +404,8 @@ export async function pokeNote(e, {
export async function Note_appoint(e) {
let mbPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/`;
let msg = e.msg.replace(/#|井|体力|模板|设置/g, "");
let isDel= e.msg.includes("移除")
let msg = e.msg.replace(/#|井|体力|模板|设置|移除/g, "");
let All = ["默认", "随机", "0"];
let urlType = note_file();
let keyType = Object.keys(urlType);
@ -416,7 +420,7 @@ export async function Note_appoint(e) {
if (msg.includes("列表")) {
let isUser = msg.includes('我的')
let temp = tempData[e.user_id]?.temp;
if (!temp && isUser) {
if ((!temp||temp?.length===0) && isUser) {
e.reply("未获取到您设置的模板信息哦~")
return true;
}
@ -430,7 +434,7 @@ export async function Note_appoint(e) {
for (let [index, item] of keyType.entries()) {
let msg_pass = [];
let imgurl;
let pathFile=urlType[item].replace(/\./,_path)
let pathFile = urlType[item].replace(/\./, _path)
if (item.includes(".")) {
imgurl = await segment.image(`file:///${pathFile}`);
item = item.split(".")[0];
@ -490,8 +494,16 @@ export async function Note_appoint(e) {
if (typeof tempData[e.user_id]["temp"] === "string") {
temp = [tempData[e.user_id]["temp"], msg]
} else {
temp =tempData[e.user_id]["temp"]
if (!tempData[e.user_id]["temp"]?.includes(msg)) {
temp = [...tempData[e.user_id]["temp"], msg]
temp.push(msg)
}
}
let sendMsg="诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~"
if(isDel){
if(temp.includes(msg)){
temp.splice(temp.indexOf(msg),1)
sendMsg=`模板${msg}已移除~`
}
}
tempData[e.user_id] = {
@ -500,7 +512,7 @@ export async function Note_appoint(e) {
}
fs.writeFileSync(tempDataUrl + "/tempData.json", JSON.stringify(tempData));
init()
e.reply("诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~")
e.reply(sendMsg)
return true;
}

View File

@ -99,7 +99,7 @@ let rule = {
describe: "体力推送",
},
Note_appoint: {
reg: "^#体力模板(设置(.*)|列表(.*))|(#我的体力模板列表)$",
reg: "^#体力模板(设置(.*)|列表(.*))|(#我的体力模板列表|#体力模板移除(.*))$",
describe: "体力模板设置",
},
genShenMap: {