修复 带Bot名字时 星铁命令 无法识别 (#144)

This commit is contained in:
时雨◎星空 2023-05-30 03:47:45 +08:00 committed by GitHub
parent b561ab4b3b
commit be70d6ac2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

View File

@ -30,6 +30,9 @@ class PluginsLoader {
/** 插件监听 */ /** 插件监听 */
this.watcher = {} this.watcher = {}
/** 星铁命令前缀 */
this.srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
} }
/** /**
@ -213,6 +216,13 @@ class PluginsLoader {
/** 是否只关注主动at */ /** 是否只关注主动at */
if (!this.onlyReplyAt(e)) return 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 */ /** accept */
for (let plugin of priority) { for (let plugin of priority) {
/** accept hook */ /** accept hook */
@ -354,17 +364,7 @@ class PluginsLoader {
for (let val of e.message) { for (let val of e.message) {
switch (val.type) { switch (val.type) {
case 'text': case 'text':
let msg = (val.text || '').replace(/^\s*[#井#]+\s*/, '#').replace(/^\s*[\\*※]+\s*/, '*').trim() e.msg = (e.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
break break
case 'image': case 'image':
if (!e.img) { if (!e.img) {