perf: 重做help指令模块

This commit is contained in:
Soulter
2023-04-14 21:05:39 +08:00
parent c12a4f7353
commit 80975c5715
4 changed files with 42 additions and 5 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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"
return True, super().help_messager(super().general_commands()), "help"

View File

@@ -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"