Add support for RPL_ISUPPORT

This commit is contained in:
Simon Ser 2021-01-22 11:34:04 +01:00
parent 4acacc1f22
commit b3f8b0c97d
2 changed files with 28 additions and 0 deletions

View file

@ -450,6 +450,7 @@ export default class App extends Component {
networks.set(netID, { networks.set(netID, {
id: netID, id: netID,
status: Status.CONNECTING, status: Status.CONNECTING,
isupport: new Map(),
}); });
return { networks }; return { networks };
}); });
@ -548,6 +549,14 @@ export default class App extends Component {
}; };
this.setBufferState({ network: netID, name: SERVER_BUFFER}, { serverInfo }); this.setBufferState({ network: netID, name: SERVER_BUFFER}, { serverInfo });
break; 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: case irc.RPL_NOTOPIC:
var channel = msg.params[1]; var channel = msg.params[1];

View file

@ -3,6 +3,7 @@ export const RPL_WELCOME = "001";
export const RPL_YOURHOST = "002"; export const RPL_YOURHOST = "002";
export const RPL_CREATED = "003"; export const RPL_CREATED = "003";
export const RPL_MYINFO = "004"; export const RPL_MYINFO = "004";
export const RPL_ISUPPORT = "005";
export const RPL_ENDOFWHO = "315"; export const RPL_ENDOFWHO = "315";
export const RPL_NOTOPIC = "331"; export const RPL_NOTOPIC = "331";
export const RPL_TOPIC = "332"; export const RPL_TOPIC = "332";
@ -313,3 +314,21 @@ export function parseCTCP(msg) {
ctcp.command = ctcp.command.toUpperCase(); ctcp.command = ctcp.command.toUpperCase();
return ctcp; 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);
});
}