mirror of https://github.com/velour/catbase.git
first: re-enable
This commit is contained in:
parent
9264febfbe
commit
19578f7147
3
main.go
3
main.go
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/velour/catbase/plugins/dice"
|
"github.com/velour/catbase/plugins/dice"
|
||||||
"github.com/velour/catbase/plugins/emojifyme"
|
"github.com/velour/catbase/plugins/emojifyme"
|
||||||
"github.com/velour/catbase/plugins/fact"
|
"github.com/velour/catbase/plugins/fact"
|
||||||
|
"github.com/velour/catbase/plugins/first"
|
||||||
"github.com/velour/catbase/plugins/leftpad"
|
"github.com/velour/catbase/plugins/leftpad"
|
||||||
"github.com/velour/catbase/plugins/reaction"
|
"github.com/velour/catbase/plugins/reaction"
|
||||||
"github.com/velour/catbase/plugins/reminder"
|
"github.com/velour/catbase/plugins/reminder"
|
||||||
|
@ -49,7 +50,7 @@ func main() {
|
||||||
// b.AddHandler(plugins.NewTestPlugin(b))
|
// b.AddHandler(plugins.NewTestPlugin(b))
|
||||||
b.AddHandler("admin", admin.New(b))
|
b.AddHandler("admin", admin.New(b))
|
||||||
b.AddHandler("stats", stats.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("leftpad", leftpad.New(b))
|
||||||
// b.AddHandler("downtime", downtime.New(b))
|
// b.AddHandler("downtime", downtime.New(b))
|
||||||
b.AddHandler("talker", talker.New(b))
|
b.AddHandler("talker", talker.New(b))
|
||||||
|
|
|
@ -129,10 +129,12 @@ func (p *FirstPlugin) Message(message msg.Message) bool {
|
||||||
// This bot does not reply to anything
|
// This bot does not reply to anything
|
||||||
|
|
||||||
if p.First == nil && p.allowed(message) {
|
if p.First == nil && p.allowed(message) {
|
||||||
|
log.Printf("No previous first. Recording new first: %s", message.Body)
|
||||||
p.recordFirst(message)
|
p.recordFirst(message)
|
||||||
return false
|
return false
|
||||||
} else if p.First != nil {
|
} else if p.First != nil {
|
||||||
if isToday(p.First.time) && p.allowed(message) {
|
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)
|
p.recordFirst(message)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -143,8 +145,6 @@ func (p *FirstPlugin) Message(message msg.Message) bool {
|
||||||
msg := strings.ToLower(message.Body)
|
msg := strings.ToLower(message.Body)
|
||||||
if r.Replace(msg) == "whos on first" {
|
if r.Replace(msg) == "whos on first" {
|
||||||
p.announceFirst(message)
|
p.announceFirst(message)
|
||||||
log.Printf("Disallowing %s: %s from first.",
|
|
||||||
message.User.Name, message.Body)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ func (p *FirstPlugin) recordFirst(message msg.Message) {
|
||||||
body: message.Body,
|
body: message.Body,
|
||||||
nick: message.User.Name,
|
nick: message.User.Name,
|
||||||
}
|
}
|
||||||
|
log.Printf("recordFirst: %+v", p.First.day)
|
||||||
err := p.First.save(p.db)
|
err := p.First.save(p.db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error saving first entry: ", err)
|
log.Println("Error saving first entry: ", err)
|
||||||
|
|
Loading…
Reference in New Issue