From 67faa587b60927effd316c30ad269e30e857b285 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 20 Sep 2023 10:31:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=9D=E6=AC=A1?= =?UTF-8?q?=E8=B0=83=E7=94=A8/keyword=E6=8C=87=E4=BB=A4=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=96=87=E4=BB=B6=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 14 +++++++++----- model/command/command.py | 2 +- model/provider/provider_openai_official.py | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index f80048351..68da366aa 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -674,11 +674,15 @@ def oper_msg(message, return command = command_result[2] if command == "keyword": - if not os.path.exists("keyword.json"): - send_message(platform, message, "出现异常,文件不存在。", msg_ref=msg_ref, session_id=session_id) - return - with open("keyword.json", "r", encoding="utf-8") as f: - keywords = json.load(f) + if os.path.exists("keyword.json"): + with open("keyword.json", "r", encoding="utf-8") as f: + keywords = json.load(f) + else: + try: + send_message(platform, message, command_result[1], msg_ref=msg_ref, session_id=session_id) + except BaseException as e: + send_message(platform, message, f"回复消息出错: {str(e)}", msg_ref=msg_ref, session_id=session_id) + # 昵称 if command == "nick": nick_qq = cc.get("nick_qq", nick_qq) diff --git a/model/command/command.py b/model/command/command.py index 483e7de5f..de5abd5d0 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -375,7 +375,7 @@ class Command: 3. keyword d hi 删除hi关键词的回复 4. keyword hi <图片> -当发送hi时会回复图片(切记加空格) +当发送hi时会回复图片 """, "keyword" del_mode = False diff --git a/model/provider/provider_openai_official.py b/model/provider/provider_openai_official.py index 699666020..6bc20f437 100644 --- a/model/provider/provider_openai_official.py +++ b/model/provider/provider_openai_official.py @@ -16,6 +16,7 @@ class ProviderOpenAIOfficial(Provider): self.key_list = [] if 'api_base' in cfg and cfg['api_base'] != 'none' and cfg['api_base'] != '': openai.api_base = cfg['api_base'] + print(f"设置apibase为:{openai.api_base}") if cfg['key'] != '' and cfg['key'] != None: self.key_list = cfg['key'] else: