From 19754a07a59b9832673b7c336f6e01ec935152b3 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Wed, 11 May 2016 12:10:15 -0400 Subject: [PATCH] Change Splits to Fields where appropriate --- plugins/counter/counter.go | 2 +- plugins/fact/factoid.go | 2 +- plugins/fact/remember.go | 2 +- plugins/leftpad/leftpad.go | 2 +- plugins/talker/talker.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/counter/counter.go b/plugins/counter/counter.go index cc86a15..d77e013 100644 --- a/plugins/counter/counter.go +++ b/plugins/counter/counter.go @@ -128,7 +128,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool { // This bot does not reply to anything nick := message.User.Name channel := message.Channel - parts := strings.Split(message.Body, " ") + parts := strings.Fields(message.Body) if len(parts) == 0 { return false diff --git a/plugins/fact/factoid.go b/plugins/fact/factoid.go index 385dca2..ef1f1db 100644 --- a/plugins/fact/factoid.go +++ b/plugins/fact/factoid.go @@ -659,7 +659,7 @@ func (p *Factoid) RegisterWeb() *string { } func linkify(text string) template.HTML { - parts := strings.Split(text, " ") + parts := strings.Fields(text) for i, word := range parts { if strings.HasPrefix(word, "http") { parts[i] = fmt.Sprintf("%s", word, word) diff --git a/plugins/fact/remember.go b/plugins/fact/remember.go index f6064d2..e4fc6bd 100644 --- a/plugins/fact/remember.go +++ b/plugins/fact/remember.go @@ -47,7 +47,7 @@ func (p *RememberPlugin) Message(message msg.Message) bool { } user := message.User - parts := strings.Split(message.Body, " ") + parts := strings.Fields(message.Body) if message.Command && len(parts) >= 3 && strings.ToLower(parts[0]) == "remember" { diff --git a/plugins/leftpad/leftpad.go b/plugins/leftpad/leftpad.go index 338d704..6beb410 100644 --- a/plugins/leftpad/leftpad.go +++ b/plugins/leftpad/leftpad.go @@ -37,7 +37,7 @@ func (p *LeftpadPlugin) Message(message msg.Message) bool { return false } - parts := strings.Split(message.Body, " ") + parts := strings.Fields(message.Body) if len(parts) > 3 && parts[0] == "leftpad" { padchar := parts[1] length, err := strconv.Atoi(parts[2]) diff --git a/plugins/talker/talker.go b/plugins/talker/talker.go index e5713d6..1e01b90 100644 --- a/plugins/talker/talker.go +++ b/plugins/talker/talker.go @@ -69,7 +69,7 @@ func (p *TalkerPlugin) Message(message msg.Message) bool { if message.Command && strings.HasPrefix(lowermessage, "goatse") { nick := message.User.Name - if parts := strings.Split(message.Body, " "); len(parts) > 1 { + if parts := strings.Fields(message.Body); len(parts) > 1 { nick = parts[1] }