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
|
iscmd := false
|
||||||
lowerMessage := strings.ToLower(message)
|
lowerMessage := strings.ToLower(message)
|
||||||
|
|
||||||
|
rex := fmt.Sprintf(`^%s\S\s.+`, botnick)
|
||||||
|
|
||||||
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {
|
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {
|
||||||
iscmd = true
|
iscmd = true
|
||||||
message = message[len(cmdc):]
|
message = message[len(cmdc):]
|
||||||
} else if strings.HasPrefix(lowerMessage, botnick) && lowerMessage[len(botnick)] != ' ' {
|
} else if match, _ := regexp.MatchString(rex, lowerMessage); match {
|
||||||
iscmd = true
|
iscmd = true
|
||||||
message = message[len(botnick):]
|
message = message[len(botnick):]
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"labix.org/v2/mgo"
|
"labix.org/v2/mgo"
|
||||||
"labix.org/v2/mgo/bson"
|
"labix.org/v2/mgo/bson"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +41,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
|
||||||
channel := message.Channel
|
channel := message.Channel
|
||||||
parts := strings.Split(message.Body, " ")
|
parts := strings.Split(message.Body, " ")
|
||||||
|
|
||||||
|
log.Println("++Message:", nick, channel, parts)
|
||||||
|
|
||||||
if len(parts) == 0 {
|
if len(parts) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -128,6 +131,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
|
||||||
itemName = nameParts[1]
|
itemName = nameParts[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("++:", subject, itemName)
|
||||||
|
|
||||||
if strings.HasSuffix(parts[0], "++") {
|
if strings.HasSuffix(parts[0], "++") {
|
||||||
// ++ those fuckers
|
// ++ those fuckers
|
||||||
item := p.update(subject, itemName, 1)
|
item := p.update(subject, itemName, 1)
|
||||||
|
|
Loading…
Reference in New Issue