mirror of https://github.com/velour/catbase.git
emojifyme Chance weighted on number of emojies
The chance of an emojified message being sent is now proportional to the number of emojies that can be substituted in the message.
This commit is contained in:
parent
dcd38a55ff
commit
8119df6dea
|
@ -67,21 +67,19 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rand.Float64() <= p.Bot.Config().Emojify.Chance {
|
emojied := 0.0
|
||||||
tokens := strings.Fields(strings.ToLower(message.Body))
|
tokens := strings.Fields(strings.ToLower(message.Body))
|
||||||
sendMessage := false
|
for i, token := range tokens {
|
||||||
for i, token := range tokens {
|
if _, ok := p.Emoji[token]; ok {
|
||||||
if _, ok := p.Emoji[token]; ok {
|
emojied++
|
||||||
sendMessage = true
|
tokens[i] = ":" + token + ":"
|
||||||
tokens[i] = ":" + token + ":"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if sendMessage {
|
|
||||||
modified := strings.Join(tokens, " ")
|
|
||||||
p.Bot.SendMessage(message.Channel, modified)
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if emojied > 0 && rand.Float64() <= p.Bot.Config().Emojify.Chance*emojied {
|
||||||
|
modified := strings.Join(tokens, " ")
|
||||||
|
p.Bot.SendMessage(message.Channel, modified)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue