diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index 790396b..f3ca7fe 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -240,7 +240,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { } p.Bot.SendMessage(channel, out) return true - } else if tea, _ := regexp.MatchString("(?i)^tea\\. [^.]*\\. ((hot)|(iced))\\.?$", message.Body); tea { + } else if tea, _ := regexp.MatchString("(?i)^tea\\. [^.]*\\. ([^.]*\\.?)+$", message.Body); tea { item, err := GetItem(p.DB, nick, ":tea:") if err != nil { log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err) diff --git a/plugins/counter/counter_test.go b/plugins/counter/counter_test.go index a83b6aa..91f1ad6 100644 --- a/plugins/counter/counter_test.go +++ b/plugins/counter/counter_test.go @@ -37,6 +37,28 @@ func TestTeaEarlGreyHot(t *testing.T) { assert.Equal(t, 2, item.Count) } +func TestTeaTwoPeriods(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + assert.NotNil(t, c) + c.Message(makeMessage("Tea. Earl Grey.")) + c.Message(makeMessage("Tea. Earl Grey.")) + item, err := GetItem(mb.DB(), "tester", ":tea:") + assert.Nil(t, err) + assert.Equal(t, 0, item.Count) +} + +func TestTeaMultiplePeriods(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + assert.NotNil(t, c) + c.Message(makeMessage("Tea. Earl Grey. Spiked. Hot.")) + c.Message(makeMessage("Tea. Earl Grey. Spiked. Hot.")) + item, err := GetItem(mb.DB(), "tester", ":tea:") + assert.Nil(t, err) + assert.Equal(t, 2, item.Count) +} + func TestTeaGreenHot(t *testing.T) { mb := bot.NewMockBot() c := New(mb)