From 5b3784a9edffda4e89d26105d04a72f0957f2ac1 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 17 Aug 2012 22:53:39 -0400 Subject: [PATCH] Fixed error with beers and reporting a particular users' beers --- plugins/beers.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/beers.go b/plugins/beers.go index 2d72b12..813c54a 100644 --- a/plugins/beers.go +++ b/plugins/beers.go @@ -76,13 +76,7 @@ func (p *BeersPlugin) Message(message bot.Message) bool { count, err := strconv.Atoi(parts[2]) if err != nil { // if it's not a number, maybe it's a nick! - if p.doIKnow(parts[2]) { - p.reportCount(parts[2], channel, false) - } else { - msg := fmt.Sprintf("Sorry, I don't know %s.", parts[2]) - p.Bot.SendMessage(channel, msg) - return true - } + p.Bot.SendMessage(channel, "Sorry, that didn't make any sense.") } if count < 0 { @@ -103,6 +97,13 @@ func (p *BeersPlugin) Message(message bot.Message) bool { } else { p.Bot.SendMessage(channel, "I don't know your math.") } + } else if len(parts) == 2 { + if p.doIKnow(parts[1]) { + p.reportCount(parts[1], channel, false) + } else { + msg := fmt.Sprintf("Sorry, I don't know %s.", parts[1]) + p.Bot.SendMessage(channel, msg) + } } else if len(parts) == 1 { p.reportCount(nick, channel, true) } @@ -159,7 +160,11 @@ func (p *BeersPlugin) reportCount(nick, channel string, himself bool) { beers := p.getBeers(nick) msg := fmt.Sprintf("%s has had %d beers so far.", nick, beers) if himself { - msg = fmt.Sprintf("You've had %d beers so far, %s.", beers, nick) + if beers == 0 { + msg = fmt.Sprintf("You really need to get drinkin, %s!", nick) + } else { + msg = fmt.Sprintf("You've had %d beers so far, %s.", beers, nick) + } } p.Bot.SendMessage(channel, msg) fmt.Println("I should have reported a beer count!")