From aa55f44ebfaed2c60367d08dfc21e9bdf9821f67 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 28 Aug 2024 01:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E4=B8=8B=20namerena?= =?UTF-8?q?=20=E5=92=8C=20=E5=8E=BB=E6=8E=89=20bmcl=20/bm93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bmcl.py | 4 ++-- plugins/namerena.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/bmcl.py b/plugins/bmcl.py index decc759..0c8ec0d 100644 --- a/plugins/bmcl.py +++ b/plugins/bmcl.py @@ -361,8 +361,8 @@ def on_tailchat_message(msg, client: TailchatClient) -> None: if len(name) > 1: name = name[1] bmcl_rank(msg, client, name) - elif msg.content == "/bm93": - bangbang_img(msg, client) + # elif msg.content == "/bm93": + # bangbang_img(msg, client) except: # noqa report_msg = f"bmcl插件发生错误,请呼叫shenjack\n{traceback.format_exc()}" client.warn(report_msg) diff --git a/plugins/namerena.py b/plugins/namerena.py index 8fae163..a520572 100644 --- a/plugins/namerena.py +++ b/plugins/namerena.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import sys import time @@ -31,7 +33,7 @@ else: TailchatReciveMessage = TypeVar("TailchatReciveMessage") -_version_ = "0.5.0" +_version_ = "0.6.0" EVAL_PREFIX = "/namerena" CONVERT_PREFIX = "/namer-peek" @@ -89,11 +91,11 @@ def eval_fight(msg: ReciveMessage, client) -> None: root_path = Path(__file__).parent with open(root_path / "md5" / "input.txt", "w") as f: f.write(names) - # 执行 node md5.js - runner_path = root_path / "md5" / "md5-api.js" - # input_path = root_path / "md5" / "input.txt" + # 执行 node md5-api.js / bun md5-api.ts + use_bun = CONFIG_DATA["use_bun"] + runner_path = root_path / "md5" / ("md5-api.ts" if use_bun else "md5-api.js") result = subprocess.run( - ["node", runner_path.absolute()], + ["bun", "run", runner_path.absolute()] if use_bun else ["node", runner_path.absolute()], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) @@ -127,3 +129,10 @@ def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None: def on_tailchat_message(msg: TailchatReciveMessage, client) -> None: dispatch_msg(msg, client) # type: ignore + + +def on_config() -> tuple[str, str]: + return ( + "namer.toml", + "use_bun = false # 是否使用 bun" + )