更新对e.game的处理逻辑

This commit is contained in:
Kokomi 2023-10-25 03:34:37 +08:00
parent b4f9b54dbd
commit ee33abc554
3 changed files with 21 additions and 9 deletions

View File

@ -181,12 +181,13 @@ class PluginsLoader {
}) })
/** 检查频道消息 */ /** 检查频道消息 */
if (this.checkGuildMsg(e)) return if (this.checkGuildMsg(e)) return
/** 检查黑白名单 */
if (!this.checkBlack(e)) return
/** 冷却 */ /** 冷却 */
if (!this.checkLimit(e)) return if (!this.checkLimit(e)) return
/** 处理消息 */ /** 处理消息 */
this.dealMsg(e) this.dealMsg(e)
/** 检查黑白名单 */
if (!this.checkBlack(e)) return
/** 处理回复 */ /** 处理回复 */
this.reply(e) this.reply(e)
/** 过滤事件 */ /** 过滤事件 */
@ -233,8 +234,16 @@ class PluginsLoader {
// 判断是否是星铁命令,若是星铁命令则标准化处理 // 判断是否是星铁命令,若是星铁命令则标准化处理
// e.isSr = true且命令标准化为 #星铁 开头 // 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)) { if (this.srReg.test(e.msg)) {
e.isSr = true e.game = 'sr'
e.msg = e.msg.replace(this.srReg, '#星铁') e.msg = e.msg.replace(this.srReg, '#星铁')
} }
@ -717,9 +726,14 @@ class PluginsLoader {
if (e.test) return true if (e.test) return true
/** 黑名单qq */ /** 黑名单qq */
if (other.blackQQ && other.blackQQ.includes(Number(e.user_id) || e.user_id)) { if (other.blackQQ) {
if (other.blackQQ.includes(Number(e.user_id) || e.user_id)) {
return false return false
} }
if (e.at && other.blackQQ.includes(Number(e.at) || e.at)) {
return false
}
}
if (e.group_id) { if (e.group_id) {
/** 白名单群 */ /** 白名单群 */

View File

@ -77,7 +77,6 @@ export default class Runtime {
await MysInfo.initCache() await MysInfo.initCache()
let runtime = new Runtime(e) let runtime = new Runtime(e)
e.runtime = runtime e.runtime = runtime
e.game = e.isSr ? 'sr' : 'gs'
await runtime.initUser() await runtime.initUser()
return runtime return runtime
} }
@ -88,7 +87,7 @@ export default class Runtime {
if (user) { if (user) {
e.user = new Proxy(user, { e.user = new Proxy(user, {
get (self, key, receiver) { get (self, key, receiver) {
let game = e.isSr ? 'sr' : 'gs' let game = e.game
let fnMap = { let fnMap = {
uid: 'getUid', uid: 'getUid',
uidList: 'getUidList', uidList: 'getUidList',

View File

@ -13,7 +13,6 @@ fs.readFile(`${_path}/config/pm2/pm2.json`, `utf8`, (err, data) => {
const config = JSON.parse(data) const config = JSON.parse(data)
if (config.apps && config.apps.length > 0 && config.apps[0].name) { if (config.apps && config.apps.length > 0 && config.apps[0].name) {
const appName = config.apps[0].name const appName = config.apps[0].name
console.log(config.apps[0].name)
runPm2Logs(appName) runPm2Logs(appName)
} else { } else {
console.log('读取失败无法在pm2.json中找到name数组') console.log('读取失败无法在pm2.json中找到name数组')