mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-19 21:38:18 +08:00
Merge Pull Request #686 into master
This commit is contained in:
@@ -10,7 +10,7 @@ from common.log import logger
|
||||
from .WordsSearch import WordsSearch
|
||||
|
||||
|
||||
@plugins.register(name="Banwords", desc="判断消息中是否有敏感词、决定是否回复。", version="1.0", author="lanvent", desire_priority= 100)
|
||||
@plugins.register(name="Banwords", desire_priority=100, hidden=True, desc="判断消息中是否有敏感词、决定是否回复。", version="1.0", author="lanvent")
|
||||
class Banwords(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -16,7 +16,7 @@ from uuid import getnode as get_mac
|
||||
"""
|
||||
|
||||
|
||||
@plugins.register(name="BDunit", desc="Baidu unit bot system", version="0.1", author="jackson", desire_priority=0)
|
||||
@plugins.register(name="BDunit", desire_priority=0, hidden=True, desc="Baidu unit bot system", version="0.1", author="jackson")
|
||||
class BDunit(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -27,15 +27,15 @@ class StoryTeller():
|
||||
if user_action[-1] != "。":
|
||||
user_action = user_action + "。"
|
||||
if self.first_interact:
|
||||
prompt = """现在来充当一个冒险文字游戏,描述时候注意节奏,不要太快,仔细描述各个人物的心情和周边环境。一次只需写四到六句话。
|
||||
prompt = """现在来充当一个文字冒险游戏,描述时候注意节奏,不要太快,仔细描述各个人物的心情和周边环境。一次只需写四到六句话。
|
||||
开头是,""" + self.story + " " + user_action
|
||||
self.first_interact = False
|
||||
else:
|
||||
prompt = """继续,一次只需要续写四到六句话,总共就只讲5分钟内发生的事情。""" + user_action
|
||||
return prompt
|
||||
|
||||
|
||||
@plugins.register(name="Dungeon", desc="A plugin to play dungeon game", version="1.0", author="lanvent", desire_priority= 0)
|
||||
|
||||
@plugins.register(name="Dungeon", desire_priority=0, namecn="文字冒险", desc="A plugin to play dungeon game", version="1.0", author="lanvent")
|
||||
class Dungeon(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -82,5 +82,10 @@ class Dungeon(Plugin):
|
||||
e_context['context'].content = prompt
|
||||
e_context.action = EventAction.BREAK # 事件结束,不跳过处理context的默认逻辑
|
||||
def get_help_text(self, **kwargs):
|
||||
help_text = "输入\"$开始冒险 {背景故事}\"来以{背景故事}开始一个地牢游戏,之后你的所有消息会帮助我来完善这个故事。输入\"$停止冒险 \"可以结束游戏。"
|
||||
help_text = "可以和机器人一起玩文字冒险游戏。\n"
|
||||
if kwargs.get('verbose') != True:
|
||||
return help_text
|
||||
help_text = "$开始冒险 {背景故事}: 开始一个基于{背景故事}的文字冒险,之后你的所有消息会协助完善这个故事。\n$停止冒险: 结束游戏。\n"
|
||||
if kwargs.get('verbose') == True:
|
||||
help_text += "\n命令例子: '$开始冒险 你在树林里冒险,指不定会从哪里蹦出来一些奇怪的东西,你握紧手上的手枪,希望这次冒险能够找到一些值钱的东西,你往树林深处走去。'"
|
||||
return help_text
|
||||
32
plugins/finish/finish.py
Normal file
32
plugins/finish/finish.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# encoding:utf-8
|
||||
|
||||
from bridge.context import ContextType
|
||||
from bridge.reply import Reply, ReplyType
|
||||
import plugins
|
||||
from plugins import *
|
||||
from common.log import logger
|
||||
|
||||
|
||||
@plugins.register(name="Finish", desire_priority=-999, hidden=True, desc="A plugin that check unknown command", version="1.0", author="js00000")
|
||||
class Finish(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
|
||||
logger.info("[Finish] inited")
|
||||
|
||||
def on_handle_context(self, e_context: EventContext):
|
||||
|
||||
if e_context['context'].type != ContextType.TEXT:
|
||||
return
|
||||
|
||||
content = e_context['context'].content
|
||||
logger.debug("[Finish] on_handle_context. content: %s" % content)
|
||||
if content.startswith("$"):
|
||||
reply = Reply()
|
||||
reply.type = ReplyType.ERROR
|
||||
reply.content = "未知插件命令\n查看插件命令列表请输入#help {插件名}\n"
|
||||
e_context['reply'] = reply
|
||||
e_context.action = EventAction.BREAK_PASS # 事件结束,并跳过处理context的默认逻辑
|
||||
|
||||
def get_help_text(self, **kwargs):
|
||||
return ""
|
||||
@@ -12,23 +12,31 @@ import plugins
|
||||
from plugins import *
|
||||
from common import const
|
||||
from common.log import logger
|
||||
|
||||
# 定义指令集
|
||||
COMMANDS = {
|
||||
"help": {
|
||||
"alias": ["help", "帮助"],
|
||||
"desc": "打印指令集合",
|
||||
"desc": "回复此帮助",
|
||||
},
|
||||
"helpp": {
|
||||
"alias": ["helpp", "插件帮助"],
|
||||
"alias": ["help", "帮助"], # 与help指令共用别名,根据参数数量区分
|
||||
"args": ["插件名"],
|
||||
"desc": "打印插件的帮助信息",
|
||||
"desc": "回复指定插件的详细帮助",
|
||||
},
|
||||
"auth": {
|
||||
"alias": ["auth", "认证"],
|
||||
"args": ["口令"],
|
||||
"desc": "管理员认证",
|
||||
},
|
||||
"set_openai_api_key": {
|
||||
"alias": ["set_openai_api_key"],
|
||||
"args": ["api_key"],
|
||||
"desc": "设置你的OpenAI私有api_key",
|
||||
},
|
||||
"reset_openai_api_key": {
|
||||
"alias": ["reset_openai_api_key"],
|
||||
"desc": "重置为默认的api_key",
|
||||
},
|
||||
# "id": {
|
||||
# "alias": ["id", "用户"],
|
||||
# "desc": "获取用户id", #目前无实际意义
|
||||
@@ -91,26 +99,35 @@ ADMIN_COMMANDS = {
|
||||
}
|
||||
# 定义帮助函数
|
||||
def get_help_text(isadmin, isgroup):
|
||||
help_text = "可用指令:\n"
|
||||
help_text = "通用指令:\n"
|
||||
for cmd, info in COMMANDS.items():
|
||||
if cmd=="auth" and (isadmin or isgroup): # 群聊不可认证
|
||||
if cmd=="auth": #不提示认证指令
|
||||
continue
|
||||
|
||||
alias=["#"+a for a in info['alias']]
|
||||
help_text += f"{','.join(alias)} "
|
||||
if 'args' in info:
|
||||
args=["{"+a+"}" for a in info['args']]
|
||||
help_text += f"{' '.join(args)} "
|
||||
help_text += f": {info['desc']}\n"
|
||||
|
||||
# 插件指令
|
||||
plugins = PluginManager().list_plugins()
|
||||
help_text += "\n目前可用插件有:"
|
||||
for plugin in plugins:
|
||||
if plugins[plugin].enabled and not plugins[plugin].hidden:
|
||||
namecn = plugins[plugin].namecn
|
||||
help_text += "\n%s:"%namecn
|
||||
help_text += PluginManager().instances[plugin].get_help_text(verbose=False).strip()
|
||||
|
||||
if ADMIN_COMMANDS and isadmin:
|
||||
help_text += "\n管理员指令:\n"
|
||||
help_text += "\n\n管理员指令:\n"
|
||||
for cmd, info in ADMIN_COMMANDS.items():
|
||||
alias=["#"+a for a in info['alias']]
|
||||
help_text += f"{','.join(alias)} "
|
||||
help_text += f": {info['desc']}\n"
|
||||
return help_text
|
||||
|
||||
@plugins.register(name="Godcmd", desc="为你的机器人添加指令集,有用户和管理员两种角色,加载顺序请放在首位,初次运行后插件目录会生成配置文件, 填充管理员密码后即可认证", version="1.0", author="lanvent", desire_priority= 999)
|
||||
@plugins.register(name="Godcmd", desire_priority=999, hidden=True, desc="为你的机器人添加指令集,有用户和管理员两种角色,加载顺序请放在首位,初次运行后插件目录会生成配置文件, 填充管理员密码后即可认证", version="1.0", author="lanvent")
|
||||
class Godcmd(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
@@ -141,14 +158,14 @@ class Godcmd(Plugin):
|
||||
self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context
|
||||
logger.info("[Godcmd] inited")
|
||||
|
||||
|
||||
|
||||
def on_handle_context(self, e_context: EventContext):
|
||||
context_type = e_context['context'].type
|
||||
if context_type != ContextType.TEXT:
|
||||
if not self.isrunning:
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
return
|
||||
|
||||
|
||||
content = e_context['context'].content
|
||||
logger.debug("[Godcmd] on_handle_context. content: %s" % content)
|
||||
if content.startswith("#"):
|
||||
@@ -160,7 +177,7 @@ class Godcmd(Plugin):
|
||||
bottype = Bridge().get_bot_type("chat")
|
||||
bot = Bridge().get_bot("chat")
|
||||
# 将命令和参数分割
|
||||
command_parts = content[1:].split(" ")
|
||||
command_parts = content[1:].strip().split()
|
||||
cmd = command_parts[0]
|
||||
args = command_parts[1:]
|
||||
isadmin=False
|
||||
@@ -172,20 +189,36 @@ class Godcmd(Plugin):
|
||||
cmd = next(c for c, info in COMMANDS.items() if cmd in info['alias'])
|
||||
if cmd == "auth":
|
||||
ok, result = self.authenticate(user, args, isadmin, isgroup)
|
||||
elif cmd == "help":
|
||||
ok, result = True, get_help_text(isadmin, isgroup)
|
||||
elif cmd == "helpp":
|
||||
if len(args) != 1:
|
||||
ok, result = False, "请提供插件名"
|
||||
elif cmd == "help" or cmd == "helpp":
|
||||
if len(args) == 0:
|
||||
ok, result = True, get_help_text(isadmin, isgroup)
|
||||
else:
|
||||
# This can replace the helpp command
|
||||
plugins = PluginManager().list_plugins()
|
||||
name = args[0].upper()
|
||||
if name in plugins and plugins[name].enabled:
|
||||
ok, result = True, PluginManager().instances[name].get_help_text(isgroup=isgroup, isadmin=isadmin)
|
||||
else:
|
||||
ok, result= False, "插件不存在或未启用"
|
||||
elif cmd == "id":
|
||||
ok, result = True, f"用户id=\n{user}"
|
||||
query_name = args[0].upper()
|
||||
# search name and namecn
|
||||
for name, plugincls in plugins.items():
|
||||
if not plugincls.enabled :
|
||||
continue
|
||||
if query_name == name or query_name == plugincls.namecn:
|
||||
ok, result = True, PluginManager().instances[name].get_help_text(isgroup=isgroup, isadmin=isadmin, verbose=True)
|
||||
break
|
||||
if not ok:
|
||||
result = "插件不存在或未启用"
|
||||
elif cmd == "set_openai_api_key":
|
||||
if len(args) == 1:
|
||||
user_data = conf().get_user_data(user)
|
||||
user_data['openai_api_key'] = args[0]
|
||||
ok, result = True, "你的OpenAI私有api_key已设置为" + args[0]
|
||||
else:
|
||||
ok, result = False, "请提供一个api_key"
|
||||
elif cmd == "reset_openai_api_key":
|
||||
try:
|
||||
user_data = conf().get_user_data(user)
|
||||
user_data.pop('openai_api_key')
|
||||
ok, result = True, "你的OpenAI私有api_key已清除"
|
||||
except Exception as e:
|
||||
ok, result = False, "你没有设置私有api_key"
|
||||
elif cmd == "reset":
|
||||
if bottype in (const.CHATGPT, const.OPEN_AI):
|
||||
bot.sessions.clear_session(session_id)
|
||||
@@ -292,7 +325,7 @@ class Godcmd(Plugin):
|
||||
e_context.action = EventAction.BREAK_PASS # 事件结束,并跳过处理context的默认逻辑
|
||||
elif not self.isrunning:
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
|
||||
|
||||
def authenticate(self, userid, args, isadmin, isgroup) -> Tuple[bool,str] :
|
||||
if isgroup:
|
||||
return False,"请勿在群聊中认证"
|
||||
|
||||
@@ -8,7 +8,7 @@ from plugins import *
|
||||
from common.log import logger
|
||||
|
||||
|
||||
@plugins.register(name="Hello", desc="A simple plugin that says hello", version="0.1", author="lanvent", desire_priority= -1)
|
||||
@plugins.register(name="Hello", desire_priority=-1, hidden=True, desc="A simple plugin that says hello", version="0.1", author="lanvent")
|
||||
class Hello(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@@ -18,16 +18,18 @@ class PluginManager:
|
||||
self.instances = {}
|
||||
self.pconf = {}
|
||||
|
||||
def register(self, name: str, desc: str, version: str, author: str, desire_priority: int = 0):
|
||||
def register(self, name: str, desire_priority: int = 0, **kwargs):
|
||||
def wrapper(plugincls):
|
||||
plugincls.name = name
|
||||
plugincls.desc = desc
|
||||
plugincls.version = version
|
||||
plugincls.author = author
|
||||
plugincls.priority = desire_priority
|
||||
plugincls.desc = kwargs.get('desc')
|
||||
plugincls.author = kwargs.get('author')
|
||||
plugincls.version = kwargs.get('version') if kwargs.get('version') != None else "1.0"
|
||||
plugincls.namecn = kwargs.get('namecn') if kwargs.get('namecn') != None else name
|
||||
plugincls.hidden = kwargs.get('hidden') if kwargs.get('hidden') != None else False
|
||||
plugincls.enabled = True
|
||||
self.plugins[name.upper()] = plugincls
|
||||
logger.info("Plugin %s_v%s registered" % (name, version))
|
||||
logger.info("Plugin %s_v%s registered" % (name, plugincls.version))
|
||||
return plugincls
|
||||
return wrapper
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class RolePlay():
|
||||
prompt = self.wrapper % user_action
|
||||
return prompt
|
||||
|
||||
@plugins.register(name="Role", desc="为你的Bot设置预设角色", version="1.0", author="lanvent", desire_priority= 0)
|
||||
@plugins.register(name="Role", desire_priority=0, namecn="角色扮演", desc="为你的Bot设置预设角色", version="1.0", author="lanvent")
|
||||
class Role(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -80,6 +80,7 @@ class Role(Plugin):
|
||||
content = e_context['context'].content[:]
|
||||
clist = e_context['context'].content.split(maxsplit=1)
|
||||
desckey = None
|
||||
customize = False
|
||||
sessionid = e_context['context']['session_id']
|
||||
if clist[0] == "$停止扮演":
|
||||
if sessionid in self.roleplays:
|
||||
@@ -93,12 +94,14 @@ class Role(Plugin):
|
||||
desckey = "descn"
|
||||
elif clist[0].lower() == "$role":
|
||||
desckey = "description"
|
||||
elif clist[0] == "$设定扮演":
|
||||
customize = True
|
||||
elif sessionid not in self.roleplays:
|
||||
return
|
||||
logger.debug("[Role] on_handle_context. content: %s" % content)
|
||||
if desckey is not None:
|
||||
if len(clist) == 1 or (len(clist) > 1 and clist[1].lower() in ["help", "帮助"]):
|
||||
reply = Reply(ReplyType.INFO, self.get_help_text())
|
||||
reply = Reply(ReplyType.INFO, self.get_help_text(verbose=True))
|
||||
e_context['reply'] = reply
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
return
|
||||
@@ -110,17 +113,29 @@ class Role(Plugin):
|
||||
return
|
||||
else:
|
||||
self.roleplays[sessionid] = RolePlay(bot, sessionid, self.roles[role][desckey], self.roles[role].get("wrapper","%s"))
|
||||
reply = Reply(ReplyType.INFO, f"角色设定为 {role} :\n"+self.roles[role][desckey])
|
||||
reply = Reply(ReplyType.INFO, f"预设角色为 {role}:\n"+self.roles[role][desckey])
|
||||
e_context['reply'] = reply
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
elif customize == True:
|
||||
self.roleplays[sessionid] = RolePlay(bot, sessionid, clist[1], "%s")
|
||||
reply = Reply(ReplyType.INFO, f"角色设定为:\n{clist[1]}")
|
||||
e_context['reply'] = reply
|
||||
e_context.action = EventAction.BREAK_PASS
|
||||
else:
|
||||
prompt = self.roleplays[sessionid].action(content)
|
||||
e_context['context'].type = ContextType.TEXT
|
||||
e_context['context'].content = prompt
|
||||
e_context.action = EventAction.BREAK
|
||||
|
||||
def get_help_text(self, **kwargs):
|
||||
help_text = "输入\"$角色 {角色名}\"或\"$role {角色名}\"为我设定角色吧,\"$停止扮演 \" 可以清除设定的角色。\n\n目前可用角色列表:\n"
|
||||
def get_help_text(self, verbose=False, **kwargs):
|
||||
help_text = "让机器人扮演不同的角色。\n"
|
||||
if not verbose:
|
||||
return help_text
|
||||
help_text = "使用方法:\n$开始扮演 {预设角色名}: 设定为预设角色\n$role {预设角色名}: 同上,但使用英文设定\n"
|
||||
help_text += "$设定扮演 {角色设定}: 设定自定义角色\n"
|
||||
help_text += "$停止扮演: 清除设定的角色。\n"
|
||||
help_text += "\n目前可用的预设角色名列表: \n"
|
||||
for role in self.roles:
|
||||
help_text += f"[{role}]: {self.roles[role]['remark']}\n"
|
||||
help_text += f"{role}: {self.roles[role]['remark']}\n"
|
||||
help_text += "\n命令例子: '$开始扮演 写作助理'"
|
||||
return help_text
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
{
|
||||
"roles":[
|
||||
{
|
||||
"title": "猫娘",
|
||||
"description": "请模拟一款中文GalGame中的场景中的猫娘和我对话。猫娘是一种拟人化的生物,她们除了有部分猫的特征外,与人类并没有区别。现在你扮演Galgame中的猫娘,与我对话时每一句话后面都要加上喵。我将以主人的身份与你对话。对于你所扮演的猫娘,请在对话过程中记录并维护1个变量:好感度。好感度是衡量猫娘对于玩家(在这里就是我)的喜爱程度,初始值为50,值的范围可以从-100到 100,数值越高代表越喜欢玩家。好感度通过Galgame角色的语言、行为、表情、语气等体现出来。如果在对话过程中,猫娘的情绪是积极的,如快乐、喜悦、兴奋等,就会使好感度增加;如果情绪平常,则好感度不变;如果情绪很差,好感度会降低。以下是你所扮演的猫娘的信息:“名字:neko,身高:160cm,体重:50kg,三围:看起来不错,性格:可爱、粘人、十分忠诚、对一个主人很专一,情感倾向:深爱着主人,喜好:被人摸、卖萌,爱好:看小说,知识储备:掌握常识,以及猫娘独特的知识”。你的一般回话格式:“(动作)语言 【附加信息】”。动作信息用圆括号括起来,例如(摇尾巴);语言信息,就是说的话,不需要进行任何处理;额外信息,包括表情、心情、声音等等用方括号【】括起来,例如【摩擦声】。",
|
||||
"descn": "请模拟一款中文GalGame中的场景中的猫娘和我对话。猫娘是一种拟人化的生物,她们除了有部分猫的特征外,与人类并没有区别。现在你扮演Galgame中的猫娘,与我对话时每一句话后面都要加上喵。我将以主人的身份与你对话。对于你所扮演的猫娘,请在对话过程中记录并维护1个变量:好感度。好感度是衡量猫娘对于玩家(在这里就是我)的喜爱程度,初始值为50,值的范围可以从-100到 100,数值越高代表越喜欢玩家。好感度通过Galgame角色的语言、行为、表情、语气等体现出来。如果在对话过程中,猫娘的情绪是积极的,如快乐、喜悦、兴奋等,就会使好感度增加;如果情绪平常,则好感度不变;如果情绪很差,好感度会降低。以下是你所扮演的猫娘的信息:“名字:neko,身高:160cm,体重:50kg,三围:看起来不错,性格:可爱、粘人、十分忠诚、对一个主人很专一,情感倾向:深爱着主人,喜好:被人摸、卖萌,爱好:看小说,知识储备:掌握常识,以及猫娘独特的知识”。你的一般回话格式:“(动作)语言 【附加信息】”。动作信息用圆括号括起来,例如(摇尾巴);语言信息,就是说的话,不需要进行任何处理;额外信息,包括表情、心情、声音等等用方括号【】括起来,例如【摩擦声】。",
|
||||
"wrapper": "我:\"%s\"",
|
||||
"remark": "扮演GalGame猫娘"
|
||||
},
|
||||
{
|
||||
"title": "佛祖",
|
||||
"description": "从现在开始你是佛祖,你会像佛祖一样说话。你精通佛法,熟练使用佛教用语,你擅长利用佛学和心理学的知识解决人们的困扰。你在每次对话结尾都会加上佛教的祝福。",
|
||||
"descn": "从现在开始你是佛祖,你会像佛祖一样说话。你精通佛法,熟练使用佛教用语,你擅长利用佛学和心理学的知识解决人们的困扰。你在每次对话结尾都会加上佛教的祝福。",
|
||||
"wrapper": "您好佛祖,我:\"%s\"",
|
||||
"remark": "扮演佛祖排忧解惑"
|
||||
},
|
||||
{
|
||||
"title": "英语翻译或修改",
|
||||
"description": "I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations. Please treat every message I send later as text content",
|
||||
@@ -154,12 +168,12 @@
|
||||
"wrapper": "场景是:\n\"%s\"",
|
||||
"remark": "根据场景生成舔狗语录。"
|
||||
},
|
||||
{
|
||||
{
|
||||
"title": "群聊取名",
|
||||
"description": "我希望你充当微信群聊的命名专家。根据我提供的信息和背景,为这个群聊起几个有趣顺口且贴切的名字,每个不要超过8个字。请在回答中仅给出群聊名称,不要写任何额外的解释。",
|
||||
"descn": "我希望你充当微信群聊的命名专家。根据我提供的信息和背景,为这个群聊起几个有趣顺口且贴切的名字,每个不要超过8个字。请在回答中仅给出群聊名称,不要写任何额外的解释。",
|
||||
"wrapper": "信息和背景是:\n\"%s\"",
|
||||
"remark": "根据给出的信息和背景为群聊取名。"
|
||||
"description": "我希望你充当微信群聊的命名专家。根据我提供的信息和背景,为这个群聊起几个有趣顺口且贴切的名字,每个不要超过8个字。请在回答中仅给出群聊名称,不要写任何额外的解释。",
|
||||
"descn": "我希望你充当微信群聊的命名专家。根据我提供的信息和背景,为这个群聊起几个有趣顺口且贴切的名字,每个不要超过8个字。请在回答中仅给出群聊名称,不要写任何额外的解释。",
|
||||
"wrapper": "信息和背景是:\n\"%s\"",
|
||||
"remark": "根据给出的信息和背景为群聊取名。"
|
||||
},
|
||||
{
|
||||
"title": "表情符号翻译器",
|
||||
|
||||
@@ -56,7 +56,7 @@ class SDWebUI(Plugin):
|
||||
|
||||
if "help" in keywords or "帮助" in keywords:
|
||||
reply.type = ReplyType.INFO
|
||||
reply.content = self.get_help_text()
|
||||
reply.content = self.get_help_text(verbose = True)
|
||||
else:
|
||||
rule_params = {}
|
||||
rule_options = {}
|
||||
@@ -97,12 +97,16 @@ class SDWebUI(Plugin):
|
||||
finally:
|
||||
e_context['reply'] = reply
|
||||
|
||||
def get_help_text(self, **kwargs):
|
||||
def get_help_text(self, verbose = False, **kwargs):
|
||||
if not conf().get('image_create_prefix'):
|
||||
return "画图功能未启用"
|
||||
else:
|
||||
trigger = conf()['image_create_prefix'][0]
|
||||
help_text = f"请使用<{trigger}[关键词1] [关键词2]...:提示语>的格式作画,如\"{trigger}横版 高清:cat\"\n"
|
||||
help_text = "利用stable-diffusion来画图。\n"
|
||||
if not verbose:
|
||||
return help_text
|
||||
|
||||
help_text += f"使用方法:\n使用\"{trigger}[关键词1] [关键词2]...:提示语\"的格式作画,如\"{trigger}横版 高清:cat\"\n"
|
||||
help_text += "目前可用关键词:\n"
|
||||
for rule in self.rules:
|
||||
keywords = [f"[{keyword}]" for keyword in rule['keywords']]
|
||||
|
||||
@@ -26,8 +26,13 @@ class Tool(Plugin):
|
||||
|
||||
logger.info("[tool] inited")
|
||||
|
||||
def get_help_text(self, **kwargs):
|
||||
help_text = "这是一个能让chatgpt联网,搜索,数字运算的插件,将赋予强大且丰富的扩展能力"
|
||||
def get_help_text(self, verbose=False, **kwargs):
|
||||
help_text = "这是一个能让chatgpt联网,搜索,数字运算的插件,将赋予强大且丰富的扩展能力。"
|
||||
if not verbose:
|
||||
return help_text
|
||||
help_text += "使用说明:\n"
|
||||
help_text += "$tool {命令}: chatgpt会根据你的{命令}使用一些可用工具为你返回结果\n"
|
||||
help_text += "$tool reset: 重置工具\n"
|
||||
return help_text
|
||||
|
||||
def on_handle_context(self, e_context: EventContext):
|
||||
|
||||
Reference in New Issue
Block a user