iuiaoin / wechat-gptbot

A wechat robot based on ChatGPT with no risk, very stable! 🚀
MIT License
583 stars 115 forks source link

[Feat]: 给自定义的插件传递参数 #72

Closed QAbot-zh closed 1 year ago

QAbot-zh commented 1 year ago

Search for answers in existing issues

Feature description

怎么给自定义的插件传递参数?示例的tiktok是命令式的,怎么给它附加参数,就是用户输入command后加入搜索参数,让插件功能更丰富

Motivation

No response

QAbot-zh commented 1 year ago

勉强找到一种可行的方法,提供大家参考:

    def will_generate_reply(self, event: Event):
        query = event.context.query
        command = self.config.get("command")
        if query.startswith(command):
            self.msg = query.lstrip(command).replace(' ', '').replace(',','').replace(',','')
            event.reply = self.reply()
            event.bypass()

如果作者有更好的方法,可以提示我一下

iuiaoin commented 1 year ago

@undefinedcodezhong 命令式的调用目前暂时只能使用模式匹配的方式,之后集成了 function calling 应该会对用户更加友好, 有个issue在track: #30