3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-22 18:24:17 +01:00

Merge pull request #138 from slingamn/quit_messages

send the actual quit message to friends
This commit is contained in:
Daniel Oaks 2017-09-26 13:03:13 +10:00 committed by GitHub
commit 90435256fd

View File

@ -68,6 +68,7 @@ type Client struct {
nickMaskString string // cache for nickmask string since it's used with lots of replies nickMaskString string // cache for nickmask string since it's used with lots of replies
operName string operName string
proxiedIP string // actual remote IP if using the PROXY protocol proxiedIP string // actual remote IP if using the PROXY protocol
quitMessage string
quitMessageSent bool quitMessageSent bool
quitMutex sync.Mutex quitMutex sync.Mutex
quitTimer *time.Timer quitTimer *time.Timer
@ -491,6 +492,7 @@ func (client *Client) Quit(message string) {
client.socket.SetFinalData(quitLine + errorLine) client.socket.SetFinalData(quitLine + errorLine)
client.quitMessageSent = true client.quitMessageSent = true
client.quitMessage = message
} }
} }
@ -559,8 +561,10 @@ func (client *Client) destroy() {
// send quit messages to friends // send quit messages to friends
for friend := range friends { for friend := range friends {
//TODO(dan): store quit message in user, if exists use that instead here if client.quitMessage == "" {
friend.Send(nil, client.nickMaskString, "QUIT", "Exited") client.quitMessage = "Exited"
}
friend.Send(nil, client.nickMaskString, "QUIT", client.quitMessage)
} }
if !client.exitedSnomaskSent { if !client.exitedSnomaskSent {
client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), client.nick)) client.server.snomasks.Send(sno.LocalQuits, fmt.Sprintf(ircfmt.Unescape("%s$r exited the network"), client.nick))