2012-08-17 22:09:29 +00:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
2012-08-17 22:17:39 +00:00
|
|
|
"bitbucket.org/phlyingpenguin/godeepintir/bot"
|
2012-08-25 04:46:13 +00:00
|
|
|
"fmt"
|
2012-08-25 04:54:03 +00:00
|
|
|
"math/rand"
|
2012-08-25 04:49:48 +00:00
|
|
|
"strings"
|
2012-08-25 04:54:03 +00:00
|
|
|
"time"
|
2012-08-17 22:09:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type TalkerPlugin struct {
|
|
|
|
Bot *bot.Bot
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTalkerPlugin(bot *bot.Bot) *TalkerPlugin {
|
|
|
|
return &TalkerPlugin{
|
|
|
|
Bot: bot,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *TalkerPlugin) Message(message bot.Message) bool {
|
|
|
|
channel := message.Channel
|
|
|
|
body := message.Body
|
|
|
|
|
|
|
|
if channel != p.Bot.Config.MainChannel {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2012-08-25 04:58:36 +00:00
|
|
|
if len(message.User.Name) != 9 {
|
|
|
|
msg := fmt.Sprintf("Hey %s, we really like to have 9 character nicks because we're crazy OCD and stuff.",
|
|
|
|
message.User.Name)
|
|
|
|
p.Bot.SendMessage(message.Channel, msg)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2012-08-17 22:09:29 +00:00
|
|
|
lowermessage := strings.ToLower(body)
|
|
|
|
|
|
|
|
if strings.Contains(lowermessage, "felps") || strings.Contains(lowermessage, "fredfelps") {
|
|
|
|
outmsg := p.Bot.Filter(message, "GOD HATES $NICK")
|
|
|
|
p.Bot.SendMessage(channel, outmsg)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *TalkerPlugin) LoadData() {
|
2012-08-25 04:54:03 +00:00
|
|
|
rand.Seed(time.Now().Unix())
|
2012-08-17 22:09:29 +00:00
|
|
|
}
|
2012-08-17 22:56:44 +00:00
|
|
|
|
|
|
|
func (p *TalkerPlugin) Help(channel string, parts []string) {
|
|
|
|
p.Bot.SendMessage(channel, "Hi, this is talker. I like to talk about FredFelps!")
|
|
|
|
}
|
2012-08-25 04:46:13 +00:00
|
|
|
|
|
|
|
// Empty event handler because this plugin does not do anything on event recv
|
2012-08-25 04:49:48 +00:00
|
|
|
func (p *TalkerPlugin) Event(kind string, message bot.Message) bool {
|
2013-01-22 21:14:04 +00:00
|
|
|
if kind == "JOIN" && strings.ToLower(message.User.Name) != strings.ToLower(p.Bot.Config.Nick) {
|
2013-01-12 16:32:42 +00:00
|
|
|
sayings := p.Bot.Config.WelcomeMsgs
|
2012-08-25 04:54:03 +00:00
|
|
|
msg := fmt.Sprintf(sayings[rand.Intn(len(sayings))], message.User.Name)
|
2012-08-25 04:46:13 +00:00
|
|
|
p.Bot.SendMessage(message.Channel, msg)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|