diff --git a/plugins/deadend/deadend.go b/plugins/deadend/deadend.go index 4c8e74d..55d236f 100644 --- a/plugins/deadend/deadend.go +++ b/plugins/deadend/deadend.go @@ -6,7 +6,7 @@ import ( "regexp" ) -const defaultMessage = "I don't know how to respond to that. If you'd like to ask an LLM, use the `llm` command." +const defaultMessage = "I don't know how to respond to that. If you'd like to ask an LLM, use the `llm` command (or prefix your message with &)." type DeadEndPlugin struct { b bot.Bot diff --git a/plugins/llm/gpt.go b/plugins/llm/gpt.go index 39fd479..ef11d5a 100644 --- a/plugins/llm/gpt.go +++ b/plugins/llm/gpt.go @@ -8,6 +8,7 @@ import ( "github.com/velour/catbase/bot" "github.com/velour/catbase/config" "regexp" + "strings" "time" ) @@ -48,6 +49,12 @@ func (p *LLMPlugin) register() { HelpText: "set the ChatGPT prompt", Handler: p.setPromptMessage, }, + { + Kind: bot.Message, IsCmd: false, + Regex: regexp.MustCompile(`(?is)^&(?P.*)`), + HelpText: "chat completion using first-available AI", + Handler: p.geminiChatMessage, + }, { Kind: bot.Message, IsCmd: true, Regex: regexp.MustCompile(`(?is)^llm (?P.*)`), @@ -55,7 +62,7 @@ func (p *LLMPlugin) register() { Handler: p.geminiChatMessage, }, { - Kind: bot.Message, IsCmd: true, + Kind: bot.Message, IsCmd: false, Regex: regexp.MustCompile(`(?is)^gpt4 (?P.*)`), HelpText: "chat completion using OpenAI", Handler: p.gptMessage, @@ -66,6 +73,11 @@ func (p *LLMPlugin) register() { HelpText: "clear chat history", Handler: p.puke, }, + { + Kind: bot.Help, IsCmd: false, + Regex: regexp.MustCompile(`.*`), + Handler: p.help, + }, } p.b.RegisterTable(p, p.h) } @@ -164,3 +176,16 @@ func (p *LLMPlugin) puke(r bot.Request) bool { p.b.Send(r.Conn, bot.Message, r.Msg.Channel, resp) return true } + +func (p *LLMPlugin) help(r bot.Request) bool { + out := "Talk like a pirate commands:\n" + for _, h := range p.h { + if h.HelpText == "" { + continue + } + out += fmt.Sprintf("```%s```\t%s", h.Regex.String(), h.HelpText) + } + out = strings.TrimSpace(out) + p.b.Send(r.Conn, bot.Message, r.Msg.Channel, out) + return true +}