Trailing gets added to the end of params

This commit is contained in:
khlieng 2015-02-03 23:33:23 +01:00
parent 3214e5931a
commit d69281cdd6
3 changed files with 11 additions and 14 deletions

View File

@ -20,7 +20,7 @@ var selectedTabStore = Reflux.createStore({
select: function(server, channel) { select: function(server, channel) {
selectedTab.server = server; selectedTab.server = server;
selectedTab.channel = channel; selectedTab.channel = channel || null;
if (channel) { if (channel) {
selectedTab.name = channel; selectedTab.name = channel;

8
irc.go
View File

@ -94,7 +94,7 @@ func (i *IRC) Connect(address string) error {
} }
i.Server = address i.Server = address
dialer := &net.Dialer{Timeout: 10 * time.Second} dialer := &net.Dialer{Timeout: 30 * time.Second}
if i.TLS { if i.TLS {
if i.TLSConfig == nil { if i.TLSConfig == nil {
@ -227,7 +227,7 @@ func parseMessage(line string) *Message {
msg.Prefix = line[1 : cmdStart-1] msg.Prefix = line[1 : cmdStart-1]
} }
if i := strings.LastIndex(line, " :"); i > 0 { if i := strings.Index(line, " :"); i > 0 {
cmdEnd = i cmdEnd = i
msg.Trailing = line[i+2:] msg.Trailing = line[i+2:]
} }
@ -238,6 +238,10 @@ func parseMessage(line string) *Message {
msg.Params = cmd[1:] msg.Params = cmd[1:]
} }
if msg.Trailing != "" {
msg.Params = append(msg.Params, msg.Trailing)
}
return &msg return &msg
} }

View File

@ -24,26 +24,19 @@ func handleMessages(irc *IRC, session *Session) {
case JOIN: case JOIN:
user := msg.Prefix user := msg.Prefix
var channel string
if len(msg.Params) > 0 {
channel = msg.Params[0]
} else {
channel = msg.Trailing
}
session.sendJSON("join", Join{ session.sendJSON("join", Join{
Server: irc.Host, Server: irc.Host,
User: user, User: user,
Channels: []string{channel}, Channels: msg.Params,
}) })
channelStore.AddUser(user, irc.Host, channel) channelStore.AddUser(user, irc.Host, msg.Params[0])
if user == irc.nick { if user == irc.nick {
session.user.AddChannel(storage.Channel{ session.user.AddChannel(storage.Channel{
Server: irc.Host, Server: irc.Host,
Name: channel, Name: msg.Params[0],
}) })
} }
@ -116,7 +109,7 @@ func handleMessages(irc *IRC, session *Session) {
session.sendJSON("pm", Chat{ session.sendJSON("pm", Chat{
Server: irc.Host, Server: irc.Host,
From: msg.Prefix, From: msg.Prefix,
Message: strings.Join(append(msg.Params[1:], msg.Trailing), " "), Message: strings.Join(msg.Params[1:], " "),
}) })
case RPL_TOPIC: case RPL_TOPIC: