Merge pull request #26 from velour/FieldsVsSplits

Change Splits to Fields where appropriate
This commit is contained in:
Chris Sexton 2016-05-11 12:14:41 -04:00
commit a0d0f79884
5 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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("<a href=\"%s\">%s</a>", word, word)

View File

@ -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" {

View File

@ -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])

View File

@ -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]
}