From 25f32918b1978883cc1457bd6980af24de8c9f9a Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 15 Jan 2016 09:43:31 -0500 Subject: [PATCH] Improve talker to disable nick length constraints --- config/config.go | 1 + plugins/talker.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 88bab45..f9a02c1 100644 --- a/config/config.go +++ b/config/config.go @@ -28,6 +28,7 @@ type Config struct { UntappdToken string UntappdFreq int UntappdChannels []string + EnforceNicks bool WelcomeMsgs []string TwitterConsumerKey string TwitterConsumerSecret string diff --git a/plugins/talker.go b/plugins/talker.go index cc68189..b3d5d51 100644 --- a/plugins/talker.go +++ b/plugins/talker.go @@ -4,10 +4,11 @@ package plugins import ( "fmt" - "github.com/chrissexton/alepale/bot" "math/rand" "strings" "time" + + "github.com/chrissexton/alepale/bot" ) var goatse []string = []string{ @@ -39,12 +40,14 @@ var goatse []string = []string{ } type TalkerPlugin struct { - Bot *bot.Bot + Bot *bot.Bot + enforceNicks bool } func NewTalkerPlugin(bot *bot.Bot) *TalkerPlugin { return &TalkerPlugin{ - Bot: bot, + Bot: bot, + enforceNicks: bot.Config.EnforceNicks, } } @@ -53,6 +56,7 @@ func (p *TalkerPlugin) Message(message bot.Message) bool { body := message.Body lowermessage := strings.ToLower(body) + // TODO: This ought to be space split afterwards to remove any punctuation if strings.HasPrefix(lowermessage, "say") { msg := strings.TrimSpace(body[3:]) p.Bot.SendMessage(channel, msg) @@ -73,7 +77,7 @@ func (p *TalkerPlugin) Message(message bot.Message) bool { return true } - if len(message.User.Name) != 9 { + if p.enforceNicks && 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)