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