Fix goatse in talker

Note: This makes the goatse very Slack specific with preformatting and
newlines.
This commit is contained in:
Chris Sexton 2016-03-25 15:10:56 -04:00
parent 3cdb40ab5c
commit 0e69e58ff5
2 changed files with 7 additions and 5 deletions

View File

@ -46,7 +46,7 @@ func main() {
// b.AddHandler("first", plugins.NewFirstPlugin(b)) // b.AddHandler("first", plugins.NewFirstPlugin(b))
b.AddHandler("leftpad", leftpad.New(b)) b.AddHandler("leftpad", leftpad.New(b))
b.AddHandler("downtime", downtime.NewDowntimePlugin(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("dice", dice.NewDicePlugin(b))
b.AddHandler("beers", beers.NewBeersPlugin(b)) b.AddHandler("beers", beers.NewBeersPlugin(b))
b.AddHandler("counter", counter.NewCounterPlugin(b)) b.AddHandler("counter", counter.NewCounterPlugin(b))

View File

@ -12,7 +12,7 @@ import (
) )
var goatse []string = []string{ 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", "g g",
"o / \\ \\ / \\ o", "o / \\ \\ / \\ o",
"a| | \\ | | a", "a| | \\ | | a",
@ -36,7 +36,7 @@ var goatse []string = []string{
"s | / / \\__/\\___/ | |s", "s | / / \\__/\\___/ | |s",
"e | / | | | |e", "e | / | | | |e",
"x | | | | | |x", "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 { type TalkerPlugin struct {
@ -44,7 +44,7 @@ type TalkerPlugin struct {
enforceNicks bool enforceNicks bool
} }
func NewTalkerPlugin(bot *bot.Bot) *TalkerPlugin { func New(bot *bot.Bot) *TalkerPlugin {
return &TalkerPlugin{ return &TalkerPlugin{
Bot: bot, Bot: bot,
enforceNicks: bot.Config.EnforceNicks, enforceNicks: bot.Config.EnforceNicks,
@ -69,11 +69,13 @@ func (p *TalkerPlugin) Message(message bot.Message) bool {
nick = parts[1] nick = parts[1]
} }
output := ""
for _, line := range goatse { for _, line := range goatse {
nick = fmt.Sprintf("%9.9s", nick) nick = fmt.Sprintf("%9.9s", nick)
line = strings.Replace(line, "{nick}", nick, 1) line = strings.Replace(line, "{nick}", nick, 1)
p.Bot.SendMessage(channel, line) output += line + "\n"
} }
p.Bot.SendMessage(channel, output)
return true return true
} }