From ebd9e99f8d4ef8484af081d56e94182a1dca156c Mon Sep 17 00:00:00 2001 From: shenjack-5600u <3695888@qq.com> Date: Sun, 5 May 2024 22:21:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E4=BA=86=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/plugins/namerena.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ica-rs/plugins/namerena.py b/ica-rs/plugins/namerena.py index 7f6943d..5a7a8a5 100644 --- a/ica-rs/plugins/namerena.py +++ b/ica-rs/plugins/namerena.py @@ -2,6 +2,8 @@ import time import traceback import subprocess +from pathlib import Path + from typing import TYPE_CHECKING, TypeVar if TYPE_CHECKING: @@ -27,10 +29,12 @@ def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None: # 开始 try try: # 内容写入到 ./md5/input.txt - with open("./md5/input.txt", "w") as f: + # 路径是插件文件的相对路径 + root_path = Path(__file__).parent + with open(root_path / "md5" / "input.txt", "w") as f: f.write(names) # 执行 node md5.js - result = subprocess.run(["node", "md5/md5.js"], stdout=subprocess.PIPE) + result = subprocess.run(["node", (root_path / "md5" / "md5.js").absolute()], stdout=subprocess.PIPE) # 获取结果 result = result.stdout.decode("utf-8") # 发送结果