Skip to content

Commit

Permalink
🎨 3.6.5: Update init_bot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AirportR committed Dec 5, 2023
1 parent 17da2ae commit aedb14b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions botmodule/init_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@

from utils.clash import check_port, start_fulltclash
from utils.cleaner import ConfigManager
from utils.safe import gen_key

config = ConfigManager() # 配置加载
admin = config.getAdmin() # 管理员
config.add_user(admin) # 管理员同时也是用户
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用户名和密码可省略"
Expand Down Expand Up @@ -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:
Expand All @@ -124,8 +134,6 @@ def check_version() -> str:
return _latest_version_hash


check_args()
check_init()
# 获取远程仓库的最新提交哈希
latest_version_hash = check_version()

Expand All @@ -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]
Expand Down

0 comments on commit aedb14b

Please sign in to comment.