Fix broken IRC servers with /list
This commit is contained in:
parent
1d47290ada
commit
0f439545d4
@ -47,6 +47,7 @@ var inputs = [
|
|||||||
"quit",
|
"quit",
|
||||||
"raw",
|
"raw",
|
||||||
"topic",
|
"topic",
|
||||||
|
"list",
|
||||||
].reduce(function(plugins, name) {
|
].reduce(function(plugins, name) {
|
||||||
var path = "./plugins/inputs/" + name;
|
var path = "./plugins/inputs/" + name;
|
||||||
var plugin = require(path);
|
var plugin = require(path);
|
||||||
|
@ -23,6 +23,7 @@ function Network(attr) {
|
|||||||
serverOptions: {
|
serverOptions: {
|
||||||
PREFIX: [],
|
PREFIX: [],
|
||||||
},
|
},
|
||||||
|
chanCache: [],
|
||||||
}, attr));
|
}, attr));
|
||||||
this.name = attr.name || prettify(attr.host);
|
this.name = attr.name || prettify(attr.host);
|
||||||
this.channels.unshift(
|
this.channels.unshift(
|
||||||
|
7
src/plugins/inputs/list.js
Normal file
7
src/plugins/inputs/list.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
exports.commands = ["list"];
|
||||||
|
|
||||||
|
exports.input = function(network, chan, cmd, args) {
|
||||||
|
network.chanCache = [];
|
||||||
|
network.irc.list(args);
|
||||||
|
return true;
|
||||||
|
};
|
@ -3,11 +3,10 @@ var Msg = require("../../models/msg");
|
|||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
var chanCache = {};
|
|
||||||
var MAX_CHANS = 1000;
|
var MAX_CHANS = 1000;
|
||||||
|
|
||||||
irc.on("channel list start", function() {
|
irc.on("channel list start", function() {
|
||||||
chanCache[network.id] = [];
|
network.chanCache = [];
|
||||||
|
|
||||||
updateListStatus(new Msg({
|
updateListStatus(new Msg({
|
||||||
text: "Loading channel list, this can take a moment...",
|
text: "Loading channel list, this can take a moment...",
|
||||||
@ -16,23 +15,23 @@ module.exports = function(irc, network) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
irc.on("channel list", function(channels) {
|
irc.on("channel list", function(channels) {
|
||||||
Array.prototype.push.apply(chanCache[network.id], channels);
|
Array.prototype.push.apply(network.chanCache, channels);
|
||||||
});
|
});
|
||||||
|
|
||||||
irc.on("channel list end", function() {
|
irc.on("channel list end", function() {
|
||||||
updateListStatus(new Msg({
|
updateListStatus(new Msg({
|
||||||
type: "channel_list",
|
type: "channel_list",
|
||||||
channels: chanCache[network.id].slice(0, MAX_CHANS)
|
channels: network.chanCache.slice(0, MAX_CHANS)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (chanCache[network.id].length > MAX_CHANS) {
|
if (network.chanCache.length > MAX_CHANS) {
|
||||||
updateListStatus(new Msg({
|
updateListStatus(new Msg({
|
||||||
type: "channel_list_truncated",
|
type: "channel_list_truncated",
|
||||||
text: "Channel list is too large: truncated to " + MAX_CHANS + " channels."
|
text: "Channel list is too large: truncated to " + MAX_CHANS + " channels."
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
chanCache[network.id] = [];
|
network.chanCache = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateListStatus(msg) {
|
function updateListStatus(msg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user