Added a say command to talker

This commit is contained in:
Chris Sexton 2013-03-04 10:43:23 -05:00
parent 7f4c9cf311
commit 84e7001165
2 changed files with 9 additions and 6 deletions

View File

@ -3,13 +3,12 @@ package bot
import ( import (
"errors" "errors"
"fmt" "fmt"
"labix.org/v2/mgo/bson"
"math/rand" "math/rand"
"regexp"
"strconv" "strconv"
"strings" "strings"
"time" "time"
// "labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"regexp"
) )
import irc "github.com/fluffle/goirc/client" import irc "github.com/fluffle/goirc/client"

View File

@ -49,12 +49,18 @@ func NewTalkerPlugin(bot *bot.Bot) *TalkerPlugin {
func (p *TalkerPlugin) Message(message bot.Message) bool { func (p *TalkerPlugin) Message(message bot.Message) bool {
channel := message.Channel channel := message.Channel
body := message.Body body := message.Body
lowermessage := strings.ToLower(body)
if channel != p.Bot.Config.MainChannel { if channel != p.Bot.Config.MainChannel {
return false return false
} }
if strings.HasPrefix(message.Body, "goatse") { if strings.HasPrefix(lowermessage, "say") {
msg := strings.TrimSpace(body[3:])
p.Bot.SendMessage(channel, msg)
}
if strings.HasPrefix(lowermessage, "goatse") {
nick := message.User.Name nick := message.User.Name
if parts := strings.Split(message.Body, " "); len(parts) > 1 { if parts := strings.Split(message.Body, " "); len(parts) > 1 {
nick = parts[1] nick = parts[1]
@ -75,8 +81,6 @@ func (p *TalkerPlugin) Message(message bot.Message) bool {
return true return true
} }
lowermessage := strings.ToLower(body)
if strings.Contains(lowermessage, "felps") || strings.Contains(lowermessage, "fredfelps") { if strings.Contains(lowermessage, "felps") || strings.Contains(lowermessage, "fredfelps") {
outmsg := p.Bot.Filter(message, "GOD HATES $NICK") outmsg := p.Bot.Filter(message, "GOD HATES $NICK")
p.Bot.SendMessage(channel, outmsg) p.Bot.SendMessage(channel, outmsg)