mirror of https://github.com/velour/catbase.git
Merge pull request #70 from velour/control_emojify
emojify: configurize the chance
This commit is contained in:
commit
dcd38a55ff
|
@ -89,6 +89,9 @@ type Config struct {
|
|||
DBPath string
|
||||
Sightings []string
|
||||
}
|
||||
Emojify struct {
|
||||
Chance float64
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -71,5 +71,8 @@
|
|||
"Stats": {
|
||||
"DBPath": "stats.db",
|
||||
"Sightings": ["user"]
|
||||
},
|
||||
"Emojify": {
|
||||
"Chance": 0.02
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue