修复 添加表情无法删除

This commit is contained in:
🌌 2023-05-15 10:18:19 +08:00
parent fdd2936cec
commit 7257bd9c24
2 changed files with 10 additions and 8 deletions

View File

@ -14,8 +14,8 @@ import Runtime from "./runtime.js"
global.plugin = plugin global.plugin = plugin
function toSegment(type, data) { function toSegment(type, data) {
for (const i in data) { for (const i in data)
if (data[i]) { if (data[i])
switch (typeof data[i]) { switch (typeof data[i]) {
case "string": case "string":
if ((i == "file" || data[i].match(/^file:\/\//)) && fs.existsSync(data[i].replace(/^file:\/\//, ""))) 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])) if (Buffer.isBuffer(data[i]))
data[i] = `base64://${data[i].toString("base64")}` data[i] = `base64://${data[i].toString("base64")}`
} }
}
}
return { type, ...data } return { type, ...data }
} }

View File

@ -191,7 +191,6 @@ export class add extends plugin {
this.e.isGlobal = this.e.msg.includes("全局"); this.e.isGlobal = this.e.msg.includes("全局");
this.keyWord = this.e.raw_message.trim() this.keyWord = this.e.raw_message.trim()
/** 过滤#添加 */
.replace(/^#?(全局)?(添加|删除)(图片|表情)?/, '') .replace(/^#?(全局)?(添加|删除)(图片|表情)?/, '')
.trim() .trim()
@ -520,9 +519,14 @@ export class add extends plugin {
this.initTextArr() 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 num = false
let index = 0 let index = 0
@ -577,7 +581,7 @@ export class add extends plugin {
let retMsg = [{ type: 'text', text: '删除成功:' }] let retMsg = [{ type: 'text', text: '删除成功:' }]
for (let msg of this.e.message) { for (let msg of this.e.message) {
if (msg.type == 'text') { if (msg.type == 'text') {
msg.text = msg.text.replace(/#||图片|表情|删除|全部|全局/g, '') msg.text = msg.text.replace(/^#?(全局)?(添加|删除)(图片|表情)?/, '')
if (!msg.text) continue if (!msg.text) continue
} }