Fixed tea regex to fix bad matches that ended in iced

Added a test based on skiesel's quote that triggered it.
This commit is contained in:
svohr 2017-02-20 11:57:12 -08:00
parent 6917e091af
commit ae3a4eee52
2 changed files with 11 additions and 1 deletions

View File

@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
return false return false
} }
if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. (hot)|(iced)\\.?$", message.Body); tea { if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
item, err := GetItem(p.DB, nick, "🍵") item, err := GetItem(p.DB, nick, "🍵")
if err != nil { if err != nil {
log.Printf("Error finding item %s.%s: %s.", nick, "🍵", err) log.Printf("Error finding item %s.%s: %s.", nick, "🍵", err)

View File

@ -60,6 +60,16 @@ func TestTeaUnrelated(t *testing.T) {
assert.Equal(t, 0, item.Count) assert.Equal(t, 0, item.Count)
} }
func TestTeaSkieselQuote(t *testing.T) {
mb := bot.NewMockBot()
c := New(mb)
assert.NotNil(t, c)
c.Message(makeMessage("blah, this is a whole page of explanation where \"we did local search and used a tabu list\" would have sufficed"))
item, err := GetItem(mb.DB(), "tester", "🍵")
assert.Nil(t, err)
assert.Equal(t, 0, item.Count)
}
func TestResetMe(t *testing.T) { func TestResetMe(t *testing.T) {
mb := bot.NewMockBot() mb := bot.NewMockBot()
c := New(mb) c := New(mb)