"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");
exports.default = (function (irc, network) {
    const client = this;
    irc.on("unknown command", function (command) {
        let target = network.getLobby();
        // Do not display users own name
        if (command.params.length > 0 && command.params[0] === network.irc.user.nick) {
            command.params.shift();
        }
        // Check the length again because we may shift the nick above
        if (command.params.length > 0) {
            // If this numeric starts with a channel name that exists
            // put this message in that channel
            const channel = network.getChannel(command.params[0]);
            if (typeof channel !== "undefined") {
                target = channel;
            }
        }
        target.pushMessage(client, new msg_1.default({
            type: msg_2.MessageType.UNHANDLED,
            command: command.command,
            params: command.params,
        }), true);
    });
});
