From c261b53ae6bcd4ffd58c40ae7e2fa9c93bab2011 Mon Sep 17 00:00:00 2001 From: Steve McCoy Date: Mon, 23 Jan 2017 10:10:54 -0500 Subject: [PATCH] Fix obvious problems --- plugins/counter/counter.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index 2ca7ff3..32f9b6e 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -6,6 +6,7 @@ import ( "database/sql" "fmt" "log" + "strconv" "strings" "github.com/jmoiron/sqlx" @@ -274,7 +275,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { } subject := strings.ToLower(nick) - itemName := strings.ToLower(parts[0])[:len(parts[0])-2] + itemName := strings.ToLower(parts[0]) if nameParts := strings.SplitN(itemName, ".", 2); len(nameParts) == 2 { subject = nameParts[0] @@ -289,7 +290,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { // Item ain't there, I guess return false } - n := strconv.Atoi(parts[2]) + n, _ := strconv.Atoi(parts[2]) log.Printf("About to update item by %d: %#v", n, item) item.UpdateDelta(n) p.Bot.SendMessage(channel, fmt.Sprintf("%s has %d %s.", subject, @@ -303,7 +304,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { // Item ain't there, I guess return false } - n := strconv.Atoi(parts[2]) + n, _ := strconv.Atoi(parts[2]) log.Printf("About to update item by -%d: %#v", n, item) item.UpdateDelta(-n) p.Bot.SendMessage(channel, fmt.Sprintf("%s has %d %s.", subject,