Skip to content

Commit 4626c40

Browse files
committed
Reclaim nick on QUIT
1 parent e057364 commit 4626c40

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

events.go

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ func (c *Client) coreEvents() {
2121
c.ReclaimNick()
2222
})
2323

24+
// If the nick that PARTs is our configured nick we'll reclaim it.
25+
c.Handle("QUIT", func(m *Message) {
26+
if m.Name == c.nick {
27+
// Acquire lock
28+
c.infoMu.Lock()
29+
30+
// Send NICK command
31+
c.Nick(c.nick)
32+
33+
// Set current nick to what we just changed it to be
34+
c.currentNick = c.nick
35+
36+
// Release the lock
37+
c.infoMu.Unlock()
38+
}
39+
})
40+
2441
// 401 is returned by the server after a WHOIS request if the nick is not in use
2542
// Let's verify if the WHOIS request was made from a nick reclaim attempt
2643
c.Handle("401", func(m *Message) {

0 commit comments

Comments
 (0)