do not learn from commands to the babbler

This commit is contained in:
skiesel 2016-05-11 12:11:21 -04:00
parent e6324ad5a2
commit ac3e1da9e5
1 changed files with 11 additions and 11 deletions

View File

@ -80,9 +80,14 @@ func (p *BabblerPlugin) Message(message msg.Message) bool {
lowercase := strings.ToLower(message.Body) lowercase := strings.ToLower(message.Body)
tokens := strings.Fields(lowercase) tokens := strings.Fields(lowercase)
addToMarkovChain(p.babblers[message.User.Name], lowercase) if len(tokens) == 2 && tokens[1] == "says" {
saying := p.babble(tokens[0])
if len(tokens) == 4 && strings.Contains(lowercase, "initialize babbler for ") { if saying == "" {
p.Bot.SendMessage(message.Channel, "Ze ain't said nothin'")
}
p.Bot.SendMessage(message.Channel, saying)
return true
} else if len(tokens) == 4 && strings.Contains(lowercase, "initialize babbler for ") {
who := tokens[len(tokens)-1] who := tokens[len(tokens)-1]
if _, ok := p.babblers[who]; !ok { if _, ok := p.babblers[who]; !ok {
babbler, err := getMarkovChain(p.db, who) babbler, err := getMarkovChain(p.db, who)
@ -94,16 +99,11 @@ func (p *BabblerPlugin) Message(message msg.Message) bool {
p.Bot.SendMessage(message.Channel, "Okay.") p.Bot.SendMessage(message.Channel, "Okay.")
return true return true
} }
} else {
addToMarkovChain(p.babblers[message.User.Name], lowercase)
} }
if len(tokens) == 2 && tokens[1] == "says" {
saying := p.babble(tokens[0])
if saying == "" {
p.Bot.SendMessage(message.Channel, "Ze ain't said nothin'")
}
p.Bot.SendMessage(message.Channel, saying)
return true
}
return false return false
} }