From bd255c2bb4aa879652b78a768475d2617c930ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Sun, 28 May 2023 11:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=98=9F=E9=93=81?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=20=E6=97=A0=E6=B3=95=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/loader.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index 846a8d9..d316ff3 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -61,6 +61,9 @@ class PluginsLoader { /** 插件监听 */ this.watcher = {} + + /** 星铁命令前缀 */ + this.srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/ } /** @@ -241,6 +244,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 */ @@ -381,13 +391,7 @@ class PluginsLoader { for (let val of e.message) { switch (val.type) { case "text": - /** 中文#转为英文 */ - val.text = val.text.replace(/#|井/g, "#").trim() - if (e.msg) { - e.msg += val.text - } else { - e.msg = val.text - } + e.msg = (e.msg || "") + (val.text || "").replace(/^\s*[#井#]+\s*/, "#").replace(/^\s*[\\*※]+\s*/, "*").trim() break case "image": if (!e.img) {