Merge pull request #2718 from thelounge/xpaw/remember-disconnect
Remember disconnected networks between server restarts
This commit is contained in:
commit
0a35000cb8
@ -205,6 +205,7 @@ Client.prototype.connect = function(args) {
|
|||||||
host: String(args.host || ""),
|
host: String(args.host || ""),
|
||||||
port: parseInt(args.port, 10),
|
port: parseInt(args.port, 10),
|
||||||
tls: !!args.tls,
|
tls: !!args.tls,
|
||||||
|
userDisconnected: !!args.userDisconnected,
|
||||||
rejectUnauthorized: !!args.rejectUnauthorized,
|
rejectUnauthorized: !!args.rejectUnauthorized,
|
||||||
password: String(args.password || ""),
|
password: String(args.password || ""),
|
||||||
nick: String(args.nick || ""),
|
nick: String(args.nick || ""),
|
||||||
@ -238,7 +239,13 @@ Client.prototype.connect = function(args) {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
network.irc.connect();
|
if (network.userDisconnected) {
|
||||||
|
network.channels[0].pushMessage(client, new Msg({
|
||||||
|
text: "You have manually disconnected from this network before, use /connect command to connect again.",
|
||||||
|
}), true);
|
||||||
|
} else {
|
||||||
|
network.irc.connect();
|
||||||
|
}
|
||||||
|
|
||||||
client.save();
|
client.save();
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ function Network(attr) {
|
|||||||
host: "",
|
host: "",
|
||||||
port: 6667,
|
port: 6667,
|
||||||
tls: false,
|
tls: false,
|
||||||
|
userDisconnected: false,
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
password: "",
|
password: "",
|
||||||
awayMessage: "",
|
awayMessage: "",
|
||||||
@ -321,6 +322,7 @@ Network.prototype.export = function() {
|
|||||||
"host",
|
"host",
|
||||||
"port",
|
"port",
|
||||||
"tls",
|
"tls",
|
||||||
|
"userDisconnected",
|
||||||
"rejectUnauthorized",
|
"rejectUnauthorized",
|
||||||
"password",
|
"password",
|
||||||
"username",
|
"username",
|
||||||
|
@ -5,13 +5,18 @@ const Msg = require("../../models/msg");
|
|||||||
exports.commands = ["connect", "server"];
|
exports.commands = ["connect", "server"];
|
||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
if (!irc || !irc.connection) {
|
network.userDisconnected = false;
|
||||||
|
this.save();
|
||||||
|
|
||||||
|
const irc = network.irc;
|
||||||
|
|
||||||
|
if (!irc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irc.connection.connected) {
|
if (irc.connection && irc.connection.connected) {
|
||||||
chan.pushMessage(this, new Msg({
|
chan.pushMessage(this, new Msg({
|
||||||
type: Msg.Type.ERROR,
|
type: Msg.Type.ERROR,
|
||||||
text: "You are already connected.",
|
text: "You are already connected.",
|
||||||
@ -19,7 +24,7 @@ exports.input = function({irc}, chan, cmd, args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
irc.connection.connect();
|
irc.connect();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,11 @@ const Helper = require("../../helper");
|
|||||||
|
|
||||||
exports.commands = ["disconnect"];
|
exports.commands = ["disconnect"];
|
||||||
|
|
||||||
exports.input = function({irc}, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
const quitMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
||||||
|
|
||||||
irc.quit(quitMessage);
|
network.irc.quit(quitMessage);
|
||||||
|
|
||||||
|
network.userDisconnected = true;
|
||||||
|
this.save();
|
||||||
};
|
};
|
||||||
|
@ -32,6 +32,7 @@ describe("Network", function() {
|
|||||||
host: "",
|
host: "",
|
||||||
port: 6667,
|
port: 6667,
|
||||||
tls: false,
|
tls: false,
|
||||||
|
userDisconnected: false,
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
password: "",
|
password: "",
|
||||||
username: "",
|
username: "",
|
||||||
@ -233,6 +234,7 @@ describe("Network", function() {
|
|||||||
"serverOptions",
|
"serverOptions",
|
||||||
"status",
|
"status",
|
||||||
"tls",
|
"tls",
|
||||||
|
"userDisconnected",
|
||||||
"rejectUnauthorized",
|
"rejectUnauthorized",
|
||||||
"uuid",
|
"uuid",
|
||||||
"username"
|
"username"
|
||||||
|
Loading…
Reference in New Issue
Block a user