Merge pull request #254 from thelounge/xpaw/auto-rc
Enable auto reconnection
This commit is contained in:
commit
7834d12e8f
@ -36,6 +36,7 @@ var inputs = [
|
|||||||
"part",
|
"part",
|
||||||
"action",
|
"action",
|
||||||
"connect",
|
"connect",
|
||||||
|
"disconnect",
|
||||||
"invite",
|
"invite",
|
||||||
"kick",
|
"kick",
|
||||||
"mode",
|
"mode",
|
||||||
@ -211,7 +212,7 @@ Client.prototype.connect = function(args) {
|
|||||||
tls: network.tls,
|
tls: network.tls,
|
||||||
localAddress: config.bind,
|
localAddress: config.bind,
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
auto_reconnect: false, // TODO: Enable auto reconnection
|
auto_reconnect: true,
|
||||||
webirc: webirc,
|
webirc: webirc,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,8 +1,24 @@
|
|||||||
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["connect", "server"];
|
exports.commands = ["connect", "server"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
if (args.length === 0) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
src/plugins/inputs/disconnect.js
Normal file
7
src/plugins/inputs/disconnect.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
exports.commands = ["disconnect"];
|
||||||
|
|
||||||
|
exports.input = function(network, chan, cmd, args) {
|
||||||
|
var quitMessage = args[0] ? args.join(" ") : "";
|
||||||
|
|
||||||
|
network.irc.quit(quitMessage);
|
||||||
|
};
|
@ -1,6 +1,6 @@
|
|||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
|
|
||||||
exports.commands = ["quit", "disconnect"];
|
exports.commands = ["quit"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
|
@ -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({
|
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() {
|
irc.on("reconnecting", function() {
|
||||||
network.channels[0].pushMessage(client, new Msg({
|
network.channels[0].pushMessage(client, new Msg({
|
||||||
text: "Reconnecting..."
|
text: "Disconnected from the network. Reconnecting..."
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user