From 7b557f1ce431d3f41f1b02a845eac4e3d32ccd0f Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Mon, 31 Oct 2022 14:29:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=AD=A3=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E6=97=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/note.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/model/note.js b/model/note.js index 7213daa..fc874c0 100644 --- a/model/note.js +++ b/model/note.js @@ -21,13 +21,7 @@ export default class note { this.cfg = gsCfg.getfileYaml(`./plugins/xiaoyao-cvs-plugin/config/`, "config"); } addNote() { - if (!this.noteCfg[this.e.group_id]) { - this.noteCfg[this.e.group_id] = { - "task": [], - "isTask": true, - "sendResin": 120 - } - } + this.isGroup() if (!this.isTaskAdmin()) return true; let userId = this.noteCfg[this.e.group_id]["task"] || []; if (!userId.includes(this.e.user_id)) { @@ -38,14 +32,6 @@ export default class note { this.e.reply("体力推送开启成功~\n后续每天会为您推送体力") } delNote() { - if (!this.noteCfg[this.e.group_id]) { //首次直接设置 - this.noteCfg[this.e.group_id] = { - "task": [], - "isTask": true, - "sendResin": 120 - } - this.saveNote(this.noteCfg) - } try { if (this.noteCfg[this.e.group_id]) { if (!this.isTaskAdmin()) return true; @@ -61,6 +47,7 @@ export default class note { } catch (e) {} } updNote() { + this.isGroup() if (this.cfg.noteSetAuth === 2) { if (!this.e.isMaster) { this.e.reply('只有主人才能操作。') @@ -90,10 +77,20 @@ export default class note { fs.writeFileSync(`${this.Cfg}note.yaml`, yaml, 'utf8') } isTaskAdmin() { + this.isGroup() if (!this.noteCfg[this.e.group_id]["isTask"]) { this.e.reply("群体力推送关闭了~\n请联系管理员开启功能~") return false; } return true; } + isGroup(){ + if (!this.noteCfg[this.e.group_id]) { //首次直接设置 + this.noteCfg[this.e.group_id] = { + "task": [], + "isTask": true, + "sendResin": 120 + } + } + } }