From 55bfa8f669fd862308812ab1e7de33da0ac228e0 Mon Sep 17 00:00:00 2001 From: po-lan <42771836+po-lan@users.noreply.github.com> Date: Mon, 13 Jun 2022 15:24:28 +0800 Subject: [PATCH] Update __init__.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows 重启适配 --- plugins/check_zhenxun_update/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/check_zhenxun_update/__init__.py b/plugins/check_zhenxun_update/__init__.py index c58eba0e..7fa68f08 100755 --- a/plugins/check_zhenxun_update/__init__.py +++ b/plugins/check_zhenxun_update/__init__.py @@ -71,18 +71,18 @@ async def _(bot: Bot): ) -@restart.handle() -async def _(): - if str(platform.system()).lower() == "windows": - await restart.finish("暂无windows重启脚本...") - @restart.got("flag", prompt="确定是否重启真寻?确定请回复[是|好|确定](重启失败咱们将失去联系,请谨慎!)") async def _(flag: str = ArgStr("flag")): if flag.lower() in ["true", "是", "好", "确定", "确定是"]: await restart.send("开始重启真寻..请稍等...") open("is_restart", "w") - os.system("./restart.sh") + if str(platform.system()).lower() == "windows": + import sys + python = sys.executable + os.execl(python, python, *sys.argv) + else: + os.system("./restart.sh") else: await restart.send("已取消操作...")