mirror of https://github.com/fluffle/goirc
handlers: Arm a timer to get our nick back when it was already taken.
This commit is contained in:
parent
7923e28091
commit
ad00f7e35d
|
@ -6,6 +6,7 @@ package client
|
||||||
import (
|
import (
|
||||||
"github.com/fluffle/goevent/event"
|
"github.com/fluffle/goevent/event"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Consts for unnamed events.
|
// Consts for unnamed events.
|
||||||
|
@ -99,6 +100,13 @@ func (conn *Conn) h_433(line *Line) {
|
||||||
// Args[1] is the new nick we were attempting to acquire
|
// Args[1] is the new nick we were attempting to acquire
|
||||||
neu := conn.NewNick(line.Args[1])
|
neu := conn.NewNick(line.Args[1])
|
||||||
conn.Nick(neu)
|
conn.Nick(neu)
|
||||||
|
// arm a timer to try get back our nick.
|
||||||
|
go func(old string) {
|
||||||
|
retry := 1 * time.Minute
|
||||||
|
for time.Sleep(retry); conn.cfg.Me.Nick != old; time.Sleep(retry) {
|
||||||
|
conn.Nick(old)
|
||||||
|
}
|
||||||
|
}(conn.cfg.Me.Nick)
|
||||||
// if this is happening before we're properly connected (i.e. the nick
|
// if this is happening before we're properly connected (i.e. the nick
|
||||||
// we sent in the initial NICK command is in use) we will not receive
|
// we sent in the initial NICK command is in use) we will not receive
|
||||||
// a NICK message to confirm our change of nick, so ReNick here...
|
// a NICK message to confirm our change of nick, so ReNick here...
|
||||||
|
|
Loading…
Reference in New Issue