Update irc-framework to 2.1.0

This commit is contained in:
Pavel Djundik 2016-07-02 21:45:41 +03:00
parent 1cc02221a3
commit 1f760d877e
3 changed files with 11 additions and 6 deletions

View File

@ -48,7 +48,7 @@
"event-stream": "3.3.2", "event-stream": "3.3.2",
"express": "4.13.4", "express": "4.13.4",
"fs-extra": "0.30.0", "fs-extra": "0.30.0",
"irc-framework": "2.0.0", "irc-framework": "2.3.0",
"lodash": "4.11.2", "lodash": "4.11.2",
"moment": "2.13.0", "moment": "2.13.0",
"read": "1.0.7", "read": "1.0.7",

View File

@ -231,6 +231,8 @@ Client.prototype.connect = function(args) {
localAddress: config.bind, localAddress: config.bind,
rejectUnauthorized: false, rejectUnauthorized: false,
auto_reconnect: true, auto_reconnect: true,
auto_reconnect_wait: 10000 + Math.floor(Math.random() * 1000), // If multiple users are connected to the same network, randomize their reconnections a little
auto_reconnect_max_retries: 360, // At least one hour (plus timeouts) worth of reconnections
webirc: webirc, webirc: webirc,
}); });

View File

@ -47,7 +47,7 @@ module.exports = function(irc, network) {
irc.on("close", function() { irc.on("close", function() {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Disconnected from the network, and will not reconnect." text: "Disconnected from the network, and will not reconnect. Use /connect to reconnect again."
})); }));
}); });
@ -69,23 +69,26 @@ module.exports = function(irc, network) {
}); });
} }
irc.on("debug", function(message) {
log.debug("[" + client.name + " on " + network.host + ":" + network.port + "]", message);
});
irc.on("socket error", function(err) { irc.on("socket error", function(err) {
log.debug("IRC socket error", err);
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Socket error: " + err text: "Socket error: " + err
})); }));
}); });
irc.on("reconnecting", function() { irc.on("reconnecting", function(data) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Disconnected from the network. Reconnecting..." text: "Disconnected from the network. Reconnecting in " + Math.round(data.wait / 1000) + " seconds… (Attempt " + data.attempt + " of " + data.max_retries + ")"
})); }));
}); });
irc.on("ping timeout", function() { irc.on("ping timeout", function() {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Ping timeout, disconnecting..." text: "Ping timeout, disconnecting"
})); }));
}); });