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 {
|
||||
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,8 +228,10 @@ func (p *TLDRPlugin) betterTLDR(r bot.Request) bool {
|
|||
promptTpl.Execute(&prompt, data)
|
||||
backlog := ""
|
||||
for _, h := range p.history {
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue