diff --git a/client.go b/client.go index e67b7bd..bdd8f74 100644 --- a/client.go +++ b/client.go @@ -169,9 +169,8 @@ func (c *Client) reply(code replyCode, args ...string) { case rplMsg: c.outputChan <- fmt.Sprintf(":%s PRIVMSG %s %s", args[0], args[1], args[2]) case rplList: - for _, listItem := range args { - c.outputChan <- fmt.Sprintf(":%s 322 %s %s", c.server.name, c.nick, listItem) - } + c.outputChan <- fmt.Sprintf(":%s 322 %s %s", c.server.name, c.nick, args[0]) + case rplListEnd: c.outputChan <- fmt.Sprintf(":%s 323 %s", c.server.name, c.nick) case rplOper: c.outputChan <- fmt.Sprintf(":%s 381 %s :You are now an operator", c.server.name, c.nick) diff --git a/rosella.go b/rosella.go index 38ffb0d..a9c5d9e 100644 --- a/rosella.go +++ b/rosella.go @@ -121,6 +121,7 @@ const ( rplKill rplMsg rplList + rplListEnd rplOper rplChannelModeIs rplKick diff --git a/server.go b/server.go index daced2e..0944b77 100644 --- a/server.go +++ b/server.go @@ -276,8 +276,6 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { } if len(args) == 0 { - chanList := make([]string, 0, len(s.channelMap)) - for channelName, channel := range s.channelMap { if channel.mode.secret { if _, inChannel := channel.clientMap[client.key]; !inChannel { @@ -286,23 +284,21 @@ func (s *Server) handleCommand(client *Client, command string, args []string) { } } listItem := fmt.Sprintf("%s %d :%s", channelName, len(channel.clientMap), channel.topic) - chanList = append(chanList, listItem) + client.reply(rplList, listItem) } - client.reply(rplList, chanList...) - + client.reply(rplListEnd) } else { channels := strings.Split(args[0], ",") - chanList := make([]string, 0, len(channels)) for _, channelName := range channels { if channel, exists := s.channelMap[strings.ToLower(channelName)]; exists { listItem := fmt.Sprintf("%s %d :%s", channelName, len(channel.clientMap), channel.topic) - chanList = append(chanList, listItem) + client.reply(rplList, listItem) } } - client.reply(rplList, chanList...) + client.reply(rplListEnd) } case "OPER": if client.registered == false {