This commit is contained in:
Chris Sexton 2013-03-18 17:29:19 -04:00
parent 80295590af
commit 340b7ee1ae
1 changed files with 1 additions and 3 deletions

View File

@ -1,9 +1,9 @@
package plugins package plugins
import ( import (
"fmt"
"math/rand" "math/rand"
"strings" "strings"
"time"
"bitbucket.org/phlyingpenguin/godeepintir/bot" "bitbucket.org/phlyingpenguin/godeepintir/bot"
) )
@ -23,14 +23,12 @@ func NewYourPlugin(bot *bot.Bot) *YourPlugin {
// This function returns true if the plugin responds in a meaningful way to the users message. // This function returns true if the plugin responds in a meaningful way to the users message.
// Otherwise, the function returns false and the bot continues execution of other plugins. // Otherwise, the function returns false and the bot continues execution of other plugins.
func (p *YourPlugin) Message(message bot.Message) bool { func (p *YourPlugin) Message(message bot.Message) bool {
fmt.Println("Your got a message!")
lower := strings.ToLower(message.Body) lower := strings.ToLower(message.Body)
if strings.Contains(lower, "your") || strings.Contains(lower, "you're") { if strings.Contains(lower, "your") || strings.Contains(lower, "you're") {
if rand.Float64() < 0.2 { if rand.Float64() < 0.2 {
r := strings.NewReplacer("Your", "You're", "your", "you're", "You're", r := strings.NewReplacer("Your", "You're", "your", "you're", "You're",
"Your", "you're", "your", "Youre", "Your", "youre", "your") "Your", "you're", "your", "Youre", "Your", "youre", "your")
msg := r.Replace(message.Body) msg := r.Replace(message.Body)
fmt.Println(msg)
p.Bot.SendMessage(message.Channel, msg) p.Bot.SendMessage(message.Channel, msg)
return true return true
} }