3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-26 05:49:25 +01:00

good ol' fashioned refactoring

This commit is contained in:
Jeremy Latt 2014-02-22 13:15:31 -08:00
parent c7298c55b9
commit c5c7469cf0
3 changed files with 13 additions and 5 deletions

View File

@ -29,6 +29,7 @@ func NewChannel(s *Server, name string) *Channel {
name: name,
server: s,
}
s.channels[name] = channel
return channel
}
@ -37,8 +38,7 @@ func (channel *Channel) IsEmpty() bool {
}
func (channel *Channel) Names(client *Client) {
client.MultilineReply(channel.Nicks(), RPL_NAMREPLY,
"= %s :%s", channel.name)
client.RplNamReply(channel)
client.RplEndOfNames(channel)
}

View File

@ -308,6 +308,16 @@ func (target *Client) RplListEnd(server *Server) {
":End of LIST")
}
func (target *Client) RplNamReply(channel *Channel) {
target.MultilineReply(channel.Nicks(), RPL_NAMREPLY,
"= %s :%s", channel)
}
func (target *Client) RplWhoisChannels(client *Client) {
target.MultilineReply(client.WhoisChannelsNames(), RPL_WHOISCHANNELS,
"%s :%s", client.Nick())
}
//
// errors (also numeric)
//

View File

@ -390,7 +390,6 @@ func (m *JoinCommand) HandleServer(s *Server) {
channel := s.channels[name]
if channel == nil {
channel = NewChannel(s, name)
s.channels[name] = channel
}
channel.Join(client, key)
}
@ -528,8 +527,7 @@ func (m *WhoisCommand) HandleServer(server *Server) {
client.RplWhoisOperator(mclient)
}
client.RplWhoisIdle(mclient)
client.MultilineReply(mclient.WhoisChannelsNames(), RPL_WHOISCHANNELS,
"%s :%s", mclient.Nick())
client.RplWhoisChannels(mclient)
client.RplEndOfWhois()
}
}