diff --git a/config/config.go b/config/config.go index 08f8a64..40b4d0a 100644 --- a/config/config.go +++ b/config/config.go @@ -106,7 +106,7 @@ func (c *Config) GetString(key, fallback string) string { q := `select value from config where key=?` err := c.DB.Get(&configValue, q, key) if err != nil { - log.Debug().Msgf("WARN: Key %s is empty", key) + log.Info().Msgf("WARN: Key %s is empty", key) return fallback } return configValue diff --git a/plugins/gpt/gpt3.go b/plugins/gpt/gpt3.go index 764ca53..1bfee23 100644 --- a/plugins/gpt/gpt3.go +++ b/plugins/gpt/gpt3.go @@ -9,6 +9,7 @@ import ( "net/http" "reflect" "regexp" + "slices" "strings" "github.com/rs/zerolog/log" @@ -48,7 +49,7 @@ func (p *GPTPlugin) register() { Kind: bot.Message, IsCmd: true, Regex: regexp.MustCompile(`(?is)^gpt (?P.*)`), HelpText: "chat completion", - Handler: p.chatMessage, + Handler: p.chatMessageForce, }, { Kind: bot.Message, IsCmd: true, @@ -62,7 +63,6 @@ func (p *GPTPlugin) register() { Handler: p.chatMessage, }, } - log.Debug().Msg("Registering GPT3 handlers") p.b.RegisterTable(p, p.h) } @@ -77,6 +77,14 @@ func (p *GPTPlugin) setPromptMessage(r bot.Request) bool { } func (p *GPTPlugin) chatMessage(r bot.Request) bool { + if slices.Contains(p.c.GetArray("gpt.silence", []string{}), r.Msg.Channel) { + log.Debug().Msgf("%s silenced", r.Msg.Channel) + return true + } + return p.chatMessageForce(r) +} + +func (p *GPTPlugin) chatMessageForce(r bot.Request) bool { resp, err := p.chatGPT(r.Values["text"]) if err != nil { resp = fmt.Sprintf("Error: %s", err)