diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index e92168d..b420898 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -213,8 +213,12 @@ class PluginsLoader { ...plugin.getContext(false, true), } if (!lodash.isEmpty(context)) { - for (const fnc in context) - plugin[fnc](context[fnc]) + let ret + for (const fnc in context) { + ret ||= await plugin[fnc](context[fnc]) + } + // 返回continue时,继续响应后续插件 + if (ret === 'continue') continue return } } @@ -250,8 +254,7 @@ class PluginsLoader { if (plugin.rule) for (const v of plugin.rule) { /** 判断事件 */ if (v.event && !this.filtEvent(e, v)) continue - /** 加入多行匹配符号 */ - if (!new RegExp(v.reg, 'sg').test(e.msg)) continue + if (!new RegExp.test(e.msg)) continue e.logFnc = `[${plugin.name}][${v.fnc}]` if (v.log !== false) diff --git a/lib/plugins/plugin.js b/lib/plugins/plugin.js index 79e978c..16bcfe6 100644 --- a/lib/plugins/plugin.js +++ b/lib/plugins/plugin.js @@ -83,15 +83,16 @@ export default class plugin { * @param type 执行方法 * @param isGroup 是否群聊 * @param time 操作时间,默认120秒 + * @param {boolean} [silent=false] 是否静默,超时不回复消息 */ - setContext(type, isGroup, time = 120) { + setContext(type, isGroup, time = 120, silent = false) { const key = this.conKey(isGroup) if (!stateArr[key]) stateArr[key] = {} stateArr[key][type] = this.e if (time) stateArr[key][type].timeout = setTimeout(() => { if (stateArr[key][type]) { delete stateArr[key][type] - this.reply("操作超时已取消", true) + silent || this.reply("操作超时已取消", true) } }, time * 1000) }