2022-06-18 20:25:21 -04:00
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
|
|
import {PluginInputHandler} from "./index";
|
2016-10-09 15:14:02 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
const commands = ["connect", "server"];
|
|
|
|
const allowDisconnected = true;
|
2016-05-16 10:22:03 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
const input: PluginInputHandler = function (network, chan, cmd, args) {
|
2016-03-20 13:35:20 -04:00
|
|
|
if (args.length === 0) {
|
2018-08-25 05:11:59 -04:00
|
|
|
network.userDisconnected = false;
|
|
|
|
this.save();
|
|
|
|
|
|
|
|
const irc = network.irc;
|
|
|
|
|
|
|
|
if (!irc) {
|
2016-05-16 10:22:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-25 05:11:59 -04:00
|
|
|
if (irc.connection && irc.connection.connected) {
|
2019-07-17 05:33:59 -04:00
|
|
|
chan.pushMessage(
|
|
|
|
this,
|
|
|
|
new Msg({
|
2022-06-18 20:25:21 -04:00
|
|
|
type: MessageType.ERROR,
|
2019-07-17 05:33:59 -04:00
|
|
|
text: "You are already connected.",
|
|
|
|
})
|
|
|
|
);
|
2016-05-16 10:22:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-25 05:11:59 -04:00
|
|
|
irc.connect();
|
2016-05-16 10:22:03 -04:00
|
|
|
|
2016-03-20 13:35:20 -04:00
|
|
|
return;
|
2014-09-13 17:29:45 -04:00
|
|
|
}
|
2016-03-06 04:24:56 -05:00
|
|
|
|
2018-01-11 06:33:36 -05:00
|
|
|
let port = args[1] || "";
|
|
|
|
const tls = port[0] === "+";
|
2016-03-20 13:35:20 -04:00
|
|
|
|
|
|
|
if (tls) {
|
|
|
|
port = port.substring(1);
|
|
|
|
}
|
|
|
|
|
2018-03-04 19:59:16 -05:00
|
|
|
const host = args[0];
|
|
|
|
this.connect({host, port, tls});
|
2016-03-20 13:35:20 -04:00
|
|
|
|
2016-03-06 04:24:56 -05:00
|
|
|
return true;
|
2014-09-13 17:29:45 -04:00
|
|
|
};
|
2022-06-18 20:25:21 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
commands,
|
|
|
|
input,
|
|
|
|
allowDisconnected,
|
|
|
|
};
|