mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Better handle registration errors
This commit is contained in:
parent
b23f55a840
commit
516de5b3ea
2 changed files with 25 additions and 5 deletions
|
@ -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", {
|
||||
|
|
10
lib/irc.js
10
lib/irc.js
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue