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
|
DBPath string
|
||||||
Sightings []string
|
Sightings []string
|
||||||
}
|
}
|
||||||
|
Emojify struct {
|
||||||
|
Chance float64
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -71,5 +71,8 @@
|
||||||
"Stats": {
|
"Stats": {
|
||||||
"DBPath": "stats.db",
|
"DBPath": "stats.db",
|
||||||
"Sightings": ["user"]
|
"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))
|
tokens := strings.Fields(strings.ToLower(message.Body))
|
||||||
sendMessage := false
|
sendMessage := false
|
||||||
for i, token := range tokens {
|
for i, token := range tokens {
|
||||||
|
|
Loading…
Reference in New Issue