修复 带Bot名字时 星铁命令 无法识别 (#144)
This commit is contained in:
parent
b561ab4b3b
commit
be70d6ac2f
|
@ -30,6 +30,9 @@ class PluginsLoader {
|
|||
|
||||
/** 插件监听 */
|
||||
this.watcher = {}
|
||||
|
||||
/** 星铁命令前缀 */
|
||||
this.srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,6 +216,13 @@ class PluginsLoader {
|
|||
/** 是否只关注主动at */
|
||||
if (!this.onlyReplyAt(e)) return
|
||||
|
||||
// 判断是否是星铁命令,若是星铁命令则标准化处理
|
||||
// e.isSr = true,且命令标准化为 #星铁 开头
|
||||
if (this.srReg.test(e.msg) || /\/common\//.test(e.msg)) {
|
||||
e.isSr = true
|
||||
e.msg = e.msg.replace(this.srReg, "#星铁")
|
||||
}
|
||||
|
||||
/** accept */
|
||||
for (let plugin of priority) {
|
||||
/** accept hook */
|
||||
|
@ -354,17 +364,7 @@ class PluginsLoader {
|
|||
for (let val of e.message) {
|
||||
switch (val.type) {
|
||||
case 'text':
|
||||
let msg = (val.text || '').replace(/^\s*[#井#]+\s*/, '#').replace(/^\s*[\\*※]+\s*/, '*').trim()
|
||||
|
||||
// 判断是否是星铁命令,若是星铁命令则标准化处理
|
||||
// e.isSr = true,且命令标准化为 #星铁 开头
|
||||
let srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
|
||||
let gclink = /\/common\//.test(msg)
|
||||
if (srReg.test(msg) || gclink) {
|
||||
e.isSr = true
|
||||
msg = msg.replace(srReg, '#星铁')
|
||||
}
|
||||
e.msg = (e.msg || '') + msg
|
||||
e.msg = (e.msg || "") + (val.text || "").replace(/^\s*[#井#]+\s*/, "#").replace(/^\s*[\\*※]+\s*/, "*").trim()
|
||||
break
|
||||
case 'image':
|
||||
if (!e.img) {
|
||||
|
|
Loading…
Reference in New Issue