From 19578f7147a459f0be345e561aef0aef93b2c899 Mon Sep 17 00:00:00 2001 From: cws Date: Fri, 18 Aug 2017 05:59:46 -0400 Subject: [PATCH] first: re-enable --- main.go | 3 ++- plugins/first/first.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 6ba3cca..5805713 100644 --- a/main.go +++ b/main.go @@ -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)) diff --git a/plugins/first/first.go b/plugins/first/first.go index 9f89193..9d63c6f 100644 --- a/plugins/first/first.go +++ b/plugins/first/first.go @@ -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)