From f2309b9090920146be409fa3517a368afed21311 Mon Sep 17 00:00:00 2001 From: skkiesel Date: Mon, 13 Mar 2017 12:41:17 -0400 Subject: [PATCH] give catbase some negative back talk --- config/config.go | 1 + example_config.json | 1 + plugins/your/your.go | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/config/config.go b/config/config.go index 21c1129..7c98730 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,7 @@ type Config struct { YourChance float64 FuckingChance float64 DuckingChance float64 + NegativeChance float64 MaxLength int } LeftPad struct { diff --git a/example_config.json b/example_config.json index 63b28b0..4774f6c 100644 --- a/example_config.json +++ b/example_config.json @@ -48,6 +48,7 @@ "YourChance": 0.4, "FuckingChance": 0.15, "DuckingChance": 0.5, + "NegativeChance": 0.5, "MaxLength": 140 }, "LeftPad": { diff --git a/plugins/your/your.go b/plugins/your/your.go index 7342f7d..50a36a2 100644 --- a/plugins/your/your.go +++ b/plugins/your/your.go @@ -63,6 +63,26 @@ func (p *YourPlugin) Message(message msg.Message) bool { return true } } + if strings.Contains(message.Body, " is ") { + log.Println("Found an is") + if rand.Float64() < config.NegativeChance { + log.Println("Replacing an is") + r := strings.NewReplacer(" is ", " is not ") + msg := r.Replace(message.Body) + p.bot.SendMessage(message.Channel, msg) + return true + } + } + if strings.Contains(message.Body, " are ") { + log.Println("Found an are") + if rand.Float64() < config.NegativeChance { + log.Println("Replacing an are") + r := strings.NewReplacer(" are ", " are not ") + msg := r.Replace(message.Body) + p.bot.SendMessage(message.Channel, msg) + return true + } + } return false }