diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index b5f3f10..1211685 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -14,8 +14,8 @@ import Runtime from "./runtime.js" global.plugin = plugin function toSegment(type, data) { - for (const i in data) { - if (data[i]) { + for (const i in data) + if (data[i]) switch (typeof data[i]) { case "string": if ((i == "file" || data[i].match(/^file:\/\//)) && fs.existsSync(data[i].replace(/^file:\/\//, ""))) @@ -25,8 +25,6 @@ function toSegment(type, data) { if (Buffer.isBuffer(data[i])) data[i] = `base64://${data[i].toString("base64")}` } - } - } return { type, ...data } } diff --git a/plugins/system/add.js b/plugins/system/add.js index 375284e..cc67a05 100644 --- a/plugins/system/add.js +++ b/plugins/system/add.js @@ -191,7 +191,6 @@ export class add extends plugin { this.e.isGlobal = this.e.msg.includes("全局"); this.keyWord = this.e.raw_message.trim() - /** 过滤#添加 */ .replace(/^#?(全局)?(添加|删除)(图片|表情)?/, '') .trim() @@ -520,9 +519,14 @@ export class add extends plugin { this.initTextArr() - let keyWord = this.e.toString().replace(/#|#|图片|表情|删除|全部|全局/g, '') + this.getKeyWord() - keyWord = this.trimAlias(keyWord) + if (!this.keyWord) { + this.e.reply('删除错误:没有关键词') + return + } + + let keyWord = this.trimAlias(this.keyWord) let num = false let index = 0 @@ -577,7 +581,7 @@ export class add extends plugin { let retMsg = [{ type: 'text', text: '删除成功:' }] for (let msg of this.e.message) { if (msg.type == 'text') { - msg.text = msg.text.replace(/#|#|图片|表情|删除|全部|全局/g, '') + msg.text = msg.text.replace(/^#?(全局)?(添加|删除)(图片|表情)?/, '') if (!msg.text) continue }