3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

client: Fix

This commit is contained in:
Daniel Oaks 2016-06-19 15:37:29 +10:00
parent 7fcc6bdbc4
commit 7b13858f8c

View File

@ -145,7 +145,7 @@ func (client *Client) Touch() {
}
func (client *Client) Idle() {
client.Reply(RplPing(client.server))
client.Send(nil, "", "PING", client.nickString)
if client.quitTimer == nil {
client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout)
@ -229,24 +229,31 @@ func (client *Client) Friends() ClientSet {
return friends
}
func (client *Client) updateNickMask() {
client.nickString = client.nick.String()
client.nickMaskString = fmt.Sprintf("%s!%s@%s", client.nickString, client.username, client.hostname)
}
func (client *Client) SetNickname(nickname Name) {
if client.HasNick() {
Log.error.Printf("%s nickname already set!", client)
return
}
client.nick = nickname
client.updateNickMask()
client.server.clients.Add(client)
}
func (client *Client) ChangeNickname(nickname Name) {
// Make reply before changing nick to capture original source id.
reply := RplNick(client, nickname)
origNickMask := client.nickMaskString
client.server.clients.Remove(client)
client.server.whoWas.Append(client)
client.nick = nickname
client.updateNickMask()
client.server.clients.Add(client)
client.Send(nil, origNickMask, "NICK", nickname.String())
for friend := range client.Friends() {
friend.Reply(reply)
friend.Send(nil, origNickMask, "NICK", nickname.String())
}
}