From 148f9635a0943358dbafc898725114578367adad Mon Sep 17 00:00:00 2001 From: cws Date: Mon, 24 Jul 2017 07:37:33 -0400 Subject: [PATCH] counter: Change regex to be more accepting Fixes #66 --- plugins/counter/counter.go | 2 +- plugins/counter/counter_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index cac69d0..ebe51b0 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { return false } - if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. ((hot)|(iced))\\.?$", message.Body); tea { + if tea, _ := regexp.MatchString("(?i)^tea\\. [^.]*\\. ((hot)|(iced))\\.?$", 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 b0b233a..868de7b 100644 --- a/plugins/counter/counter_test.go +++ b/plugins/counter/counter_test.go @@ -69,6 +69,15 @@ func TestTeaSkieselQuote(t *testing.T) { assert.Nil(t, err) assert.Equal(t, 0, item.Count) } +func TestTeaUnicodeJapanese(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + assert.NotNil(t, c) + c.Message(makeMessage("Tea. ใŠใกใ‚„. Hot.")) + item, err := GetItem(mb.DB(), "tester", ":tea:") + assert.Nil(t, err) + assert.Equal(t, 1, item.Count) +} func TestResetMe(t *testing.T) { mb := bot.NewMockBot()