I have retrieved from the bottom of my old hard drives an old mIRC script of mine.
If you connect and your nick happens to be unavailable (e.g. used by someone else) the script will use timer and server events to get it back once it’s available again.
It’s multi-network and you can configure different nicks for different networks.
I have decided to share it via https://github.com/Czuz/KeepMyNick.
I hope someone will find it useful.