UNPKG

twiedenbein-thelounge

Version:

The self-hosted Web IRC client

51 lines (50 loc) 1.64 kB
"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 chan_1 = require("../../../shared/types/chan"); const msg_2 = require("../../../shared/types/msg"); const commands = ["ignorelist"]; const input = function (network, chan, _cmd, _args) { const client = this; if (network.ignoreList.length === 0) { chan.pushMessage(client, new msg_1.default({ type: msg_2.MessageType.ERROR, text: "Ignorelist is empty", })); return; } const chanName = "Ignored users"; const ignored = network.ignoreList.map((data) => ({ hostmask: `${data.nick}!${data.ident}@${data.hostname}`, when: data.when, })); let newChan = network.getChannel(chanName); if (typeof newChan === "undefined") { newChan = client.createChannel({ type: chan_1.ChanType.SPECIAL, special: chan_1.SpecialChanType.IGNORELIST, name: chanName, data: ignored, }); client.emit("join", { network: network.uuid, chan: newChan.getFilteredClone(true), shouldOpen: false, index: network.addChannel(newChan), }); return; } // TODO: add type for this chan/event newChan.data = ignored; client.emit("msg:special", { chan: newChan.id, data: ignored, }); }; exports.default = { commands, input, };