Remember disconnected networks between server restarts
This commit is contained in:
parent
5f190fc165
commit
9bcec3bea5
@ -205,6 +205,7 @@ Client.prototype.connect = function(args) {
|
||||
host: String(args.host || ""),
|
||||
port: parseInt(args.port, 10),
|
||||
tls: !!args.tls,
|
||||
userDisconnected: !!args.userDisconnected,
|
||||
rejectUnauthorized: !!args.rejectUnauthorized,
|
||||
password: String(args.password || ""),
|
||||
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();
|
||||
|
||||
|
@ -28,6 +28,7 @@ function Network(attr) {
|
||||
host: "",
|
||||
port: 6667,
|
||||
tls: false,
|
||||
userDisconnected: false,
|
||||
rejectUnauthorized: false,
|
||||
password: "",
|
||||
awayMessage: "",
|
||||
@ -321,6 +322,7 @@ Network.prototype.export = function() {
|
||||
"host",
|
||||
"port",
|
||||
"tls",
|
||||
"userDisconnected",
|
||||
"rejectUnauthorized",
|
||||
"password",
|
||||
"username",
|
||||
|
@ -5,13 +5,18 @@ const Msg = require("../../models/msg");
|
||||
exports.commands = ["connect", "server"];
|
||||
exports.allowDisconnected = true;
|
||||
|
||||
exports.input = function({irc}, chan, cmd, args) {
|
||||
exports.input = function(network, chan, cmd, args) {
|
||||
if (args.length === 0) {
|
||||
if (!irc || !irc.connection) {
|
||||
network.userDisconnected = false;
|
||||
this.save();
|
||||
|
||||
const irc = network.irc;
|
||||
|
||||
if (!irc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (irc.connection.connected) {
|
||||
if (irc.connection && irc.connection.connected) {
|
||||
chan.pushMessage(this, new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
text: "You are already connected.",
|
||||
@ -19,7 +24,7 @@ exports.input = function({irc}, chan, cmd, args) {
|
||||
return;
|
||||
}
|
||||
|
||||
irc.connection.connect();
|
||||
irc.connect();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -4,8 +4,11 @@ const Helper = require("../../helper");
|
||||
|
||||
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;
|
||||
|
||||
irc.quit(quitMessage);
|
||||
network.irc.quit(quitMessage);
|
||||
|
||||
network.userDisconnected = true;
|
||||
this.save();
|
||||
};
|
||||
|
@ -32,6 +32,7 @@ describe("Network", function() {
|
||||
host: "",
|
||||
port: 6667,
|
||||
tls: false,
|
||||
userDisconnected: false,
|
||||
rejectUnauthorized: false,
|
||||
password: "",
|
||||
username: "",
|
||||
@ -233,6 +234,7 @@ describe("Network", function() {
|
||||
"serverOptions",
|
||||
"status",
|
||||
"tls",
|
||||
"userDisconnected",
|
||||
"rejectUnauthorized",
|
||||
"uuid",
|
||||
"username"
|
||||
|
Loading…
Reference in New Issue
Block a user