From 95c8c3644794e809986059dfe51ce0dfbd86932e Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Tue, 10 Dec 2013 18:24:05 -0500 Subject: [PATCH] Make first filter a regexp --- plugins/first.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/first.go b/plugins/first.go index 5b3158d..6d24003 100644 --- a/plugins/first.go +++ b/plugins/first.go @@ -6,6 +6,7 @@ import ( "labix.org/v2/mgo" "labix.org/v2/mgo/bson" "log" + "regexp" "strings" "time" ) @@ -88,7 +89,11 @@ func (p *FirstPlugin) Message(message bot.Message) bool { func (p *FirstPlugin) allowed(message bot.Message) bool { for _, msg := range p.Bot.Config.Bad.Msgs { - if strings.ToLower(msg) == strings.ToLower(message.Body) { + match, err := regexp.MatchString(msg, strings.ToLower(message.Body)) + if err != nil { + log.Println("Bad regexp: ", err) + } + if match { log.Println("Disallowing first: ", message.User.Name, ":", message.Body) return false }