refactor: 指令注册架构

This commit is contained in:
Rock Chin
2023-03-28 03:12:19 +00:00
parent b799de7995
commit e228225178
6 changed files with 81 additions and 24 deletions

13
main.py
View File

@@ -7,6 +7,7 @@ import time
import logging
import sys
import traceback
try:
import colorlog
@@ -191,8 +192,14 @@ def start(first_time_init=False):
import pkg.openai.session
import pkg.qqbot.manager
import pkg.openai.dprompt
import pkg.qqbot.cmds.mgr
pkg.openai.dprompt.register_all()
try:
pkg.openai.dprompt.register_all()
pkg.qqbot.cmds.mgr.register_all()
except Exception as e:
logging.error(e)
traceback.print_exc()
# 配置openai api_base
if "reverse_proxy" in config.openai_config and config.openai_config["reverse_proxy"] is not None:
@@ -271,10 +278,6 @@ def start(first_time_init=False):
threading.Thread(
target=run_bot_wrapper
).start()
# 机器人暂时不能放在线程池中
# pkg.utils.context.get_thread_ctl().submit_sys_task(
# run_bot_wrapper
# )
finally:
# 判断若是Windows输出选择模式可能会暂停程序的警告
if os.name == 'nt':