From e08cb2faf7f0bebff4dd656a54c1f28944c88d25 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Tue, 11 Feb 2014 04:00:35 -0500 Subject: [PATCH] Makes the lib line up more with the irc rfc in message vs args handling --- irc.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/irc.go b/irc.go index 63146bc..90d52b8 100644 --- a/irc.go +++ b/irc.go @@ -67,7 +67,18 @@ func (irc *Connection) readLoop() { } } - args := strings.SplitN(msg, " :", 2) + split := strings.SplitN(msg, " :", 2) + args := strings.Split(split[0], " ") + event.Code = strings.ToUpper(args[0]) + event.Arguments = args[1:] + if len(split) > 1 { + event.Arguments = append(event.Arguments, split[1]) + } + if len(event.Arguments) > 0 { + event.Message = event.Arguments[len(event.Arguments)-1] + } + + /*args := strings.SplitN(msg, " :", 2) if len(args) > 1 { event.Message = args[1] } @@ -77,7 +88,8 @@ func (irc *Connection) readLoop() { if len(args) > 1 { event.Arguments = args[1:len(args)] - } + }*/ + /* XXX: len(args) == 0: args should be empty */ irc.RunCallbacks(event)