diff --git a/plugins/last/last.go b/plugins/last/last.go index ce10bef..0a30ce2 100644 --- a/plugins/last/last.go +++ b/plugins/last/last.go @@ -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