From 07b4de8a1a56af26b1284463ec1834d92ceaf048 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 3 Jun 2020 17:18:57 +0200 Subject: [PATCH] Only send JOIN message if we have channels to join Don't send a JOIN command to upstream server when no channels are configured. --- upstream.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/upstream.go b/upstream.go index 82c2417..d80ead2 100644 --- a/upstream.go +++ b/upstream.go @@ -552,19 +552,21 @@ 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 { - names = append(names, ch.Name) - keys = append(keys, ch.Key) + if len(uc.network.channels) > 0 { + // TODO: split this into multiple messages if need be + var names, keys []string + for _, ch := range uc.network.channels { + names = append(names, ch.Name) + keys = append(keys, ch.Key) + } + uc.SendMessage(&irc.Message{ + Command: "JOIN", + Params: []string{ + strings.Join(names, ","), + strings.Join(keys, ","), + }, + }) } - 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