feat: add plugin_trigger_prefix option

This commit is contained in:
lanvent
2023-04-05 05:37:06 +08:00
parent e00c99c1d7
commit 62e3baba20
6 changed files with 31 additions and 18 deletions

View File

@@ -30,9 +30,10 @@ class Tool(Plugin):
help_text = "这是一个能让chatgpt联网搜索数字运算的插件将赋予强大且丰富的扩展能力。"
if not verbose:
return help_text
trigger_prefix = conf().get('plugin_trigger_prefix', "$")
help_text += "使用说明:\n"
help_text += "$tool {命令}: chatgpt会根据你的{命令}使用一些可用工具为你返回结果\n"
help_text += "$tool reset: 重置工具\n"
help_text += f"{trigger_prefix}tool "+"{命令}: 根据给出的命令使用一些可用工具尽力为你得到结果\n"
help_text += f"{trigger_prefix}tool reset: 重置工具\n"
return help_text
def on_handle_context(self, e_context: EventContext):
@@ -53,9 +54,9 @@ class Tool(Plugin):
logger.debug("[tool] on_handle_context. content: %s" % content)
reply = Reply()
reply.type = ReplyType.TEXT
trigger_prefix = conf().get('plugin_trigger_prefix', "$")
# todo: 有些工具必须要api-key需要修改config文件所以这里没有实现query增删tool的功能
if content.startswith("$tool"):
if content.startswith(f"{trigger_prefix}tool"):
if len(content_list) == 1:
logger.debug("[tool]: get help")
reply.content = self.get_help_text()