hardlounge/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 09:33:59 +00:00
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
2019-07-17 09:33:59 +00:00
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
};
export default {
commands,
input,
allowDisconnected,
};