2024-03-07 16:53:49 +00:00
|
|
|
package deadend
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/velour/catbase/bot"
|
|
|
|
"github.com/velour/catbase/config"
|
|
|
|
"regexp"
|
|
|
|
)
|
|
|
|
|
2024-09-28 16:20:41 +00:00
|
|
|
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 &)."
|
2024-03-07 16:53:49 +00:00
|
|
|
|
|
|
|
type DeadEndPlugin struct {
|
|
|
|
b bot.Bot
|
|
|
|
c *config.Config
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(b bot.Bot) *DeadEndPlugin {
|
|
|
|
p := &DeadEndPlugin{
|
|
|
|
b: b,
|
|
|
|
c: b.Config(),
|
|
|
|
}
|
|
|
|
b.RegisterRegexCmd(p, bot.Message, regexp.MustCompile(`.*`), p.message)
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *DeadEndPlugin) message(r bot.Request) bool {
|
|
|
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel,
|
|
|
|
p.c.Get("deadend.message", defaultMessage))
|
|
|
|
return true
|
|
|
|
}
|