From b3f8b0c97df7c79175fbf2c2055fa55e2ec6942e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 22 Jan 2021 11:34:04 +0100 Subject: [PATCH] Add support for RPL_ISUPPORT --- components/app.js | 9 +++++++++ lib/irc.js | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/components/app.js b/components/app.js index 26eba05..fbeaa97 100644 --- a/components/app.js +++ b/components/app.js @@ -450,6 +450,7 @@ export default class App extends Component { networks.set(netID, { id: netID, status: Status.CONNECTING, + isupport: new Map(), }); return { networks }; }); @@ -548,6 +549,14 @@ export default class App extends Component { }; this.setBufferState({ network: netID, name: SERVER_BUFFER}, { serverInfo }); break; + case irc.RPL_ISUPPORT: + var tokens = msg.params.slice(1, -1); + this.setNetworkState(netID, (network) => { + var isupport = new Map(network.isupport); + irc.parseISUPPORT(tokens, isupport); + return { isupport }; + }); + break; case irc.RPL_NOTOPIC: var channel = msg.params[1]; diff --git a/lib/irc.js b/lib/irc.js index 361b4ad..8e648d2 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -3,6 +3,7 @@ export const RPL_WELCOME = "001"; export const RPL_YOURHOST = "002"; export const RPL_CREATED = "003"; export const RPL_MYINFO = "004"; +export const RPL_ISUPPORT = "005"; export const RPL_ENDOFWHO = "315"; export const RPL_NOTOPIC = "331"; export const RPL_TOPIC = "332"; @@ -313,3 +314,21 @@ export function parseCTCP(msg) { ctcp.command = ctcp.command.toUpperCase(); return ctcp; } + +export function parseISUPPORT(tokens, params) { + tokens.forEach((tok) => { + if (tok.startsWith("-")) { + var k = tok.slice(1); + params.delete(k.toUpperCase()); + return; + } + + var i = tok.indexOf("="); + var k = tok, v = ""; + if (i >= 0) { + k = tok.slice(0, i); + v = tok.slice(i + 1); + } + params.set(k.toUpperCase(), v); + }); +}