mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +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
|
return friends
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) ChangeNickname(nickname string) {
|
func (client *Client) SetNickname(nickname string) {
|
||||||
// Make reply before changing nick.
|
|
||||||
reply := RplNick(client, nickname)
|
|
||||||
|
|
||||||
client.nick = nickname
|
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() {
|
for friend := range client.Friends() {
|
||||||
friend.Reply(reply)
|
friend.Reply(reply)
|
||||||
}
|
}
|
||||||
|
@ -296,8 +296,7 @@ func (m *NickCommand) HandleRegServer(s *Server) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client.ChangeNickname(m.nickname)
|
client.SetNickname(m.nickname)
|
||||||
s.clients.Add(client)
|
|
||||||
s.tryRegister(client)
|
s.tryRegister(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,9 +355,7 @@ func (msg *NickCommand) HandleServer(server *Server) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
server.clients.Remove(client)
|
|
||||||
client.ChangeNickname(msg.nickname)
|
client.ChangeNickname(msg.nickname)
|
||||||
server.clients.Add(client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UserCommand) HandleServer(s *Server) {
|
func (m *UserCommand) HandleServer(s *Server) {
|
||||||
|
Loading…
Reference in New Issue
Block a user