mirror of https://github.com/velour/catbase.git
Compare commits
2 Commits
4c669e520f
...
802911203f
Author | SHA1 | Date |
---|---|---|
|
802911203f | |
|
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
|
||||
|
@ -24,6 +27,7 @@ func New(b bot.Bot) *LastPlugin {
|
|||
p := &LastPlugin{
|
||||
b: b,
|
||||
db: b.DB(),
|
||||
c: b.Config(),
|
||||
channels: map[string]bool{},
|
||||
}
|
||||
if err := p.migrate(); err != nil {
|
||||
|
@ -98,6 +102,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