Fix number of fields for counter inventory

Fixes #11
This commit is contained in:
Chris Sexton 2016-03-13 10:13:41 -04:00
parent 624d96a10c
commit d7056e3ec7
1 changed files with 6 additions and 2 deletions

View File

@ -66,8 +66,9 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
subject = parts[1] subject = parts[1]
} }
log.Printf("Getting counter for %s", subject)
// pull all of the items associated with "subject" // pull all of the items associated with "subject"
rows, err := p.DB.Query(`select * from counter where nick = ?`, subject) rows, err := p.DB.Query(`select nick, item, count from counter where nick = ?`, subject)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -77,7 +78,10 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
for rows.Next() { for rows.Next() {
count += 1 count += 1
var it Item var it Item
rows.Scan(&it.Nick, &it.Item, &it.Count) err := rows.Scan(&it.Nick, &it.Item, &it.Count)
if err != nil {
log.Printf("Error getting counter: %s", err)
}
if count > 1 { if count > 1 {
resp = fmt.Sprintf("%s, ", resp) resp = fmt.Sprintf("%s, ", resp)