UNPKG

twiedenbein-thelounge

Version:

The self-hosted Web IRC client

55 lines (54 loc) 2.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const log_1 = __importDefault(require("../../log")); const msg_1 = __importDefault(require("../../models/msg")); const msg_2 = require("../../../shared/types/msg"); const chan_1 = require("../../../shared/types/chan"); exports.default = (function (irc, network) { const client = this; irc.on("kick", function (data) { const chan = network.getChannel(data.channel); if (typeof chan === "undefined") { return; } const user = chan.getUser(data.kicked); const msg = new msg_1.default({ type: msg_2.MessageType.KICK, time: data.time, from: chan.getUser(data.nick), target: user, text: data.message || "", highlight: data.kicked === irc.user.nick, self: data.nick === irc.user.nick, }); chan.pushMessage(client, msg); if (data.kicked === irc.user.nick) { chan.users = new Map(); chan.state = chan_1.ChanState.PARTED; client.emit("channel:state", { chan: chan.id, state: chan.state, }); // Auto-rejoin the channel if the setting is enabled for this network if (network.autoRejoin) { log_1.default.info(`Auto-rejoining channel ${chan.name} after being kicked by ${data.nick}`); // Add a small delay before rejoining setTimeout(() => { irc.join(chan.name); // Notify the user about the auto-rejoin attempt const rejoinMsg = new msg_1.default({ type: msg_2.MessageType.NOTICE, text: `Attempting to automatically rejoin ${chan.name}...`, }); chan.pushMessage(client, rejoinMsg); }, 1000); // 1 second delay } } else { chan.removeUser(user); } }); });