hardlounge/src/plugins/inputs/connect.js

44 lines
710 B
JavaScript
Raw Normal View History

"use strict";
2018-01-11 11:33:36 +00:00
const Msg = require("../../models/msg");
exports.commands = ["connect", "server"];
exports.allowDisconnected = true;
2016-03-06 09:24:56 +00:00
exports.input = function(network, chan, cmd, args) {
if (args.length === 0) {
network.userDisconnected = false;
this.save();
const irc = network.irc;
if (!irc) {
return;
}
if (irc.connection && irc.connection.connected) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: "You are already connected.",
}));
return;
}
irc.connect();
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] === "+";
if (tls) {
port = port.substring(1);
}
const host = args[0];
this.connect({host, port, tls});
2016-03-06 09:24:56 +00:00
return true;
2014-09-13 21:29:45 +00:00
};