thelounge/server/plugins/inputs/connect.ts

52 lines
814 B
TypeScript
Raw Normal View History

import Msg, {MessageType} from "../../models/msg";
import {PluginInputHandler} from "./index";
const commands = ["connect", "server"];
const allowDisconnected = true;
const input: PluginInputHandler = function (network, chan, cmd, args) {
if (args.length === 0) {
network.userDisconnected = false;
this.save();
const irc = network.irc;
if (!irc) {
return;
}
if (irc.connected) {
2019-07-17 11:33:59 +02:00
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
2019-07-17 11:33:59 +02:00
text: "You are already connected.",
})
);
return;
}
irc.connect();
return;
2014-09-13 23:29:45 +02:00
}
2016-03-06 10:24:56 +01:00
2018-01-11 12:33:36 +01: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 10:24:56 +01:00
return true;
2014-09-13 23:29:45 +02:00
};
export default {
commands,
input,
allowDisconnected,
};