From c547aa02781ee42086b8d80e15beb03d866e1a9e Mon Sep 17 00:00:00 2001 From: Eyal Sawady Date: Mon, 25 May 2020 20:15:57 -0400 Subject: [PATCH] Join all channels with a single JOIN message --- upstream.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/upstream.go b/upstream.go index 4d8b70d..e4f24b2 100644 --- a/upstream.go +++ b/upstream.go @@ -525,16 +525,19 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error { dc.updateSupportedCaps() }) + // TODO: split this into multiple messages if need be + var names, keys []string for _, ch := range uc.network.channels { - params := []string{ch.Name} - if ch.Key != "" { - params = append(params, ch.Key) - } - uc.SendMessage(&irc.Message{ - Command: "JOIN", - Params: params, - }) + names = append(names, ch.Name) + keys = append(keys, ch.Key) } + uc.SendMessage(&irc.Message{ + Command: "JOIN", + Params: []string{ + strings.Join(names, ","), + strings.Join(keys, ","), + }, + }) case irc.RPL_MYINFO: if err := parseMessageParams(msg, nil, &uc.serverName, nil, &uc.availableUserModes, nil); err != nil { return err