From 0e69e58ff546cd4273639cb23e984bfb72cc6c5e Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 25 Mar 2016 15:10:56 -0400 Subject: [PATCH] Fix goatse in talker Note: This makes the goatse very Slack specific with preformatting and newlines. --- main.go | 2 +- plugins/talker/talker.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 69b04d9..97b9960 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ func main() { // b.AddHandler("first", plugins.NewFirstPlugin(b)) b.AddHandler("leftpad", leftpad.New(b)) b.AddHandler("downtime", downtime.NewDowntimePlugin(b)) - b.AddHandler("talker", talker.NewTalkerPlugin(b)) + b.AddHandler("talker", talker.New(b)) b.AddHandler("dice", dice.NewDicePlugin(b)) b.AddHandler("beers", beers.NewBeersPlugin(b)) b.AddHandler("counter", counter.NewCounterPlugin(b)) diff --git a/plugins/talker/talker.go b/plugins/talker/talker.go index 2236078..ba3f79d 100644 --- a/plugins/talker/talker.go +++ b/plugins/talker/talker.go @@ -12,7 +12,7 @@ import ( ) var goatse []string = []string{ - "* g o a t s e x * g o a t s e x * g o a t s e x *", + "```* g o a t s e x * g o a t s e x * g o a t s e x *", "g g", "o / \\ \\ / \\ o", "a| | \\ | | a", @@ -36,7 +36,7 @@ var goatse []string = []string{ "s | / / \\__/\\___/ | |s", "e | / | | | |e", "x | | | | | |x", - "* g o a t s e x * g o a t s e x * g o a t s e x *", + "* g o a t s e x * g o a t s e x * g o a t s e x *```", } type TalkerPlugin struct { @@ -44,7 +44,7 @@ type TalkerPlugin struct { enforceNicks bool } -func NewTalkerPlugin(bot *bot.Bot) *TalkerPlugin { +func New(bot *bot.Bot) *TalkerPlugin { return &TalkerPlugin{ Bot: bot, enforceNicks: bot.Config.EnforceNicks, @@ -69,11 +69,13 @@ func (p *TalkerPlugin) Message(message bot.Message) bool { nick = parts[1] } + output := "" for _, line := range goatse { nick = fmt.Sprintf("%9.9s", nick) line = strings.Replace(line, "{nick}", nick, 1) - p.Bot.SendMessage(channel, line) + output += line + "\n" } + p.Bot.SendMessage(channel, output) return true }