mIRC Home    About    Download    Register    News    Help

Topic Options
#264388 - 26/11/18 04:13 AM Automatic Main-Nickname Recovery while in Alt Nick
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2504
It usually happens that people become disconnected and reconnect as their alternate nickname because their main nickname is still in use by their ghost connection until it ping-timeouts. Occasionally somebody else might also attempt to use your nickname (maliciously or in play) causing you to connect with your alternate nickname preference.

I propose that mIRC automatically recover the main preference nickname whilst using the alternate nickname preference.

This seems to be a pretty standard feature in many IRC clients, and while scriptable in mIRC, I wouldn't say it's especially "easy" to script.

While using your Alternate Nickname ($anick), detect when your Main Nickname ($mnick) becomes available and change nicknames (to $mnick). Detection can be through standard visible presence of a QUIT, NICK or similar event, and also with the Notify feature via MONITOR, WATCH or ISON as appropriate.

mIRC should be careful to disable this functionality and ignore when a user manually changes their nickname from their $mnick into their $anick, or if the server (or BNC) specifically changes their nickname from their $mnick to their $anick or a Guest-style /^\S\S\S+\d\d\d+$/ nickname. As with any automated actions, there should be a sanity check to detect contrary repetitive behavior to prevent looping fits -- ie, only one nickname recovery allowed after connect, or allowed again if a '433 :Nickname is already in use.' error is encountered (and the user eventually changes into their $anick nickname), but also not more than once in a 10 minute window.
_________________________
doin� things a particle can

Top
#264389 - 26/11/18 05:18 AM Re: Automatic Main-Nickname Recovery while in Alt Nick [Re: Raccoon]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2504
pseudo-code.

Code:
On *:CONNECT: {
  set -e %NicknameRecovery.Allowed $true
  set -e %NicknameRecovery.Disabled $false
}

RAW 433:*: { ; :Nickname is already in use.
  if ($2 == $mnick) $&
    && (!%NicknameRecovery.Disabled) {
    ; This basically asserts that the user wants to retry claiming their main nickname.
    ;   All they have to do next is change into their alternate nickname.
    set -e %NicknameRecovery.Allowed $true
} }

On me:*:NICK: {
  if ($nick == $mnick) {
    ; The user did this or the server did this intentionally.
    ; (We used to have our $mnick, but we changed it to something else.)
    ; ((Remember that $nick is our old nick, and $newnick is our new nick.))
    set -eu600 %NicknameRecovery.Disabled $true
  }
  elseif ($newnick == $anick) $&
    && (%NicknameRecovery.Allowed) $&
    && (!%NicknameRecovery.Disabled) {
    ; If we're changing from any random nickname to our alt nickname,
    ;   monitor for our main preferred nickname to become available.
    notify $mnick
    notify on
} }

On *:UNOTIFY: {
  if ($me == $anick) $&
    && ($nick == $mnick) $&
    && (%NicknameRecovery.Allowed) $&
    && (!%NicknameRecovery.Disabled) {
    ; super sanity: the former can be reset again by a 433 later on,
    ;   but the latter must first timeout after a 10 minute hard wait.
    set -e %NicknameRecovery.Allowed $false
    set -eu600 %NicknameRecovery.Disabled $true
    nick $mnick
} } ; by Raccoon 2018

; On *:QUIT:
; On *:NICK:
;; both events are handled by On UNOTIFY implicitly.

; There's no feasible easy way to clean up temporary /notify use, so I didn't bother.
; This code is untested.
_________________________
doin� things a particle can

Top
#264398 - 26/11/18 04:45 PM Re: Automatic Main-Nickname Recovery while in Alt Nick [Re: Raccoon]
BhaaL Offline
Babel fish

Registered: 23/03/08
Posts: 84
Loc: Austria
I wouldn't mind if this were to become a built-in feature, but I have a script atm that works (for me and me alone). However, I only use it for networks that do not have NickServ (well, because I can just ghost/recover there and be done with it) - so it becomes a simple
Code:
on *:UNOTIFY: {
  if ($nick == $mnick && ($network == QuakeNet || $network == EFNet)) {
    tnick $mnick
  }
}

(aside from the obvious "my $mnick is permanently on NOTIFY", and perhaps a few potential improvements to make it a little more sturdy...but again, it works for me)

Top
#264408 - 27/11/18 10:47 AM Re: Automatic Main-Nickname Recovery while in Alt Nick [Re: BhaaL]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2504
Absolutely. I have the similar few-line script as yours, all manually configured per network. If you don't turn off your /notify then you can't change nicknames without further complicating the script. A user friendly feature would be neat smile

I like that you use /tnick so it's agnostic to the '[x] Preserve nicknames' setting.
_________________________
doin� things a particle can

Top
#264414 - 27/11/18 07:52 PM Re: Automatic Main-Nickname Recovery while in Alt Nick [Re: Raccoon]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2504
Upon review, my pseudo-code script and definition should exclude On Connect enabling of this functionality. %NicknameRecovery.Allowed should only be set to $true when a RAW 433 ($2 == $mnick) is encountered. This occurrence might happen during connection pre-auth On LOGON, or during the course of regular IRC use. Move %NicknameRecovery.Disabled = $false to On LOGON.

This revision would prevent automatic grabbing of $mnick for merely changing from a random nickname to $anick without first attempting to try $mnick.
_________________________
doin� things a particle can

Top