diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index abd5c3f..1845d16 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -135,7 +135,19 @@ func (p *CounterPlugin) Message(message msg.Message) bool { return false } - if message.Command && message.Body == "reset me" { + if strings.ToLower(message.Body) == "tea. earl grey. hot." { + item, err := GetItem(p.DB, nick, "🍵") + if err != nil { + log.Printf("Error finding item %s.%s: %s.", nick, "🍵", err) + // Item ain't there, I guess + return false + } + log.Printf("About to update item: %#v", item) + item.UpdateDelta(1) + p.Bot.SendMessage(channel, fmt.Sprintf("bleep-bloop-blop... %s has %d 🍵", + nick, item.Count)) + return true + } else if message.Command && message.Body == "reset me" { items, err := GetItems(p.DB, strings.ToLower(nick)) if err != nil { log.Printf("Error getting items to reset %s: %s", nick, err) diff --git a/plugins/counter/counter_test.go b/plugins/counter/counter_test.go index 189458a..6e928a8 100644 --- a/plugins/counter/counter_test.go +++ b/plugins/counter/counter_test.go @@ -26,6 +26,17 @@ func makeMessage(payload string) msg.Message { } } +func TestTeaEarlGreyHot(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + assert.NotNil(t, c) + c.Message(makeMessage("Tea. Earl Grey. Hot.")) + c.Message(makeMessage("Tea. Earl Grey. Hot.")) + item, err := GetItem(mb.DB(), "tester", "🍵") + assert.Nil(t, err) + assert.Equal(t, 2, item.Count) +} + func TestResetMe(t *testing.T) { mb := bot.NewMockBot() c := New(mb)