mirror of https://github.com/velour/catbase.git
Making the counters aware of the bot itself.
This commit is contained in:
parent
e8ff495c2f
commit
46fa81cd68
|
@ -84,10 +84,12 @@ func (b *Bot) isCmd(message string) (bool, string) {
|
|||
iscmd := false
|
||||
lowerMessage := strings.ToLower(message)
|
||||
|
||||
rex := fmt.Sprintf(`^%s\S\s.+`, botnick)
|
||||
|
||||
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {
|
||||
iscmd = true
|
||||
message = message[len(cmdc):]
|
||||
} else if strings.HasPrefix(lowerMessage, botnick) && lowerMessage[len(botnick)] != ' ' {
|
||||
} else if match, _ := regexp.MatchString(rex, lowerMessage); match {
|
||||
iscmd = true
|
||||
message = message[len(botnick):]
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"labix.org/v2/mgo"
|
||||
"labix.org/v2/mgo/bson"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -40,6 +41,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
|
|||
channel := message.Channel
|
||||
parts := strings.Split(message.Body, " ")
|
||||
|
||||
log.Println("++Message:", nick, channel, parts)
|
||||
|
||||
if len(parts) == 0 {
|
||||
return false
|
||||
}
|
||||
|
@ -128,6 +131,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
|
|||
itemName = nameParts[1]
|
||||
}
|
||||
|
||||
log.Println("++:", subject, itemName)
|
||||
|
||||
if strings.HasSuffix(parts[0], "++") {
|
||||
// ++ those fuckers
|
||||
item := p.update(subject, itemName, 1)
|
||||
|
|
Loading…
Reference in New Issue