mirror of https://github.com/velour/catbase.git
last: add filters for invalid messages
This commit is contained in:
parent
4c669e520f
commit
19cbf5efd9
|
@ -5,6 +5,8 @@ import (
|
|||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/config"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
|
@ -15,6 +17,7 @@ import (
|
|||
type LastPlugin struct {
|
||||
b bot.Bot
|
||||
db *sqlx.DB
|
||||
c *config.Config
|
||||
|
||||
handlers bot.HandlerTable
|
||||
channels map[string]bool
|
||||
|
@ -98,6 +101,17 @@ func (p *LastPlugin) recordLast(r bot.Request) bool {
|
|||
}
|
||||
}
|
||||
|
||||
if r.Msg.Body == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
invalidUsers := p.c.GetArray("last.invalidUsers", []string{"unknown"})
|
||||
for _, u := range invalidUsers {
|
||||
if who == u {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
_, err := p.db.Exec(
|
||||
`insert into last values (?, ?, ?, ?, ?)
|
||||
on conflict(day) do update set
|
||||
|
|
Loading…
Reference in New Issue