mirror of https://github.com/velour/catbase.git
tldr: filter by channel
This commit is contained in:
parent
f8f18acacb
commit
5acf14b0ae
|
@ -29,6 +29,7 @@ type TLDRPlugin struct {
|
||||||
|
|
||||||
type history struct {
|
type history struct {
|
||||||
timestamp time.Time
|
timestamp time.Time
|
||||||
|
channel string
|
||||||
user string
|
user string
|
||||||
body string
|
body string
|
||||||
}
|
}
|
||||||
|
@ -81,6 +82,7 @@ func (p *TLDRPlugin) record(r bot.Request) bool {
|
||||||
hist := history{
|
hist := history{
|
||||||
body: strings.ToLower(r.Msg.Body),
|
body: strings.ToLower(r.Msg.Body),
|
||||||
user: r.Msg.User.Name,
|
user: r.Msg.User.Name,
|
||||||
|
channel: r.Msg.Channel,
|
||||||
timestamp: time.Now(),
|
timestamp: time.Now(),
|
||||||
}
|
}
|
||||||
p.addHistory(hist)
|
p.addHistory(hist)
|
||||||
|
@ -226,7 +228,9 @@ func (p *TLDRPlugin) betterTLDR(r bot.Request) bool {
|
||||||
promptTpl.Execute(&prompt, data)
|
promptTpl.Execute(&prompt, data)
|
||||||
backlog := ""
|
backlog := ""
|
||||||
for _, h := range p.history {
|
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())
|
sess := c.NewChatSession(prompt.String())
|
||||||
completion, err := sess.Complete(context.TODO(), backlog)
|
completion, err := sess.Complete(context.TODO(), backlog)
|
||||||
|
|
Loading…
Reference in New Issue