2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

fix:修正默认文件没有时设置报错

This commit is contained in:
Ctrlcvs 2022-10-31 14:29:07 +08:00
parent e2af245be6
commit 7b557f1ce4

View File

@ -21,13 +21,7 @@ export default class note {
this.cfg = gsCfg.getfileYaml(`./plugins/xiaoyao-cvs-plugin/config/`, "config"); this.cfg = gsCfg.getfileYaml(`./plugins/xiaoyao-cvs-plugin/config/`, "config");
} }
addNote() { addNote() {
if (!this.noteCfg[this.e.group_id]) { this.isGroup()
this.noteCfg[this.e.group_id] = {
"task": [],
"isTask": true,
"sendResin": 120
}
}
if (!this.isTaskAdmin()) return true; if (!this.isTaskAdmin()) return true;
let userId = this.noteCfg[this.e.group_id]["task"] || []; let userId = this.noteCfg[this.e.group_id]["task"] || [];
if (!userId.includes(this.e.user_id)) { if (!userId.includes(this.e.user_id)) {
@ -38,14 +32,6 @@ export default class note {
this.e.reply("体力推送开启成功~\n后续每天会为您推送体力") this.e.reply("体力推送开启成功~\n后续每天会为您推送体力")
} }
delNote() { delNote() {
if (!this.noteCfg[this.e.group_id]) { //首次直接设置
this.noteCfg[this.e.group_id] = {
"task": [],
"isTask": true,
"sendResin": 120
}
this.saveNote(this.noteCfg)
}
try { try {
if (this.noteCfg[this.e.group_id]) { if (this.noteCfg[this.e.group_id]) {
if (!this.isTaskAdmin()) return true; if (!this.isTaskAdmin()) return true;
@ -61,6 +47,7 @@ export default class note {
} catch (e) {} } catch (e) {}
} }
updNote() { updNote() {
this.isGroup()
if (this.cfg.noteSetAuth === 2) { if (this.cfg.noteSetAuth === 2) {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.e.reply('只有主人才能操作。') this.e.reply('只有主人才能操作。')
@ -90,10 +77,20 @@ export default class note {
fs.writeFileSync(`${this.Cfg}note.yaml`, yaml, 'utf8') fs.writeFileSync(`${this.Cfg}note.yaml`, yaml, 'utf8')
} }
isTaskAdmin() { isTaskAdmin() {
this.isGroup()
if (!this.noteCfg[this.e.group_id]["isTask"]) { if (!this.noteCfg[this.e.group_id]["isTask"]) {
this.e.reply("群体力推送关闭了~\n请联系管理员开启功能~") this.e.reply("群体力推送关闭了~\n请联系管理员开启功能~")
return false; return false;
} }
return true; return true;
} }
isGroup(){
if (!this.noteCfg[this.e.group_id]) { //首次直接设置
this.noteCfg[this.e.group_id] = {
"task": [],
"isTask": true,
"sendResin": 120
}
}
}
} }