From 80975c5715a1b25f7980092df6390c9b494cf027 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Fri, 14 Apr 2023 21:05:39 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=87=8D=E5=81=9Ahelp=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/command/command.py | 27 ++++++++++++++++++++++-- model/command/command_openai_official.py | 10 +++++++++ model/command/command_rev_chatgpt.py | 8 +++++-- model/command/command_rev_edgegpt.py | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/model/command/command.py b/model/command/command.py index 653f0c8f..e8315888 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -4,8 +4,9 @@ import git.exc from git.repo import Repo import os import sys - +import requests from model.provider.provider import Provider +import json class Command: def __init__(self, provider: Provider): @@ -17,6 +18,28 @@ class Command: return True, self.help() return False, None + def general_commands(self): + return { + "help": "帮助", + "keyword": "设置关键词/关键指令回复", + "update": "更新面板", + "update latest": "更新到最新版本", + "update r": "重启程序", + "reset": "重置会话" + } + + def help_messager(self, commands: dict): + try: + resp = requests.get("https://soulter.top/channelbot/notice.json").text + notice = json.loads(resp)["notice"] + except BaseException as e: + notice = "" + msg = "Github项目名QQChannelChatGPT, 有问题提交issue, 欢迎Star\n【指令列表】\n" + for key, value in commands.items(): + msg += key + ": " + value + "\n" + msg += notice + return msg + # 接受可变参数 def command_start_with(self, message: str, *args): for arg in args: @@ -116,7 +139,7 @@ class Command: return False def help(self): - return True, f"[Github项目名: QQChannelChatGPT,有问题请前往提交issue,欢迎Star此项目~]\n\n指令面板:\nstatus 查看机器人key状态\ncount 查看机器人统计信息\nreset 重置会话\nhis 查看历史记录\ntoken 查看会话token数\nhelp 查看帮助\nset 人格指令菜单\nkey 动态添加key", "help" + return False def status(self): return False diff --git a/model/command/command_openai_official.py b/model/command/command_openai_official.py index b17e3eac..7f24d577 100644 --- a/model/command/command_openai_official.py +++ b/model/command/command_openai_official.py @@ -35,6 +35,16 @@ class CommandOpenAIOfficial(Command): return True, self.key(message, user_name) return False, None + + def help(self): + commands = super().general_commands() + commands['画'] = '画画' + commands['key'] = '添加OpenAI key' + commands['set'] = '人格设置面板' + commands['gpt'] = '查看gpt配置信息' + commands['status'] = '查看key使用状态' + commands['token'] = '查看本轮会话token' + return True, super().help_messager(commands), "help" def reset(self, session_id: str): diff --git a/model/command/command_rev_chatgpt.py b/model/command/command_rev_chatgpt.py index cb2f61de..557abc65 100644 --- a/model/command/command_rev_chatgpt.py +++ b/model/command/command_rev_chatgpt.py @@ -8,12 +8,16 @@ class CommandRevChatGPT(Command): def check_command(self, message: str, role): if self.command_start_with(message, "help", "帮助"): return True, self.help() + elif self.command_start_with(message, "reset"): + return True, self.reset() elif self.command_start_with(message, "update"): return True, self.update(message, role) elif self.command_start_with(message, "keyword"): return True, self.keyword(message, role) return False, None + def reset(self): + return False, "此功能暂未开放", "reset" + def help(self): - return True, "[Github项目名: QQChannelChatGPT,有问题请前往提交issue,欢迎Star此项目~]\n\nRevChatGPT指令面板:\n当前语言模型RevChatGPT未实现任何指令\n", "help" - \ No newline at end of file + return True, super().help_messager(super().general_commands()), "help" diff --git a/model/command/command_rev_edgegpt.py b/model/command/command_rev_edgegpt.py index 06eabcd7..961323b9 100644 --- a/model/command/command_rev_edgegpt.py +++ b/model/command/command_rev_edgegpt.py @@ -25,5 +25,5 @@ class CommandRevEdgeGPT(Command): return res, "重置失败", "reset" def help(self): - return True, "[Github项目名: QQChannelChatGPT,有问题请前往提交issue,欢迎Star此项目~]\n\nRevBing指令面板:\nreset: 重置\nhelp: 帮助", "help" + return True, super().help_messager(super().general_commands()), "help"