mirror of https://github.com/velour/catbase.git
commit
c82d32e460
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue