From e3a1bf2f8781860dc7317e43228f3e6080ec87f4 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 13 Apr 2016 10:10:44 +0300 Subject: [PATCH 1/3] Enable auto reconnection --- src/client.js | 2 +- src/plugins/irc-events/connection.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client.js b/src/client.js index 4ad1bf93..194c09f9 100644 --- a/src/client.js +++ b/src/client.js @@ -211,7 +211,7 @@ Client.prototype.connect = function(args) { tls: network.tls, localAddress: config.bind, rejectUnauthorized: false, - auto_reconnect: false, // TODO: Enable auto reconnection + auto_reconnect: true, webirc: webirc, }); diff --git a/src/plugins/irc-events/connection.js b/src/plugins/irc-events/connection.js index 26676297..597e1db3 100644 --- a/src/plugins/irc-events/connection.js +++ b/src/plugins/irc-events/connection.js @@ -19,9 +19,9 @@ module.exports = function(irc, network) { })); }); - irc.on("socket close", function() { + irc.on("close", function() { network.channels[0].pushMessage(client, new Msg({ - text: "Disconnected from the network." + text: "Disconnected from the network, and will not reconnect." })); }); @@ -35,7 +35,7 @@ module.exports = function(irc, network) { irc.on("reconnecting", function() { network.channels[0].pushMessage(client, new Msg({ - text: "Reconnecting..." + text: "Disconnected from the network. Reconnecting..." })); }); From 047a79ead6b804d5b85bd91b5aada5c3ea3686d1 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 14 Apr 2016 11:56:02 +0300 Subject: [PATCH 2/3] Add separate /disconnect command --- src/client.js | 1 + src/plugins/inputs/disconnect.js | 7 +++++++ src/plugins/inputs/quit.js | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/plugins/inputs/disconnect.js diff --git a/src/client.js b/src/client.js index 194c09f9..98653ba7 100644 --- a/src/client.js +++ b/src/client.js @@ -36,6 +36,7 @@ var inputs = [ "part", "action", "connect", + "disconnect", "invite", "kick", "mode", diff --git a/src/plugins/inputs/disconnect.js b/src/plugins/inputs/disconnect.js new file mode 100644 index 00000000..a0ad99fb --- /dev/null +++ b/src/plugins/inputs/disconnect.js @@ -0,0 +1,7 @@ +exports.commands = ["disconnect"]; + +exports.input = function(network, chan, cmd, args) { + var quitMessage = args[0] ? args.join(" ") : ""; + + network.irc.quit(quitMessage); +}; diff --git a/src/plugins/inputs/quit.js b/src/plugins/inputs/quit.js index 7f54fccf..9039c704 100644 --- a/src/plugins/inputs/quit.js +++ b/src/plugins/inputs/quit.js @@ -1,6 +1,6 @@ var _ = require("lodash"); -exports.commands = ["quit", "disconnect"]; +exports.commands = ["quit"]; exports.allowDisconnected = true; exports.input = function(network, chan, cmd, args) { From a0010ca9f601f7ce9503f972a778f7da16f5fe69 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 16 May 2016 17:22:03 +0300 Subject: [PATCH 3/3] Allow /connect command to work on current network --- src/plugins/inputs/connect.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/inputs/connect.js b/src/plugins/inputs/connect.js index 538cd4a2..04296247 100644 --- a/src/plugins/inputs/connect.js +++ b/src/plugins/inputs/connect.js @@ -1,8 +1,24 @@ +var Msg = require("../../models/msg"); + exports.commands = ["connect", "server"]; exports.allowDisconnected = true; exports.input = function(network, chan, cmd, args) { if (args.length === 0) { + if (!network.irc || !network.irc.connection) { + return; + } + + if (network.irc.connection.connected) { + chan.pushMessage(this, new Msg({ + type: Msg.Type.ERROR, + text: "You are already connected." + })); + return; + } + + network.irc.connection.connect(); + return; }