emojify: handle plurals again

This commit is contained in:
Chris Sexton 2019-01-21 18:05:35 -05:00
parent 36320df725
commit 4d188bdf20
1 changed files with 12 additions and 4 deletions

View File

@ -70,10 +70,18 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool {
msg := strings.Replace(strings.ToLower(message.Body), "_", " ", -1) msg := strings.Replace(strings.ToLower(message.Body), "_", " ", -1)
for k, v := range p.Emoji { for k, v := range p.Emoji {
k = strings.Replace(k, "_", " ", -1) k = strings.Replace(k, "_", " ", -1)
if strings.Contains(msg, " "+k+" ") || strings.HasPrefix(msg, k) || strings.HasSuffix(msg, k) { candidates := []string{
emojys = append(emojys, v) k + "es",
if !stringsContain(inertTokens, k) || len(k) <= 2 { k + "s",
emojied++ }
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++
}
} }
} }
} }