Try to fix args

This commit is contained in:
Neale Pickett 2014-10-30 02:52:51 +00:00
parent 97705bc5d0
commit 2b881146d7
1 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"logfile" "logfile"
"net" "net"
"os" "os"
"strconv"
"strings" "strings"
"time" "time"
) )
@ -114,7 +115,6 @@ func parse(v string) (Message, error) {
m.FullSender = "." m.FullSender = "."
m.Forum = "." m.Forum = "."
m.Sender = "." m.Sender = "."
m.Args = parts
parts = strings.Split(lhs, " ") parts = strings.Split(lhs, " ")
if parts[0][0] == ':' { if parts[0][0] == ':' {
@ -140,6 +140,7 @@ func parse(v string) (Message, error) {
} }
case "PART", "MODE", "TOPIC", "KICK": case "PART", "MODE", "TOPIC", "KICK":
m.Forum = parts[1] m.Forum = parts[1]
m.Args = parts[2:]
case "JOIN": case "JOIN":
if len(parts) == 1 { if len(parts) == 1 {
m.Forum = m.Text m.Forum = m.Text
@ -157,11 +158,23 @@ func parse(v string) (Message, error) {
case "NICK": case "NICK":
if len(parts) > 1 { if len(parts) > 1 {
m.Sender = parts[1] m.Sender = parts[1]
m.Args = parts[2:]
} else { } else {
m.Sender = m.Text m.Sender = m.Text
m.Text = "" m.Text = ""
m.Args = parts[1:]
} }
m.Forum = m.Sender m.Forum = m.Sender
case "353":
m.Forum = parts[3]
default:
numeric, _ := strconv.Atoi(m.Command)
if numeric >= 300 {
if len(parts) > 2 {
m.Forum = parts[2]
}
}
m.Args = parts[1:]
} }
return m, nil return m, nil