Split rplList into rplList and rplListEnd
This commit is contained in:
parent
f240730e9a
commit
ce6038f4b0
@ -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)
|
||||
|
@ -121,6 +121,7 @@ const (
|
||||
rplKill
|
||||
rplMsg
|
||||
rplList
|
||||
rplListEnd
|
||||
rplOper
|
||||
rplChannelModeIs
|
||||
rplKick
|
||||
|
12
server.go
12
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user