From ee33abc554cd6655dc320c194f435aaf79a8454f Mon Sep 17 00:00:00 2001 From: Kokomi <1379177109@qq.com> Date: Wed, 25 Oct 2023 03:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=B9e.game=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/loader.js | 24 +++++++++++++++++++----- lib/plugins/runtime.js | 3 +-- lib/tools/log.js | 3 +-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index 9d5448f..e97484e 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -181,12 +181,13 @@ class PluginsLoader { }) /** 检查频道消息 */ if (this.checkGuildMsg(e)) return - /** 检查黑白名单 */ - if (!this.checkBlack(e)) return + /** 冷却 */ if (!this.checkLimit(e)) return /** 处理消息 */ this.dealMsg(e) + /** 检查黑白名单 */ + if (!this.checkBlack(e)) return /** 处理回复 */ this.reply(e) /** 过滤事件 */ @@ -233,8 +234,16 @@ class PluginsLoader { // 判断是否是星铁命令,若是星铁命令则标准化处理 // e.isSr = true,且命令标准化为 #星铁 开头 + Object.defineProperty(e, 'isSr', { + get: () => e.game === 'sr', + set: (v) => e.game = v ? 'sr' : 'gs' + }) + Object.defineProperty(e, 'isGs', { + get: () => e.game === 'gs', + set: (v) => e.game = v ? 'gs' : 'sr' + }) if (this.srReg.test(e.msg)) { - e.isSr = true + e.game = 'sr' e.msg = e.msg.replace(this.srReg, '#星铁') } @@ -717,8 +726,13 @@ class PluginsLoader { if (e.test) return true /** 黑名单qq */ - if (other.blackQQ && other.blackQQ.includes(Number(e.user_id) || e.user_id)) { - return false + if (other.blackQQ) { + if (other.blackQQ.includes(Number(e.user_id) || e.user_id)) { + return false + } + if (e.at && other.blackQQ.includes(Number(e.at) || e.at)) { + return false + } } if (e.group_id) { diff --git a/lib/plugins/runtime.js b/lib/plugins/runtime.js index a1f90c8..0cba154 100644 --- a/lib/plugins/runtime.js +++ b/lib/plugins/runtime.js @@ -77,7 +77,6 @@ export default class Runtime { await MysInfo.initCache() let runtime = new Runtime(e) e.runtime = runtime - e.game = e.isSr ? 'sr' : 'gs' await runtime.initUser() return runtime } @@ -88,7 +87,7 @@ export default class Runtime { if (user) { e.user = new Proxy(user, { get (self, key, receiver) { - let game = e.isSr ? 'sr' : 'gs' + let game = e.game let fnMap = { uid: 'getUid', uidList: 'getUidList', diff --git a/lib/tools/log.js b/lib/tools/log.js index d4ff2f2..33799aa 100644 --- a/lib/tools/log.js +++ b/lib/tools/log.js @@ -13,7 +13,6 @@ fs.readFile(`${_path}/config/pm2/pm2.json`, `utf8`, (err, data) => { const config = JSON.parse(data) if (config.apps && config.apps.length > 0 && config.apps[0].name) { const appName = config.apps[0].name - console.log(config.apps[0].name) runPm2Logs(appName) } else { console.log('读取失败:无法在pm2.json中找到name数组') @@ -32,4 +31,4 @@ function runPm2Logs(appName) { console.error(`pm2 logs process exited with code ${code}`) } }) -} \ No newline at end of file +}