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