From 1f760d877e99d4d9e26926ae78552fc2ede5adaa Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 2 Jul 2016 21:45:41 +0300 Subject: [PATCH] Update irc-framework to 2.1.0 --- package.json | 2 +- src/client.js | 2 ++ src/plugins/irc-events/connection.js | 13 ++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 57e9c5da..e8743908 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "event-stream": "3.3.2", "express": "4.13.4", "fs-extra": "0.30.0", - "irc-framework": "2.0.0", + "irc-framework": "2.3.0", "lodash": "4.11.2", "moment": "2.13.0", "read": "1.0.7", diff --git a/src/client.js b/src/client.js index 11ef2b37..15e0830d 100644 --- a/src/client.js +++ b/src/client.js @@ -231,6 +231,8 @@ Client.prototype.connect = function(args) { localAddress: config.bind, rejectUnauthorized: false, 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, }); diff --git a/src/plugins/irc-events/connection.js b/src/plugins/irc-events/connection.js index ce2a2697..db84632c 100644 --- a/src/plugins/irc-events/connection.js +++ b/src/plugins/irc-events/connection.js @@ -47,7 +47,7 @@ module.exports = function(irc, network) { irc.on("close", function() { 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) { - log.debug("IRC socket error", err); network.channels[0].pushMessage(client, new Msg({ type: Msg.Type.ERROR, text: "Socket error: " + err })); }); - irc.on("reconnecting", function() { + irc.on("reconnecting", function(data) { 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() { network.channels[0].pushMessage(client, new Msg({ - text: "Ping timeout, disconnecting..." + text: "Ping timeout, disconnecting…" })); });