emojify: configurize the chance

This commit is contained in:
cws 2017-07-25 14:44:36 -04:00
parent 9264febfbe
commit f004cecf3a
3 changed files with 7 additions and 1 deletions

View File

@ -89,6 +89,9 @@ type Config struct {
DBPath string
Sightings []string
}
Emojify struct {
Chance float64
}
}
func init() {

View File

@ -71,5 +71,8 @@
"Stats": {
"DBPath": "stats.db",
"Sightings": ["user"]
},
"Emojify": {
"Chance": 0.02
}
}

View File

@ -67,7 +67,7 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool {
}
}
if rand.Intn(10) == 0 {
if rand.Float64() <= p.Bot.Config().Emojify.Chance {
tokens := strings.Fields(strings.ToLower(message.Body))
sendMessage := false
for i, token := range tokens {