From 2e9229a6ad35afd094f1d97d462277b5c1ad0206 Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Sat, 30 Mar 2024 21:34:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E5=9C=A8=20main.py=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.py b/main.py index d60b34d..055a530 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ # QChatGPT 终端启动入口 # 在此层级解决依赖项检查。 +# QChatGPT/main.py asciiart = r""" ___ ___ _ _ ___ ___ _____ @@ -62,6 +63,21 @@ if __name__ == '__main__': input("按任意键退出...") exit(0) + # 检查本目录是否有main.py,且包含QChatGPT字符串 + invalid_pwd = False + + if not os.path.exists('main.py'): + invalid_pwd = True + else: + with open('main.py', 'r', encoding='utf-8') as f: + content = f.read() + if "QChatGPT/main.py" not in content: + invalid_pwd = True + if invalid_pwd: + print("请在QChatGPT项目根目录下运行此程序。") + input("按任意键退出...") + exit(0) + import asyncio asyncio.run(main_entry())