From 4d188bdf206241abbb32e878b2557a02c88bc909 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 21 Jan 2019 18:05:35 -0500 Subject: [PATCH] emojify: handle plurals again --- plugins/emojifyme/emojifyme.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/emojifyme/emojifyme.go b/plugins/emojifyme/emojifyme.go index 6805304..629174e 100644 --- a/plugins/emojifyme/emojifyme.go +++ b/plugins/emojifyme/emojifyme.go @@ -70,10 +70,18 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool { msg := strings.Replace(strings.ToLower(message.Body), "_", " ", -1) for k, v := range p.Emoji { k = strings.Replace(k, "_", " ", -1) - if strings.Contains(msg, " "+k+" ") || strings.HasPrefix(msg, k) || strings.HasSuffix(msg, k) { - emojys = append(emojys, v) - if !stringsContain(inertTokens, k) || len(k) <= 2 { - emojied++ + candidates := []string{ + k + "es", + k + "s", + } + for _, c := range candidates { + if strings.Contains(msg, " "+c+" ") || + strings.HasPrefix(msg, c) || + strings.HasSuffix(msg, c) { + emojys = append(emojys, v) + if !stringsContain(inertTokens, k) || len(k) <= 2 { + emojied++ + } } } }