diff --git a/lib/client.js b/lib/client.js index de7660b..8dea847 100644 --- a/lib/client.js +++ b/lib/client.js @@ -47,6 +47,7 @@ export default class Client extends EventTarget { autoReconnect = true; reconnectTimeoutID = null; pendingHistory = Promise.resolve(null); + cm = irc.CaseMapping.RFC1459; constructor(params) { super(); @@ -166,7 +167,18 @@ export default class Client extends EventTarget { break; case irc.RPL_ISUPPORT: var tokens = msg.params.slice(1, -1); - irc.parseISUPPORT(tokens, this.isupport); + var changed = irc.parseISUPPORT(tokens, this.isupport); + if (changed.indexOf("CASEMAPPING") >= 0) { + this.setCaseMapping(this.isupport.get("CASEMAPPING")); + } + break; + case irc.RPL_ENDOFMOTD: + case irc.ERR_NOMOTD: + // These messages are used to indicate the end of the ISUPPORT list + if (!this.isupport.has("CASEMAPPING")) { + // Server didn't send any CASEMAPPING token, assume RFC 1459 + this.setCaseMapping("rfc1459"); + } break; case "CAP": this.handleCap(msg); @@ -378,6 +390,14 @@ export default class Client extends EventTarget { console.debug("Sent:", msg); } + setCaseMapping(name) { + this.cm = irc.CaseMapping.byName(name); + if (!this.cm) { + console.error("Unsupported case-mapping '" + name + "', falling back to RFC 1459"); + this.cm = irc.CaseMapping.RFC1459; + } + } + /* Execute a command that expects a response. `done` is called with message * events until it returns a truthy value. */ roundtrip(msg, done) { diff --git a/lib/irc.js b/lib/irc.js index b540051..5093e93 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -11,6 +11,7 @@ export const RPL_TOPICWHOTIME = "333"; export const RPL_WHOREPLY = "352"; export const RPL_NAMREPLY = "353"; export const RPL_ENDOFNAMES = "366"; +export const RPL_ENDOFMOTD = "376"; export const ERR_NOMOTD = "422"; export const ERR_ERRONEUSNICKNAME = "432"; export const ERR_NICKNAMEINUSE = "433";