diff --git a/client.go b/client.go index 5cc7adb..906e686 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 df3ea5b..bea5bb3 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 ec2dc1f..ff677cd 100644 --- a/server.go +++ b/server.go @@ -267,8 +267,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 { @@ -277,23 +275,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 {