mirror of https://github.com/velour/catbase.git
emojify: handle plurals again
This commit is contained in:
parent
36320df725
commit
4d188bdf20
|
@ -70,13 +70,21 @@ 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) {
|
||||
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++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if emojied > 0 && rand.Float64() <= p.Bot.Config().GetFloat64("Emojify.Chance")*emojied {
|
||||
for _, e := range emojys {
|
||||
|
|
Loading…
Reference in New Issue