Merge pull request #70 from velour/control_emojify

emojify: configurize the chance
This commit is contained in:
Chris Sexton 2017-07-25 14:45:14 -04:00 committed by GitHub
commit dcd38a55ff
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 {