From 5f024e9f3094bee1e48385cb697bf3c979003778 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Tue, 6 Jun 2023 12:28:55 +0000 Subject: [PATCH] fix: bugfixes --- model/command/command.py | 11 ++++++----- model/command/command_openai_official.py | 8 ++++---- model/command/command_rev_chatgpt.py | 7 ++++--- model/command/command_rev_edgegpt.py | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/model/command/command.py b/model/command/command.py index b155e8927..c8d5c4d56 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -300,7 +300,7 @@ class Command: "plugin": "插件安装、卸载和重载" } - def help_messager(self, commands: dict, platform: str): + def help_messager(self, commands: dict, platform: str, cached_plugins: dict = None): try: resp = requests.get("https://soulter.top/channelbot/notice.json").text notice = json.loads(resp)["notice"] @@ -311,10 +311,11 @@ class Command: for key, value in commands.items(): msg += key + ": " + value + "\n" # plugins - plugin_list_info = "\n".join([f"{k}: \n名称: {v['info']['name']}\n简介: {v['info']['desc']}\n" for k, v in cached_plugins.items()]) - if plugin_list_info.strip() != "": - msg += "\n【插件列表】\n" - msg += plugin_list_info + if cached_plugins != None: + plugin_list_info = "\n".join([f"{k}: \n名称: {v['info']['name']}\n简介: {v['info']['desc']}\n" for k, v in cached_plugins.items()]) + if plugin_list_info.strip() != "": + msg += "\n【插件列表】\n" + msg += plugin_list_info msg += notice if platform == gu.PLATFORM_GOCQ: diff --git a/model/command/command_openai_official.py b/model/command/command_openai_official.py index cf55395e9..21e3e07f8 100644 --- a/model/command/command_openai_official.py +++ b/model/command/command_openai_official.py @@ -36,7 +36,7 @@ class CommandOpenAIOfficial(Command): elif self.command_start_with(message, "count"): return True, self.count() elif self.command_start_with(message, "help", "帮助"): - return True, self.help() + return True, self.help(cached_plugins) elif self.command_start_with(message, "unset"): return True, self.unset(session_id) elif self.command_start_with(message, "set"): @@ -55,7 +55,7 @@ class CommandOpenAIOfficial(Command): return False, None - def help(self): + def help(self, cached_plugins): commands = super().general_commands() commands['画'] = '画画' commands['key'] = '添加OpenAI key' @@ -63,9 +63,9 @@ class CommandOpenAIOfficial(Command): commands['gpt'] = '查看gpt配置信息' commands['status'] = '查看key使用状态' commands['token'] = '查看本轮会话token' - return True, super().help_messager(commands, self.platform), "help" + return True, super().help_messager(commands, self.platform, cached_plugins), "help" - + def reset(self, session_id: str): if self.provider is None: return False, "未启动OpenAI ChatGPT语言模型.", "reset" diff --git a/model/command/command_rev_chatgpt.py b/model/command/command_rev_chatgpt.py index 0af07eccd..655ac2aa7 100644 --- a/model/command/command_rev_chatgpt.py +++ b/model/command/command_rev_chatgpt.py @@ -19,7 +19,7 @@ class CommandRevChatGPT(Command): if hit: return True, res if self.command_start_with(message, "help", "帮助"): - return True, self.help() + return True, self.help(cached_plugins) elif self.command_start_with(message, "reset"): return True, self.reset() elif self.command_start_with(message, "update"): @@ -34,5 +34,6 @@ class CommandRevChatGPT(Command): def reset(self): return False, "此功能暂未开放", "reset" - def help(self): - return True, super().help_messager(super().general_commands(), self.platform), "help" + + def help(self, cached_plugins: dict): + return True, super().help_messager(super().general_commands(), self.platform, cached_plugins), "help" diff --git a/model/command/command_rev_edgegpt.py b/model/command/command_rev_edgegpt.py index c18c9a579..466e799b9 100644 --- a/model/command/command_rev_edgegpt.py +++ b/model/command/command_rev_edgegpt.py @@ -24,7 +24,7 @@ class CommandRevEdgeGPT(Command): if self.command_start_with(message, "reset"): return True, self.reset(loop) elif self.command_start_with(message, "help"): - return True, self.help() + return True, self.help(cached_plugins) elif self.command_start_with(message, "update"): return True, self.update(message, role) elif self.command_start_with(message, "keyword"): @@ -44,6 +44,6 @@ class CommandRevEdgeGPT(Command): else: return res, "重置失败", "reset" - def help(self): - return True, super().help_messager(super().general_commands(), self.platform), "help" + def help(self, cached_plugins: dict): + return True, super().help_messager(super().general_commands(), self.platform, cached_plugins), "help"