From 0a1df90a83b7b58b368db4834f96cb3f957dabe1 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Wed, 5 Apr 2023 20:26:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=90=8E=E8=AE=BE=E7=BD=AE=E7=9A=84=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E6=A8=A1=E5=9E=8B=E9=80=89=E6=8B=A9=E5=81=8F=E5=A5=BD?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=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 | 14 ++++++++++++++ model/command/command.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 4a4c0c6e5..ba537453a 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -192,6 +192,13 @@ def initBot(cfg, prov): command_openai_official = CommandOpenAIOfficial(chatgpt) chosen_provider = OPENAI_OFFICIAL + # 检查provider设置偏好 + if os.path.exists("provider_preference.txt"): + with open("provider_preference.txt", 'r', encoding='utf-8') as f: + res = f.read() + if res in prov: + chosen_provider = res + # 百度内容审核 if 'baidu_aip' in cfg and 'enable' in cfg['baidu_aip'] and cfg['baidu_aip']['enable']: @@ -330,6 +337,10 @@ def check_frequency(id) -> bool: user_frequency[id] = t return True + +def save_provider_preference(chosen_provider): + with open('provider_preference.txt', 'w') as f: + f.write(chosen_provider) ''' 处理消息 ''' @@ -387,14 +398,17 @@ def oper_msg(message, at=False, msg_ref = None): # 检查是否是更换语言模型的请求 if qq_msg.startswith('/bing'): chosen_provider = REV_EDGEGPT + save_provider_preference(chosen_provider) send_qq_msg(message, f"已切换至【{chosen_provider}】", msg_ref=msg_ref) return elif qq_msg.startswith('/gpt'): chosen_provider = OPENAI_OFFICIAL + save_provider_preference(chosen_provider) send_qq_msg(message, f"已切换至【{chosen_provider}】", msg_ref=msg_ref) return elif qq_msg.startswith('/revgpt'): chosen_provider = REV_CHATGPT + save_provider_preference(chosen_provider) send_qq_msg(message, f"已切换至【{chosen_provider}】", msg_ref=msg_ref) return diff --git a/model/command/command.py b/model/command/command.py index 8dc92932c..d20594b63 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -39,7 +39,7 @@ class Command: # 得到最新的5条commit列表, 包含commit信息 origin = repo.remotes.origin origin.fetch() - commits = list(repo.iter_commits('master', max_count=5)) + commits = list(repo.iter_commits('master', max_count=3)) commits_log = '' index = 1 for commit in commits: