From 696a0c57ee9f568b4a3c3069fdcefc0956731252 Mon Sep 17 00:00:00 2001 From: Rock Chin Date: Fri, 9 Dec 2022 00:16:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4main.py=E7=9A=84?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 950e735..ec20c06 100644 --- a/main.py +++ b/main.py @@ -4,11 +4,6 @@ import sys import threading import time -import pkg.openai.manager -import pkg.database.manager -import pkg.openai.session -import pkg.qqbot.manager - import logging import colorlog @@ -29,11 +24,6 @@ def init_db(): def main(): - # 检查是否有config.py,如果没有就把config-template.py复制一份,并退出程序 - if not os.path.exists('config.py'): - shutil.copy('config-template.py', 'config.py') - print('请先在config.py中填写配置') - return # 导入config.py assert os.path.exists('config.py') import config @@ -55,7 +45,6 @@ def main(): )) logging.getLogger().addHandler(sh) - # 主启动流程 openai_interact = pkg.openai.manager.OpenAIInteract(config.openai_config['api_key'], config.completion_api_params) @@ -73,9 +62,20 @@ def main(): if __name__ == '__main__': + # 检查是否有config.py,如果没有就把config-template.py复制一份,并退出程序 + if not os.path.exists('config.py'): + shutil.copy('config-template.py', 'config.py') + print('请先在config.py中填写配置') + if len(sys.argv) > 1 and sys.argv[1] == 'init_db': init_db() sys.exit(0) + + import pkg.openai.manager + import pkg.database.manager + import pkg.openai.session + import pkg.qqbot.manager + main() logging.info('程序启动完成')