diff --git a/main.py b/main.py index 8252213a8..8d474a21a 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,7 @@ def privider_chooser(cfg): l.append('openai_official') return l -def check_env(): +def check_env(ch_mirror=False): if not (sys.version_info.major == 3 and sys.version_info.minor >= 8): print("请使用Python3.8运行本项目") input("按任意键退出...") @@ -60,7 +60,11 @@ def check_env(): pth = 'QQChannelChatGPT'+ os.sep +'requirements.txt' print("正在检查更新第三方库...") try: - pipmain(['install', '-r', pth, '--quiet']) + if ch_mirror: + print("使用阿里云镜像") + pipmain(['install', '-r', pth, '-i', 'https://mirrors.aliyun.com/pypi/simple/', '--quiet']) + else: + pipmain(['install', '-r', pth, '--quiet']) except BaseException as e: print(e) while True: @@ -96,17 +100,20 @@ def get_platform(): print("other") if __name__ == "__main__": - check_env() - # 获取参数 args = sys.argv - if len(args) > 1: - if args[1] == '-replit': - print("[System] 启动Replit Web保活服务...") - try: - from webapp_replit import keep_alive - keep_alive() - except BaseException as e: - print(e) - print(f"[System-err] Replit Web保活服务启动失败:{str(e)}") + + if '-cn' in args: + check_env(True) + else: + check_env() + + if '-replit' in args: + print("[System] 启动Replit Web保活服务...") + try: + from webapp_replit import keep_alive + keep_alive() + except BaseException as e: + print(e) + print(f"[System-err] Replit Web保活服务启动失败:{str(e)}") main()