Add a ducking filter

This commit is contained in:
Chris Sexton 2016-08-30 15:40:55 -04:00
parent 2f9abf660d
commit 7b7c0dc5bb
3 changed files with 15 additions and 3 deletions

View File

@ -37,9 +37,9 @@ type Config struct {
Freq int
Channels []string
}
Twitch struct {
Freq int
Users map[string][]string //channel -> usernames
Twitch struct {
Freq int
Users map[string][]string //channel -> usernames
}
EnforceNicks bool
WelcomeMsgs []string
@ -56,6 +56,7 @@ type Config struct {
Your struct {
YourChance float64
FuckingChance float64
DuckingChance float64
MaxLength int
}
LeftPad struct {

View File

@ -47,6 +47,7 @@
"Your": {
"YourChance": 0.4,
"FuckingChance": 0.15,
"DuckingChance": 0.5,
"MaxLength": 140
},
"LeftPad": {

View File

@ -44,6 +44,16 @@ func (p *YourPlugin) Message(message msg.Message) bool {
return true
}
}
if strings.Contains(message.Body, "ducking") || strings.Contains(message.Body, "fucking") { // let's not mess with case
log.Println("Found a fucking|ducking")
if rand.Float64() < config.DuckingChance {
log.Println("Replacing a ducking")
r := strings.NewReplacer("fucking", "ducking", "ducking", "fucking")
msg := r.Replace(message.Body)
p.bot.SendMessage(message.Channel, msg)
return true
}
}
if strings.Contains(lower, "your") || strings.Contains(lower, "you're") {
if rand.Float64() < config.YourChance {
r := strings.NewReplacer("Your", "You're", "your", "you're", "You're",