tldr: filter by channel

This commit is contained in:
Chris Sexton 2024-01-05 19:00:41 -05:00
parent f8f18acacb
commit 5acf14b0ae
1 changed files with 5 additions and 1 deletions

View File

@ -29,6 +29,7 @@ type TLDRPlugin struct {
type history struct {
timestamp time.Time
channel string
user string
body string
}
@ -81,6 +82,7 @@ func (p *TLDRPlugin) record(r bot.Request) bool {
hist := history{
body: strings.ToLower(r.Msg.Body),
user: r.Msg.User.Name,
channel: r.Msg.Channel,
timestamp: time.Now(),
}
p.addHistory(hist)
@ -226,7 +228,9 @@ func (p *TLDRPlugin) betterTLDR(r bot.Request) bool {
promptTpl.Execute(&prompt, data)
backlog := ""
for _, h := range p.history {
backlog += fmt.Sprintf("%s: %s\n", h.user, h.body)
if h.channel == r.Msg.Channel {
backlog += fmt.Sprintf("%s: %s\n", h.user, h.body)
}
}
sess := c.NewChatSession(prompt.String())
completion, err := sess.Complete(context.TODO(), backlog)