Handle FAIL ACCOUNT_REQUIRED

This commit is contained in:
Simon Ser 2021-12-06 22:54:15 +01:00
parent 305f510501
commit f9ec578fce

View file

@ -362,7 +362,9 @@ export default class Client extends EventTarget {
} }
break; break;
case "ERROR": case "ERROR":
this.dispatchEvent(new CustomEvent("error", { detail: "Fatal IRC error: " + msg.params[0] })); this.dispatchEvent(new CustomEvent("error", {
detail: "Fatal IRC error: " + msg.params[0],
}));
this.disconnect(); this.disconnect();
break; break;
case irc.ERR_PASSWDMISMATCH: case irc.ERR_PASSWDMISMATCH:
@ -372,15 +374,27 @@ export default class Client extends EventTarget {
case irc.ERR_UNAVAILRESOURCE: case irc.ERR_UNAVAILRESOURCE:
case irc.ERR_NOPERMFORHOST: case irc.ERR_NOPERMFORHOST:
case irc.ERR_YOUREBANNEDCREEP: case irc.ERR_YOUREBANNEDCREEP:
this.dispatchEvent(new CustomEvent("error", { detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1] })); this.dispatchEvent(new CustomEvent("error", {
detail: "Error (" + msg.command + "): " + msg.params[msg.params.length - 1],
}));
if (this.status != Client.Status.REGISTERED) { if (this.status != Client.Status.REGISTERED) {
this.disconnect(); this.disconnect();
} }
break; break;
case "FAIL": case "FAIL":
if (this.status === Client.Status.REGISTERED) {
break;
}
let reason = msg.params[msg.params.length - 1];
if (msg.params[0] === "BOUNCER" && msg.params[2] === "BIND") { if (msg.params[0] === "BOUNCER" && msg.params[2] === "BIND") {
this.dispatchEvent(new CustomEvent("error", { this.dispatchEvent(new CustomEvent("error", {
detail: "Failed to bind to bouncer network: " + msg.params[3], detail: "Failed to bind to bouncer network: " + reason,
}));
this.disconnect();
}
if (msg.params[1] === "ACCOUNT_REQUIRED") {
this.dispatchEvent(new CustomEvent("error", {
detail: reason,
})); }));
this.disconnect(); this.disconnect();
} }