From eedcb9b82536bd975c9415310b75b1320d1d99c3 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Tue, 7 Mar 2023 08:15:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E8=B6=85=E9=99=90=E5=90=8E=E9=87=8D=E6=96=B0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=8F=91=E9=80=81QQ=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index c39cb3d0..842fc1d0 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -522,7 +522,7 @@ def oper_msg(message, at=False, msg_ref = None): chatgpt_res = "[Error] 占位符" - send_qq_msg(message, f"正在思考!\n(此机器人供测试,稳定性无法保证。加入[GPT机器人]了解更多)", msg_ref=msg_ref) + send_qq_msg(message, f"正在思考!\n(此机器人供测试,稳定性无法保证。加入[GPT机器人]了解更多)") if provider == OPENAI_OFFICIAL: @@ -562,11 +562,12 @@ def oper_msg(message, at=False, msg_ref = None): chatgpt_res, current_usage_tokens = get_chatGPT_response(context=cache_data_list, request=record_obj) elif 'exceeded' in str(e): send_qq_msg(message, f"OpenAI API错误。原因:\n{str(e)} \n超额了。可自己搭建一个机器人(Github仓库:QQChannelChatGPT)") + return else: f_res = re.sub(r'(https|http)?:\/\/(\w|\.|\/|\?|\=|\&|\%)*\b', '[被隐藏的链接]', str(e), flags=re.MULTILINE) f_res = f_res.replace(".", "·") send_qq_msg(message, f"OpenAI API错误。原因如下:\n{f_res} \n前往官方频道反馈~") - return + return # 超过指定tokens, 尽可能的保留最多的条目,直到小于max_tokens if current_usage_tokens > max_tokens: @@ -634,8 +635,6 @@ def oper_msg(message, at=False, msg_ref = None): try: # 防止被qq频道过滤消息 gap_chatgpt_res = chatgpt_res.replace(".", " . ") - if '```' in gap_chatgpt_res: - chatgpt_res.replace('```', "") # 过滤不合适的词 for i in uw.unfit_words: if i in gap_chatgpt_res: