From aedb14b17dd6fd0d487ecf7c1ef15ee15b7e0009 Mon Sep 17 00:00:00 2001 From: AirportR Date: Tue, 5 Dec 2023 17:15:27 +0800 Subject: [PATCH] :art: 3.6.5: Update init_bot.py --- botmodule/init_bot.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/botmodule/init_bot.py b/botmodule/init_bot.py index 29d246db..ed850a7b 100644 --- a/botmodule/init_bot.py +++ b/botmodule/init_bot.py @@ -9,7 +9,6 @@ from utils.clash import check_port, start_fulltclash from utils.cleaner import ConfigManager -from utils.safe import gen_key config = ConfigManager() # 配置加载 admin = config.getAdmin() # 管理员 @@ -17,6 +16,16 @@ config.reload() +def check_permission(): + if sys.platform != "win32": + try: + status = os.system(f"chmod +x {clash_path}") + if status != 0: + raise OSError(f"Failed to execute command: chmod +x {clash_path}") + except OSError as o: + print(o) + + def check_args(): import argparse help_text_socks5 = "设置socks5代理,bot代理使用的这个\n格式--> host:端口:用户名:密码\t用户名和密码可省略" @@ -104,8 +113,9 @@ def check_init(): return if "fulltclash-private.pem" in dirs: return - logger.info("正在初始化公私钥") - gen_key() + # logger.info("正在初始化公私钥") + # gen_key() + check_permission() def check_version() -> str: @@ -124,8 +134,6 @@ def check_version() -> str: return _latest_version_hash -check_args() -check_init() # 获取远程仓库的最新提交哈希 latest_version_hash = check_version() @@ -145,6 +153,8 @@ def check_version() -> str: USERNAME = "@FullTclashBot" port = config.get_proxy_port() proxy_subprocess = None +check_args() +check_init() try: _proxy = config.get_bot_proxy(isjoint=False).split(':') proxy_host = _proxy[0]