From 925a42e2c453c9b2f1c5227f929b2cd0e18b5e15 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 7 Dec 2023 15:30:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=20nohup=20=E7=AD=89?= =?UTF-8?q?=E6=97=A0=E6=A0=87=E5=87=86=E8=BE=93=E5=87=BA=E6=B5=81=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 19 ++++++++++++++----- requirements.txt | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 98857914b..1e31eb816 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -439,14 +439,23 @@ def initBot(cfg, prov): # thread_inst.join() asyncio.get_event_loop().run_until_complete(cli()) + thread_inst.join() + async def cli(): + show_hint = False time.sleep(1) while True: - prompt = input(">>> ") - if prompt == "": - continue - ngm = await cli_pack_message(prompt) - await oper_msg(ngm, True, PLATFORM_CLI) + try: + prompt = input(">>> ") + if prompt == "": + continue + ngm = await cli_pack_message(prompt) + await oper_msg(ngm, True, PLATFORM_CLI) + except EOFError: + if not show_hint: + show_hint = True + gu.log("您当前所使用的环境不支持 CLI 模式,您将无法在命令行控制台中使用本程序。不影响您在 QQ 上的使用。") + return async def cli_pack_message(prompt: str) -> NakuruGuildMessage: ngm = NakuruGuildMessage() diff --git a/requirements.txt b/requirements.txt index e02ef3ece..1ba3529bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,6 @@ beautifulsoup4 googlesearch-python tiktoken readability-lxml -EdgeGPT revChatGPT~=6.8.6 -baidu-aip~=4.16.9 \ No newline at end of file +baidu-aip~=4.16.9 +websockets \ No newline at end of file