Compare commits

...

2 Commits

Author SHA1 Message Date
Chris Sexton 494c9e87d6 github: update to go 1.21 2024-01-04 13:16:27 -05:00
Chris Sexton 448ae768ba gpt: silence some rooms 2024-01-04 13:16:27 -05:00
3 changed files with 13 additions and 5 deletions

View File

@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.18 - name: Set up Go 1.21
uses: actions/setup-go@v1 uses: actions/setup-go@v1
with: with:
go-version: 1.18.x go-version: 1.21.x
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory

View File

@ -106,7 +106,7 @@ func (c *Config) GetString(key, fallback string) string {
q := `select value from config where key=?` q := `select value from config where key=?`
err := c.DB.Get(&configValue, q, key) err := c.DB.Get(&configValue, q, key)
if err != nil { if err != nil {
log.Debug().Msgf("WARN: Key %s is empty", key) log.Info().Msgf("WARN: Key %s is empty", key)
return fallback return fallback
} }
return configValue return configValue

View File

@ -9,6 +9,7 @@ import (
"net/http" "net/http"
"reflect" "reflect"
"regexp" "regexp"
"slices"
"strings" "strings"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -48,7 +49,7 @@ func (p *GPTPlugin) register() {
Kind: bot.Message, IsCmd: true, Kind: bot.Message, IsCmd: true,
Regex: regexp.MustCompile(`(?is)^gpt (?P<text>.*)`), Regex: regexp.MustCompile(`(?is)^gpt (?P<text>.*)`),
HelpText: "chat completion", HelpText: "chat completion",
Handler: p.chatMessage, Handler: p.chatMessageForce,
}, },
{ {
Kind: bot.Message, IsCmd: true, Kind: bot.Message, IsCmd: true,
@ -62,7 +63,6 @@ func (p *GPTPlugin) register() {
Handler: p.chatMessage, Handler: p.chatMessage,
}, },
} }
log.Debug().Msg("Registering GPT3 handlers")
p.b.RegisterTable(p, p.h) 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 { 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"]) resp, err := p.chatGPT(r.Values["text"])
if err != nil { if err != nil {
resp = fmt.Sprintf("Error: %s", err) resp = fmt.Sprintf("Error: %s", err)