"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const msg_1 = __importDefault(require("../../models/msg"));
const msg_2 = require("../../../shared/types/msg");
const commands = ["connect", "server"];
const allowDisconnected = true;
const input = function (network, chan, cmd, args) {
    if (args.length === 0) {
        network.userDisconnected = false;
        this.save();
        const irc = network.irc;
        if (!irc) {
            return;
        }
        if (irc.connected) {
            chan.pushMessage(this, new msg_1.default({
                type: msg_2.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.connectToNetwork({ host, port, tls });
    return true;
};
exports.default = {
    commands,
    input,
    allowDisconnected,
};
