Better handle registration errors

This commit is contained in:
Simon Ser 2020-08-25 11:42:40 +02:00
parent b23f55a840
commit 516de5b3ea
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 25 additions and 5 deletions

View file

@ -93,10 +93,6 @@ export default class Client extends EventTarget {
console.log("Registration complete");
this.registered = true;
break;
case irc.ERR_PASSWDMISMATCH:
this.dispatchEvent(new CustomEvent("error", { detail: "Password mismatch" }));
this.close();
break;
case "CAP":
this.handleCap(msg);
break;
@ -148,6 +144,22 @@ export default class Client extends EventTarget {
deleteBatch = name;
}
break;
case "ERROR":
this.dispatchEvent(new CustomEvent("error", { detail: "Fatal IRC error: " + msg.params[0] }));
this.close();
break;
case irc.ERR_PASSWDMISMATCH:
case irc.ERR_ERRONEUSNICKNAME:
case irc.ERR_NICKNAMEINUSE:
case irc.ERR_NICKCOLLISION:
case irc.ERR_UNAVAILRESOURCE:
case irc.ERR_NOPERMFORHOST:
case irc.ERR_YOUREBANNEDCREEP:
this.dispatchEvent(new CustomEvent("error", { detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1] }));
if (!this.registered) {
this.close();
}
break;
}
this.dispatchEvent(new CustomEvent("message", {

View file

@ -1,3 +1,4 @@
// RFC 1459
export const RPL_WELCOME = "001";
export const RPL_YOURHOST = "002";
export const RPL_CREATED = "003";
@ -9,8 +10,15 @@ export const RPL_WHOREPLY = "352";
export const RPL_NAMREPLY = "353";
export const RPL_ENDOFNAMES = "366";
export const ERR_NOMOTD = "422";
export const ERR_ERRONEUSNICKNAME = "432";
export const ERR_NICKNAMEINUSE = "433";
export const ERR_NICKCOLLISION = "436";
export const ERR_NOPERMFORHOST = "463";
export const ERR_PASSWDMISMATCH = "464";
// https://ircv3.net/specs/extensions/sasl-3.1
export const ERR_YOUREBANNEDCREEP = "465";
// RFC 2812
export const ERR_UNAVAILRESOURCE = "437";
// IRCv3 SASL: https://ircv3.net/specs/extensions/sasl-3.1
export const RPL_LOGGEDIN = "900";
export const RPL_LOGGEDOUT = "901";
export const ERR_NICKLOCKED = "902";