mirror of https://github.com/velour/catbase.git
Make first filter a regexp
This commit is contained in:
parent
592adfb482
commit
95c8c36447
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue