From bd48f36ade55a80ef050dc89f0c12d92fea8dd5b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 31 Jan 2022 18:24:34 +0100 Subject: [PATCH] lib/irc: add missing Isupport.chanModes It was called by forEachChannelModeUpdate, but wasn't implemented. --- lib/irc.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 716f7d6..0dbde6b 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -73,7 +73,6 @@ export const ERR_SASLALREADY = "907"; export const STD_MEMBERSHIPS = "~&@%+"; export const STD_CHANTYPES = "#&+!"; -export const STD_CHANMODES = "beI,k,l,imnst"; const tagEscapeMap = { ";": "\\:", @@ -464,6 +463,19 @@ export class Isupport { bouncerNetID() { return this.raw.get("BOUNCER_NETID"); } + + chanModes() { + const stdChanModes = ["beI", "k", "l", "imnst"]; + if (!this.raw.has("CHANMODES")) { + return stdChanModes; + } + let chanModes = this.raw.get("CHANMODES").split(","); + if (chanModes.length != 4) { + console.error("Invalid CHANMODES: ", this.raw.get("CHANMODES")); + return stdChanModes; + } + return chanModes; + } } export const CaseMapping = { @@ -672,11 +684,10 @@ export function getMessageLabel(msg) { } export function forEachChannelModeUpdate(msg, isupport, callback) { - let chanmodes = isupport.chanModes(); + let [a, b, c, d] = isupport.chanModes(); let prefix = isupport.prefix(); let typeByMode = new Map(); - let [a, b, c, d] = chanmodes.split(","); Array.from(a).forEach((mode) => typeByMode.set(mode, "A")); Array.from(b).forEach((mode) => typeByMode.set(mode, "B")); Array.from(c).forEach((mode) => typeByMode.set(mode, "C"));