From 592adfb482562f2318ab1a77aac847e4d54b91b4 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 13 Sep 2013 23:27:11 -0400 Subject: [PATCH] Adding the fucking switcher --- plugins/your.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/your.go b/plugins/your.go index 171ed3a..b7db249 100644 --- a/plugins/your.go +++ b/plugins/your.go @@ -1,6 +1,7 @@ package plugins import ( + "log" "math/rand" "strings" "time" @@ -14,6 +15,7 @@ type YourPlugin struct { // NewYourPlugin creates a new YourPlugin with the Plugin interface func NewYourPlugin(bot *bot.Bot) *YourPlugin { + rand.Seed(time.Now().Unix()) return &YourPlugin{ Bot: bot, } @@ -24,8 +26,18 @@ func NewYourPlugin(bot *bot.Bot) *YourPlugin { // Otherwise, the function returns false and the bot continues execution of other plugins. func (p *YourPlugin) Message(message bot.Message) bool { lower := strings.ToLower(message.Body) - if strings.Contains(lower, "your") || strings.Contains(lower, "you're") { + if strings.Contains(message.Body, "the fucking") { // let's not mess with case + log.Println("Found a fucking") if rand.Float64() < 0.2 { + log.Println("Replacing a fucking") + r := strings.NewReplacer("the fucking", "fucking the") + 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() < 0.15 { r := strings.NewReplacer("Your", "You're", "your", "you're", "You're", "Your", "you're", "your", "Youre", "Your", "youre", "your") msg := r.Replace(message.Body) @@ -36,13 +48,6 @@ func (p *YourPlugin) Message(message bot.Message) bool { return false } -// LoadData imports any configuration data into the plugin. This is not strictly necessary other -// than the fact that the Plugin interface demands it exist. This may be deprecated at a later -// date. -func (p *YourPlugin) LoadData() { - rand.Seed(time.Now().Unix()) -} - // Help responds to help requests. Every plugin must implement a help function. func (p *YourPlugin) Help(channel string, parts []string) { p.Bot.SendMessage(channel, "Your corrects people's grammar.")