add ERR_ERRONEUSNICKNAME handler

This commit is contained in:
Evert Prants 2022-09-24 15:15:06 +03:00
parent 79d4af0a46
commit a5c7c22d54
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -248,7 +248,28 @@ export class IRCConnectionWrapper
}
break;
}
case '433': // ERR_NICKNAMEINUSE
case '432': {
// ERR_ERRONEUSNICKNAME
// No backing away from this, we don't know what is wrong exactly.
if (!this.authenticated) {
this.emit('error', {
error: new Error('Invalid nickname'),
fatal: true,
});
this.connection?.destroy();
return;
}
const resetNick = line.arguments[0];
this.emit('nick', {
oldNick: this.options.nick,
newNick: resetNick,
});
this.options.nick = resetNick;
break;
}
case '433': {
// ERR_NICKNAMEINUSE
const newNick = this.options.nick + '_';
this.write('NICK %s', newNick);
@ -259,6 +280,7 @@ export class IRCConnectionWrapper
this.options.nick = newNick;
break;
}
case '902': // ERR_NICKLOCKED
case '904': // ERR_SASLFAIL
case '905': // ERR_SASLTOOLONG