first: re-enable

This commit is contained in:
cws 2017-08-18 05:59:46 -04:00
parent 9264febfbe
commit 19578f7147
2 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/velour/catbase/plugins/dice"
"github.com/velour/catbase/plugins/emojifyme"
"github.com/velour/catbase/plugins/fact"
"github.com/velour/catbase/plugins/first"
"github.com/velour/catbase/plugins/leftpad"
"github.com/velour/catbase/plugins/reaction"
"github.com/velour/catbase/plugins/reminder"
@ -49,7 +50,7 @@ func main() {
// b.AddHandler(plugins.NewTestPlugin(b))
b.AddHandler("admin", admin.New(b))
b.AddHandler("stats", stats.New(b))
// b.AddHandler("first", plugins.NewFirstPlugin(b))
b.AddHandler("first", first.New(b))
b.AddHandler("leftpad", leftpad.New(b))
// b.AddHandler("downtime", downtime.New(b))
b.AddHandler("talker", talker.New(b))

View File

@ -129,10 +129,12 @@ func (p *FirstPlugin) Message(message msg.Message) bool {
// This bot does not reply to anything
if p.First == nil && p.allowed(message) {
log.Printf("No previous first. Recording new first: %s", message.Body)
p.recordFirst(message)
return false
} else if p.First != nil {
if isToday(p.First.time) && p.allowed(message) {
log.Printf("Recording first: %s - %v vs %v", message.Body, p.First.time, time.Now())
p.recordFirst(message)
return false
}
@ -143,8 +145,6 @@ func (p *FirstPlugin) Message(message msg.Message) bool {
msg := strings.ToLower(message.Body)
if r.Replace(msg) == "whos on first" {
p.announceFirst(message)
log.Printf("Disallowing %s: %s from first.",
message.User.Name, message.Body)
return true
}
@ -185,6 +185,7 @@ func (p *FirstPlugin) recordFirst(message msg.Message) {
body: message.Body,
nick: message.User.Name,
}
log.Printf("recordFirst: %+v", p.First.day)
err := p.First.save(p.db)
if err != nil {
log.Println("Error saving first entry: ", err)