mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 05:50:22 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
51 lines
843 B
TypeScript
51 lines
843 B
TypeScript
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.connection && irc.connection.connected) {
|
|
chan.pushMessage(
|
|
this,
|
|
new Msg({
|
|
type: MessageType.ERROR,
|
|
text: "You are already connected.",
|
|
})
|
|
);
|
|
return;
|
|
}
|
|
|
|
irc.connect();
|
|
|
|
return;
|
|
}
|
|
|
|
let port = args[1] || "";
|
|
const tls = port[0] === "+";
|
|
|
|
if (tls) {
|
|
port = port.substring(1);
|
|
}
|
|
|
|
const host = args[0];
|
|
this.connect({host, port, tls});
|
|
|
|
return true;
|
|
};
|
|
|
|
export default {
|
|
commands,
|
|
input,
|
|
allowDisconnected,
|
|
};
|