Returning command check back to messy if/else. regexp was not good.

This commit is contained in:
Chris Sexton 2013-05-07 20:56:09 -04:00
parent c3c19dda5f
commit 75e2c53bd1
1 changed files with 7 additions and 4 deletions

View File

@ -90,10 +90,13 @@ func (b *Bot) isCmd(message string) (bool, string) {
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {
iscmd = true
message = message[len(cmdc):]
} else if match, _ := regexp.MatchString(rex, lowerMessage); match {
if len(message) < len(botnick) {
return false, message
}
// } else if match, _ := regexp.MatchString(rex, lowerMessage); match {
} else if strings.HasPrefix(lowerMessage, botnick) &&
len(lowerMessage) > len(botnick) &&
(lowerMessage[len(botnick)] == ',' ||
lowerMessage[len(botnick)] == ':') &&
lowerMessage[len(botnick)+1] == ' ' {
iscmd = true
message = message[len(botnick):]