From 75f575eb204a864f5afbad537049864bf5d7b16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Solymos?= <15968382+slymas@users.noreply.github.com> Date: Mon, 5 Jan 2026 17:24:43 +0000 Subject: [PATCH] Add an config param allowing to delay renicking if the previously tried nick was already in use --- client/connection.go | 3 +++ client/handlers.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/client/connection.go b/client/connection.go index 7bbaf0f..f4709f1 100644 --- a/client/connection.go +++ b/client/connection.go @@ -112,6 +112,9 @@ type Config struct { // See DefaultNewNick implementation below for details. NewNick func(string) string + // A delay in NewNick before actually sending the new nick command. Default is not set, so it's 0. + ReNickDelay time.Duration + // Client->server ping frequency, in seconds. Defaults to 3m. // Set to 0 to disable client-side pings. PingFreq time.Duration diff --git a/client/handlers.go b/client/handlers.go index 3920c02..4a838ec 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -310,6 +310,9 @@ func (conn *Conn) h_001(line *Line) { // Handler to deal with "433 :Nickname already in use" func (conn *Conn) h_433(line *Line) { + // Delay trying again if a non-zero delay was set + time.Sleep(conn.cfg.ReNickDelay) + // Args[1] is the new nick we were attempting to acquire me := conn.Me() neu := conn.cfg.NewNick(line.Args[1])