2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const Msg = require("../../models/msg");
|
2016-05-16 14:22:03 +00:00
|
|
|
|
2016-03-14 04:21:42 +00:00
|
|
|
exports.commands = ["connect", "server"];
|
2016-04-03 09:58:59 +00:00
|
|
|
exports.allowDisconnected = true;
|
2016-03-06 09:24:56 +00:00
|
|
|
|
2018-08-25 09:11:59 +00:00
|
|
|
exports.input = function(network, chan, cmd, args) {
|
2016-03-20 17:35:20 +00:00
|
|
|
if (args.length === 0) {
|
2018-08-25 09:11:59 +00:00
|
|
|
network.userDisconnected = false;
|
|
|
|
this.save();
|
|
|
|
|
|
|
|
const irc = network.irc;
|
|
|
|
|
|
|
|
if (!irc) {
|
2016-05-16 14:22:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-25 09:11:59 +00:00
|
|
|
if (irc.connection && irc.connection.connected) {
|
2016-05-16 14:22:03 +00:00
|
|
|
chan.pushMessage(this, new Msg({
|
|
|
|
type: Msg.Type.ERROR,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "You are already connected.",
|
2016-05-16 14:22:03 +00:00
|
|
|
}));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-25 09:11:59 +00:00
|
|
|
irc.connect();
|
2016-05-16 14:22:03 +00:00
|
|
|
|
2016-03-20 17:35:20 +00:00
|
|
|
return;
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
2016-03-06 09:24:56 +00:00
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
let port = args[1] || "";
|
|
|
|
const tls = port[0] === "+";
|
2016-03-20 17:35:20 +00:00
|
|
|
|
|
|
|
if (tls) {
|
|
|
|
port = port.substring(1);
|
|
|
|
}
|
|
|
|
|
2018-03-05 00:59:16 +00:00
|
|
|
const host = args[0];
|
|
|
|
this.connect({host, port, tls});
|
2016-03-20 17:35:20 +00:00
|
|
|
|
2016-03-06 09:24:56 +00:00
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
};
|