mirror of https://github.com/velour/catbase.git
emojify: handle plurals again
This commit is contained in:
parent
36320df725
commit
4d188bdf20
|
@ -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++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue