修复 星铁命令 无法识别

This commit is contained in:
🌌 2023-05-28 11:14:36 +08:00
parent 705ea92c47
commit bd255c2bb4
1 changed files with 11 additions and 7 deletions

View File

@ -61,6 +61,9 @@ class PluginsLoader {
/** 插件监听 */ /** 插件监听 */
this.watcher = {} this.watcher = {}
/** 星铁命令前缀 */
this.srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
} }
/** /**
@ -241,6 +244,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 */
@ -381,13 +391,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":
/** 中文#转为英文 */ e.msg = (e.msg || "") + (val.text || "").replace(/^\s*[#井#]+\s*/, "#").replace(/^\s*[\\*※]+\s*/, "*").trim()
val.text = val.text.replace(/|井/g, "#").trim()
if (e.msg) {
e.msg += val.text
} else {
e.msg = val.text
}
break break
case "image": case "image":
if (!e.img) { if (!e.img) {