From 46197d49a4e4a7320c3ab968fc4e6ab8126b5e2b Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Fri, 12 May 2023 09:08:06 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=B0=83=E6=8D=A2=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=90=AF=E5=8A=A8=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 12f377798..6d178aa75 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -307,20 +307,11 @@ def initBot(cfg, prov): print("--------------------加载平台--------------------") - # QQ频道 - if 'qqbot' in cfg and cfg['qqbot']['enable']: - print("- 启用QQ频道机器人 -") - global qqchannel_bot, qqchan_loop - qqchannel_bot = QQChan() - qqchan_loop = asyncio.new_event_loop() - thread_inst = threading.Thread(target=run_qqchan_bot, args=(cfg, qqchan_loop, qqchannel_bot), daemon=False) - thread_inst.start() - # thread.join() + # GOCQ if 'gocqbot' in cfg and cfg['gocqbot']['enable']: print("- 启用QQ机器人 -") - if os.path.exists("cmd_config.json"): with open("cmd_config.json", 'r', encoding='utf-8') as f: cmd_config = json.load(f) @@ -331,14 +322,22 @@ def initBot(cfg, prov): else: admin_qq = input("[System] 请输入管理者QQ号(管理者QQ号才能使用update/plugin等指令): ") print("[System] 管理者QQ号: " + admin_qq) - - global gocq_app, gocq_bot, gocq_loop gocq_bot = QQ() gocq_loop = asyncio.new_event_loop() thread_inst = threading.Thread(target=run_gocq_bot, args=(gocq_loop, gocq_bot, gocq_app), daemon=False) thread_inst.start() + # QQ频道 + if 'qqbot' in cfg and cfg['qqbot']['enable']: + print("- 启用QQ频道机器人 -") + global qqchannel_bot, qqchan_loop + qqchannel_bot = QQChan() + qqchan_loop = asyncio.new_event_loop() + thread_inst = threading.Thread(target=run_qqchan_bot, args=(cfg, qqchan_loop, qqchannel_bot), daemon=False) + thread_inst.start() + # thread.join() + if thread_inst == None: input("[System-Error] 没有启用任何机器人,程序退出") exit()