diff --git a/config.json b/config.json index 7f6ae43..62538ae 100644 --- a/config.json +++ b/config.json @@ -26,5 +26,8 @@ "Joins upset the hivemind's OCD, %s.", "Joins upset the hivemind's CDO, %s.", "%s, I WILL CUT YOU!" + ], + "BadMsgs": [ + "I like cron." ] } diff --git a/config/config.go b/config/config.go index 6a45c86..53f88aa 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,7 @@ type Config struct { TwitterConsumerSecret string TwitterUserKey string TwitterUserSecret string + BadMsgs []string } // Readconfig loads the config data out of a JSON file located in cfile diff --git a/plugins/first.go b/plugins/first.go index 9b9eaeb..495aee8 100644 --- a/plugins/first.go +++ b/plugins/first.go @@ -60,10 +60,11 @@ func isToday(t time.Time) bool { func (p *FirstPlugin) Message(message bot.Message) bool { // This bot does not reply to anything - if p.First == nil { + if p.First == nil && p.allowed(message) { p.recordFirst(message) - } else { - if isToday(p.First.Time) { + return false + } else if p.First != nil { + if isToday(p.First.Time) && p.allowed(message) { p.recordFirst(message) return false } @@ -74,12 +75,24 @@ func (p *FirstPlugin) Message(message bot.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 } return false } +func (p *FirstPlugin) allowed(message bot.Message) bool { + for _, msg := range p.Bot.Config.BadMsgs { + if strings.ToLower(msg) == strings.ToLower(message.Body) { + log.Println("Disallowing first: ", message.User.Name, ":", message.Body) + return false + } + } + return true +} + func (p *FirstPlugin) recordFirst(message bot.Message) { log.Println("Recording first: ", message.User.Name, ":", message.Body) p.First = &FirstEntry{