From ffa0a4dd085e6b03159133cb14d991060a17da2e Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Mon, 10 Apr 2023 01:47:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20build:=20=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E5=8C=96=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index b49faed..075e349 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -22,10 +22,6 @@ import { av2BV } from "../utils/bilibili-bv-av-convert.js"; import querystring from "querystring"; export class tools extends plugin { - // 构造关键字,防止超出预期的问题 - static existsTransKey = Object.keys(transMap).join("|"); - static existsPromptKey = Object.keys(PROMPT_MAP).join("|").slice(0, -1); - constructor() { super({ name: "R插件工具和学习类", @@ -34,11 +30,11 @@ export class tools extends plugin { priority: 500, rule: [ { - reg: `^(翻|trans)[${tools.existsTransKey}]`, + reg: `^(翻|trans)[${tools.Constants.existsTransKey}]`, fnc: "trans", }, { - reg: `^#(ocr|OCR)(${tools.existsPromptKey})?$`, + reg: `^#(ocr|OCR)(${tools.Constants.existsPromptKey})?$`, fnc: "ocr2anything", }, { @@ -1201,4 +1197,13 @@ export class tools extends plugin { logger.error("下载视频发生错误!"); } } + + /** + * 构造安全的命令 + * @type {{existsPromptKey: string, existsTransKey: string}} + */ + static Constants = { + existsTransKey: Object.keys(transMap).join("|"), + existsPromptKey: Object.keys(PROMPT_MAP).join("|").slice(0, -1), + }; }