mirror of https://github.com/velour/catbase.git
counter: make tea counter less strict
This commit is contained in:
parent
b1a4fd2050
commit
8d729f5d42
|
@ -240,7 +240,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
|
||||||
}
|
}
|
||||||
p.Bot.SendMessage(channel, out)
|
p.Bot.SendMessage(channel, out)
|
||||||
return true
|
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:")
|
item, err := GetItem(p.DB, nick, ":tea:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
||||||
|
|
|
@ -37,6 +37,28 @@ func TestTeaEarlGreyHot(t *testing.T) {
|
||||||
assert.Equal(t, 2, item.Count)
|
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) {
|
func TestTeaGreenHot(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
c := New(mb)
|
c := New(mb)
|
||||||
|
|
Loading…
Reference in New Issue