mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
clean up nickname setting logic
This commit is contained in:
parent
86d4cae141
commit
0cd6be8008
@ -236,12 +236,17 @@ func (client *Client) Friends() ClientSet {
|
||||
return friends
|
||||
}
|
||||
|
||||
func (client *Client) ChangeNickname(nickname string) {
|
||||
// Make reply before changing nick.
|
||||
reply := RplNick(client, nickname)
|
||||
|
||||
func (client *Client) SetNickname(nickname string) {
|
||||
client.nick = nickname
|
||||
client.server.clients.Add(client)
|
||||
}
|
||||
|
||||
func (client *Client) ChangeNickname(nickname string) {
|
||||
// Make reply before changing nick to capture original source id.
|
||||
reply := RplNick(client, nickname)
|
||||
client.server.clients.Remove(client)
|
||||
client.nick = nickname
|
||||
client.server.clients.Add(client)
|
||||
for friend := range client.Friends() {
|
||||
friend.Reply(reply)
|
||||
}
|
||||
|
@ -296,8 +296,7 @@ func (m *NickCommand) HandleRegServer(s *Server) {
|
||||
return
|
||||
}
|
||||
|
||||
client.ChangeNickname(m.nickname)
|
||||
s.clients.Add(client)
|
||||
client.SetNickname(m.nickname)
|
||||
s.tryRegister(client)
|
||||
}
|
||||
|
||||
@ -356,9 +355,7 @@ func (msg *NickCommand) HandleServer(server *Server) {
|
||||
return
|
||||
}
|
||||
|
||||
server.clients.Remove(client)
|
||||
client.ChangeNickname(msg.nickname)
|
||||
server.clients.Add(client)
|
||||
}
|
||||
|
||||
func (m *UserCommand) HandleServer(s *Server) {
|
||||
|
Loading…
Reference in New Issue
Block a user