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:
|
case rplMsg:
|
||||||
c.outputChan <- fmt.Sprintf(":%s PRIVMSG %s %s", args[0], args[1], args[2])
|
c.outputChan <- fmt.Sprintf(":%s PRIVMSG %s %s", args[0], args[1], args[2])
|
||||||
case rplList:
|
case rplList:
|
||||||
for _, listItem := range args {
|
c.outputChan <- fmt.Sprintf(":%s 322 %s %s", c.server.name, c.nick, args[0])
|
||||||
c.outputChan <- fmt.Sprintf(":%s 322 %s %s", c.server.name, c.nick, listItem)
|
case rplListEnd:
|
||||||
}
|
|
||||||
c.outputChan <- fmt.Sprintf(":%s 323 %s", c.server.name, c.nick)
|
c.outputChan <- fmt.Sprintf(":%s 323 %s", c.server.name, c.nick)
|
||||||
case rplOper:
|
case rplOper:
|
||||||
c.outputChan <- fmt.Sprintf(":%s 381 %s :You are now an operator", c.server.name, c.nick)
|
c.outputChan <- fmt.Sprintf(":%s 381 %s :You are now an operator", c.server.name, c.nick)
|
||||||
|
@ -121,6 +121,7 @@ const (
|
|||||||
rplKill
|
rplKill
|
||||||
rplMsg
|
rplMsg
|
||||||
rplList
|
rplList
|
||||||
|
rplListEnd
|
||||||
rplOper
|
rplOper
|
||||||
rplChannelModeIs
|
rplChannelModeIs
|
||||||
rplKick
|
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 {
|
if len(args) == 0 {
|
||||||
chanList := make([]string, 0, len(s.channelMap))
|
|
||||||
|
|
||||||
for channelName, channel := range s.channelMap {
|
for channelName, channel := range s.channelMap {
|
||||||
if channel.mode.secret {
|
if channel.mode.secret {
|
||||||
if _, inChannel := channel.clientMap[client.key]; !inChannel {
|
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)
|
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 {
|
} else {
|
||||||
channels := strings.Split(args[0], ",")
|
channels := strings.Split(args[0], ",")
|
||||||
chanList := make([]string, 0, len(channels))
|
|
||||||
|
|
||||||
for _, channelName := range channels {
|
for _, channelName := range channels {
|
||||||
if channel, exists := s.channelMap[strings.ToLower(channelName)]; exists {
|
if channel, exists := s.channelMap[strings.ToLower(channelName)]; exists {
|
||||||
listItem := fmt.Sprintf("%s %d :%s", channelName, len(channel.clientMap), channel.topic)
|
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":
|
case "OPER":
|
||||||
if client.registered == false {
|
if client.registered == false {
|
||||||
|
Loading…
Reference in New Issue
Block a user