Add support for the soju.im/bouncer-networks extension
This commit is contained in:
parent
982a945932
commit
b429243573
3 changed files with 69 additions and 15 deletions
|
@ -10,6 +10,7 @@ const permanentCaps = [
|
|||
"message-tags",
|
||||
"multi-prefix",
|
||||
"server-time",
|
||||
"soju.im/bouncer-networks",
|
||||
];
|
||||
|
||||
const RECONNECT_DELAY_SEC = 10;
|
||||
|
@ -37,6 +38,7 @@ export default class Client extends EventTarget {
|
|||
nick: null,
|
||||
pass: null,
|
||||
saslPlain: null,
|
||||
bouncerNetwork: null,
|
||||
};
|
||||
batches = new Map();
|
||||
autoReconnect = true;
|
||||
|
@ -178,6 +180,9 @@ export default class Client extends EventTarget {
|
|||
case irc.RPL_SASLSUCCESS:
|
||||
console.log("SASL authentication success");
|
||||
if (this.status != Client.Status.REGISTERED) {
|
||||
if (this.enabledCaps["soju.im/bouncer-networks"] && this.params.bouncerNetwork) {
|
||||
this.send({ command: "BOUNCER", params: ["BIND", this.params.bouncerNetwork] });
|
||||
}
|
||||
this.send({ command: "CAP", params: ["END"] });
|
||||
}
|
||||
break;
|
||||
|
@ -454,4 +459,22 @@ export default class Client extends EventTarget {
|
|||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
listBouncerNetworks() {
|
||||
if (!this.enabledCaps["soju.im/bouncer-networks"]) {
|
||||
return Promise.reject(new Error("Server doesn't support the BOUNCER extension"));
|
||||
}
|
||||
|
||||
var req = { command: "BOUNCER", params: ["LISTNETWORKS"] };
|
||||
return this.fetchBatch(req, "bouncer-networks").then((batch) => {
|
||||
var networks = new Map();
|
||||
for (var msg of batch.messages) {
|
||||
console.assert(msg.command === "BOUNCER" && msg.params[0] === "NETWORK");
|
||||
var id = msg.params[1];
|
||||
var params = irc.parseTags(msg.params[2]);
|
||||
networks.set(id, params);
|
||||
}
|
||||
return networks;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue