irc-framework
Version:
A better IRC framework for node.js
2 lines • 336 kB
JavaScript
/*! For license information please see browser.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("irc-framework",[],e):"object"==typeof exports?exports["irc-framework"]=e():t["irc-framework"]=e()}(self,(()=>(()=>{var t={37215:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(52675),r(89463),r(2259),r(23792),r(84185),r(47764),r(62953),r(45700),r(2008),r(50113),r(48598),r(89572),r(23288),r(94170),r(62010),r(2892),r(26099),r(38781);var a={partial:r(19181),filter:r(87612),find:r(7309),each:r(76135),pull:r(50121),extend:r(43346)},s=r(88310).Duplex;t.exports=function(){return t=function t(e,r,n){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.irc_client=e,this.name=r,this.say=a.partial(e.say.bind(e),r),this.notice=a.partial(e.notice.bind(e),r),this.part=a.partial(e.part.bind(e),r),this.join=a.partial(e.join.bind(e),r),this.mode=a.partial(e.mode.bind(e),r),this.banlist=a.partial(e.banlist.bind(e),r),this.ban=a.partial(e.ban.bind(e),r),this.unban=a.partial(e.unban.bind(e),r),this.users=[],e.on("userlist",(function(t){e.caseCompare(t.channel,o.name)&&(o.users=t.users)})),e.on("join",(function(t){e.caseCompare(t.channel,o.name)&&o.users.push(t)})),e.on("part",(function(t){e.caseCompare(t.channel,o.name)&&(o.users=a.filter(o.users,(function(r){return!e.caseCompare(t.nick,r.nick)})))})),e.on("kick",(function(t){e.caseCompare(t.channel,o.name)&&(o.users=a.filter(o.users,(function(r){return!e.caseCompare(t.kicked,r.nick)})))})),e.on("quit",(function(t){o.users=a.filter(o.users,(function(r){return!e.caseCompare(t.nick,r.nick)}))})),e.on("nick",(function(t){a.find(o.users,(function(r){if(e.caseCompare(t.nick,r.nick))return r.nick=t.new_nick,!0}))})),e.on("mode",(function(t){e.caseCompare(t.target,o.name)&&a.each(t.modes,(function(t){if(a.find(e.network.options.PREFIX,{mode:t.mode[1]})){var r=a.find(o.users,(function(r){return e.caseCompare(r.nick,t.param)}));if(!r)return;"+"===t.mode[0]?(r.modes=r.modes||[],r.modes.push(t.mode[1])):a.pull(r.modes,t.mode[1])}}))})),this.join(n)},(e=[{key:"relay",value:function(t,e){e=a.extend({one_way:!1,replay_nicks:!0},e),"string"==typeof t&&(t=this.irc_client.channel(t));var r=this.stream(e),n=t.stream(e);r.pipe(n),e.one_way||n.pipe(r)}},{key:"stream",value:function(t){var e=this,r=[],o=!1,i=new s({objectMode:!0,write:function(r,o,i){"object"===n(r)&&"string"==typeof r.message&&(r=t.replay_nicks?"<"+r.nick+"> "+r.message:r.message),e.say(r.toString()),i()},read:function(){for(o=!0;r.length>0;){var t=r.shift();if(!1===i.push(t)){o=!1;break}}}});return this.irc_client.on("privmsg",(function(t){e.irc_client.caseCompare(t.target,e.name)&&(r.push(t),o&&i._read())})),i}},{key:"updateUsers",value:function(t){var e=this,r=function(n){e.irc_client.caseCompare(n.channel,e.name)&&(e.irc_client.removeListener("userlist",r),"function"==typeof t&&t(e))};this.irc_client.on("userlist",r),this.irc_client.raw("NAMES",this.name)}}])&&o(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},90045:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}function c(t,e,r){return e=f(e),function(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,u()?Reflect.construct(e,r||[],f(t).constructor):e.apply(t,r))}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(u=function(){return!!t})()}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}r(52675),r(89463),r(2259),r(45700),r(23418),r(23792),r(89572),r(62010),r(2892),r(59904),r(40875),r(60825),r(47764),r(62953),r(28706),r(2008),r(50113),r(51629),r(25276),r(64346),r(48598),r(34782),r(54554),r(59089),r(23288),r(94170),r(84185),r(79432),r(10287),r(26099),r(27495),r(38781),r(71761),r(90744),r(42762),r(23500);var p={extend:r(43346),find:r(7309),each:r(76135),defer:r(64112),bind:r(39729)},h=r(30228),d=r(17804),y=r(17123).CommandHandler,v=r(85601),g=r(89494),m=r(52250),b=r(98041),w=r(37215),_=r(79921).lineBreak,E=r(48338),S=null;t.exports=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=c(this,e)).request_extra_caps=[],r.options=t||null,r.createStructure(),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&l(t,e)}(e,t),r=e,n=[{key:"Message",get:function(){return v}},{key:"_applyDefaultOptions",value:function(t){for(var e={nick:"ircbot",username:"ircbot",gecos:"ircbot",encoding:"utf8",version:"node.js irc-framework",enable_chghost:!1,enable_setname:!1,enable_echomessage:!1,auto_reconnect:!0,auto_reconnect_max_wait:3e5,auto_reconnect_max_retries:3,ping_interval:30,ping_timeout:120,message_max_length:350,sasl_disconnect_on_fail:!1,transport:S,websocket_protocol:"text.ircv3.net"},r=Object.keys(e),n=0;n<r.length;n++)void 0===t[r[n]]&&(t[r[n]]=e[r[n]]);return t}},{key:"createStructure",value:function(){var t=this;t.raw_middleware=new d,t.parsed_middleware=new d,t.connection=new g(t.options),t.network=new m,t.user=new b,t.command_handler=new y(t),t.addCommandHandlerListeners(),["connecting","reconnecting","close","socket close","socket error","raw socket connected","debug","raw"].forEach((function(e){t.connection.on(e,(function(){var r=Array.prototype.slice.call(arguments);t.emit.apply(t,[e].concat(r))}))})),t.connection.on("socket connected",(function(){t.emit("socket connected"),t.registerToNetwork(),t.startPingTimeoutTimer()})),t.connection.on("connecting",(function(){t.network.cap.negotiating=!1,t.network.cap.requested=[],t.network.cap.enabled=[],t.network.cap.available.clear(),t.command_handler.resetCache()})),t.connection.on("message",(function(e,r){t.raw_middleware.handle([e.command,e,r,t],(function(r){r?console.log(r.stack):t.command_handler.dispatch(e)}))})),t.on("registered",(function(e){t.startPeriodicPing()})),t.on("away",(function(e){t.caseCompare(e.nick,t.user.nick)&&(t.user.away=!0)})),t.on("back",(function(e){t.caseCompare(e.nick,t.user.nick)&&(t.user.away=!1)})),t.proxyIrcEvents();var e={value:0,requests:[],next:function(){e.value>=999&&(e.value=0);var t=++e.value;return e.requests.push(t),t},validate:function(t){var r=e.requests.indexOf(t);return-1!==r&&(e.requests.splice(r,1),!0)}};t.whox_token=e,Object.defineProperty(t,"connected",{enumerable:!0,get:function(){return t.connection&&t.connection.connected}})}},{key:"requestCap",value:function(t){this.request_extra_caps=this.request_extra_caps.concat(t)}},{key:"use",value:function(t){return t(this,this.raw_middleware,this.parsed_middleware),this}},{key:"connect",value:function(t){var e=this;if(!t&&!e.options)throw new Error("Options object missing from IrcClient.connect()");t?e.options=t:t=e.options,e._applyDefaultOptions(t),e.connection&&e.connection.connected&&(e.debugOut("connect() called when already connected"),e.connection.end()),e.user.nick=t.nick,e.user.username=t.username,e.user.gecos=t.gecos,e.command_handler.requestExtraCaps(e.request_extra_caps),e.connection.connect(t)}},{key:"proxyIrcEvents",value:function(){var t=this;this.command_handler.on("all",(function(e,r){t.resetPingTimeoutTimer(),["privmsg","notice","action"].indexOf(e)>-1&&(r.reply=function(e){var n=r.target===t.user.nick?r.nick:r.target;t.say(n,e)},t.command_handler.emit("message",p.extend({type:e},r))),t.parsed_middleware.handle([e,r,t],(function(n){n?console.error(n.stack):t.emit(e,r)}))}))}},{key:"addCommandHandlerListeners",value:function(){var t=this,e=this.command_handler;e.on("nick",(function(e){if(t.user.nick===e.nick){if(e.new_nick.match(/^\d/))return;t.user.nick=e.new_nick}})),e.on("mode",(function(e){t.user.nick===e.target&&e.modes.forEach((function(e){t.user.toggleModes(e.mode)}))})),e.on("wholist",(function(e){var r=p.find(e.users,{nick:t.user.nick});r&&(t.user.username=r.ident,t.user.host=r.hostname)})),e.on("registered",(function(e){t.user.nick=e.nick,t.connection.registeredSuccessfully(),t.emit("connected",e)})),e.on("displayed host",(function(e){t.user.nick===e.nick&&(t.user.host=e.hostname)})),e.on("error",(function(t){}))}},{key:"registerToNetwork",value:function(){var t=this.options.webirc;if(t){var e=String(t.address);":"===e[0]&&(e="0"+e),this.raw("WEBIRC",t.password,t.username,t.hostname,e,E.encode(t.options||{}," "))}this.raw("CAP LS 302"),this.options.password&&this.raw("PASS",this.options.password),this.raw("NICK",this.user.nick),this.raw("USER",this.options.username,0,"*",this.user.gecos)}},{key:"startPeriodicPing",value:function(){var t=this,e=null;function r(){t.ping()}function n(){t.connection.clearTimeout(e),e=t.connection.setTimeout(r,1e3*t.options.ping_interval)}t.options.ping_interval<=0||(t.command_handler.on("pong",n),t.connection.once("socket close",(function(){t.command_handler.off("pong",n)})),n())}},{key:"startPingTimeoutTimer",value:function(){var t=this,e=null;function r(){t.debugOut("Ping timeout ("+t.options.ping_timeout+" seconds)"),t.emit("ping timeout");var e=t.rawString("QUIT","Ping timeout ("+t.options.ping_timeout+" seconds)");t.connection.end(e,!0)}t.options.ping_timeout<=0||(this.resetPingTimeoutTimer=function(){t.connection.clearTimeout(e),e=t.connection.setTimeout(r,1e3*t.options.ping_timeout)},this.resetPingTimeoutTimer())}},{key:"resetPingTimeoutTimer",value:function(){}},{key:"debugOut",value:function(t){this.emit("debug","Client "+t)}},{key:"raw",value:function(t){t instanceof v?this.connection.write(t.to1459()):this.connection.write(this.rawString.apply(this,arguments))}},{key:"rawString",value:function(t){var e;return(e=(e=t.constructor===Array?t:Array.prototype.slice.call(arguments,0)).filter((function(t){return"number"==typeof t||"string"==typeof t}))).length>1&&e[e.length-1].match(/^:|\s/)&&(e[e.length-1]=":"+e[e.length-1]),e.join(" ")}},{key:"quit",value:function(t){this.connection.end(this.rawString("QUIT",t))}},{key:"ping",value:function(t){this.raw("PING",t||Date.now().toString())}},{key:"changeNick",value:function(t){this.raw("NICK",t)}},{key:"sendMessage",value:function(t,e,r,n){var i=this;r.split(/\r\n|\n|\r/).filter((function(t){return t})).forEach((function(r){o(_(r,{bytes:i.options.message_max_length,allowBreakingWords:!0,allowBreakingGraphemes:!0})).forEach((function(r){if(n&&Object.keys(n).length){var o=new v(t,e,r);o.tags=n,i.raw(o)}else i.raw(t,e,r)}))}))}},{key:"say",value:function(t,e,r){return this.sendMessage("PRIVMSG",t,e,r)}},{key:"notice",value:function(t,e,r){return this.sendMessage("NOTICE",t,e,r)}},{key:"tagmsg",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new v("TAGMSG",t);r.tags=e,this.raw(r)}},{key:"join",value:function(t,e){var r=["JOIN",t];e&&r.push(e),this.raw(r)}},{key:"part",value:function(t,e){var r=["PART",t];e&&r.push(e),this.raw(r)}},{key:"mode",value:function(t,e,r){var n=["MODE",t,e];r&&(Array.isArray(r)?n=n.concat(r):n.push(r)),this.raw(n)}},{key:"inviteList",value:function(t,e){var r=this,n=this.network.supports("INVEX"),o="I";function i(n){r.caseCompare(n.channel,t)&&(s(),"function"==typeof e&&e(n))}function a(t){"chanop_privs_needed"===t.error&&(s(),"function"==typeof e&&e(null))}function s(){r.removeListener("inviteList",i),r.removeListener("irc error",a)}"string"==typeof n&&n&&(o=n),r.on("inviteList",i),r.on("irc error",a),this.raw(["MODE",t,o])}},{key:"invite",value:function(t,e){var r=["INVITE",e,t];this.raw(r)}},{key:"addInvite",value:function(t,e){var r="I",n=this.network.supports("INVEX");"string"==typeof n&&(r=n);var o=["MODE",t,"+"+r,e];this.raw(o)}},{key:"removeInvite",value:function(t,e){var r="I",n=this.network.supports("INVEX");"string"==typeof n&&(r=n);var o=["MODE",t,"-"+r,e];this.raw(o)}},{key:"banlist",value:function(t,e){var r=this,n=["MODE",t,"b"];this.on("banlist",(function n(o){r.caseCompare(o.channel,t)&&(r.removeListener("banlist",n),"function"==typeof e&&e(o))})),this.raw(n)}},{key:"ban",value:function(t,e){var r=["MODE",t,"+b",e];this.raw(r)}},{key:"unban",value:function(t,e){var r=["MODE",t,"-b",e];this.raw(r)}},{key:"setTopic",value:function(t,e){e&&e.trim()?this.raw("TOPIC",t,e):this.clearTopic(t)}},{key:"clearTopic",value:function(t){this.raw("TOPIC ".concat(t," :"))}},{key:"ctcpRequest",value:function(t,e){var r=Array.prototype.slice.call(arguments,1);r[0]=r[0].toUpperCase(),this.raw("PRIVMSG",t,String.fromCharCode(1)+r.join(" ")+String.fromCharCode(1))}},{key:"ctcpResponse",value:function(t,e){var r=Array.prototype.slice.call(arguments,1);r[0]=r[0].toUpperCase(),this.raw("NOTICE",t,String.fromCharCode(1)+r.join(" ")+String.fromCharCode(1))}},{key:"action",value:function(t,e){var r=this,n=this.options.message_max_length-9,i=o(_(e,{bytes:n,allowBreakingWords:!0,allowBreakingGraphemes:!0}));return i.forEach((function(e){r.ctcpRequest(t,"ACTION",e)})),i}},{key:"whois",value:function(t,e){var r,n=this,o=["WHOIS"];p.each(arguments,(function(t){"function"==typeof t?r=t:o.push(t)})),this.on("whois",(function e(o){n.caseCompare(o.nick,t)&&(n.removeListener("whois",e),"function"==typeof r&&r(o))})),this.raw(o)}},{key:"whowas",value:function(t,e){var r,n=this,o=["WHOWAS"];p.each(arguments,(function(t){"function"==typeof t?r=t:o.push(t)})),this.on("whowas",(function e(o){n.caseCompare(o.nick,t)&&(n.removeListener("whowas",e),"function"==typeof r&&r(o))})),this.raw(o)}},{key:"who",value:function(t,e){this.who_queue||(this.who_queue=[]),this.who_queue.push([t,e]),this.processNextWhoQueue()}},{key:"monitorlist",value:function(t){var e=this;this.on("monitorList",(function r(n){e.removeListener("monitorList",r),"function"==typeof t&&t(n)})),this.raw(["MONITOR","L"])}},{key:"addMonitor",value:function(t){var e=["MONITOR","+",t];this.raw(e)}},{key:"removeMonitor",value:function(t){var e=["MONITOR","-",t];this.raw(e)}},{key:"queryMonitor",value:function(){this.raw(["MONITOR","S"])}},{key:"clearMonitor",value:function(){this.raw(["MONITOR","C"])}},{key:"processNextWhoQueue",value:function(){var t=this;if(0!==t.who_queue.length&&!t.who_queue.is_running){t.who_queue.is_running=!0;var e=t.who_queue.shift(),r=e[0],n=e[1];if(!r||"string"!=typeof r)return"function"==typeof n&&p.defer(n,{target:r,users:[]}),t.who_queue.is_running=!1,void p.defer(p.bind(t.processNextWhoQueue,t));if(t.on("wholist",(function e(o){t.removeListener("wholist",e),t.who_queue.is_running=!1,p.defer(p.bind(t.processNextWhoQueue,t)),"function"==typeof n&&n({target:r,users:o.users})})),t.network.supports("whox")){var o=t.whox_token.next();t.raw("WHO",r,"%tcuhsnfdaor,".concat(o))}else t.raw("WHO",r)}}},{key:"list",value:function(){var t=Array.prototype.slice.call(arguments);this.command_handler.cache("chanlist").channels=[],t.unshift("LIST"),this.raw(t)}},{key:"channel",value:function(t,e){return new w(this,t,e)}},{key:"match",value:function(t,e,r){var n=this,o=function(r){r.message.match(t)&&e(r)};return this.on(r||"message",o),{stop:function(){n.removeListener(r||"message",o)}}}},{key:"matchNotice",value:function(t,e){return this.match(t,e,"notice")}},{key:"matchMessage",value:function(t,e){return this.match(t,e,"privmsg")}},{key:"matchAction",value:function(t,e){return this.match(t,e,"action")}},{key:"caseCompare",value:function(t,e){var r=t.length;if(r!==e.length)return!1;for(var n=this._getCaseMappingUpperAsciiBound(),o=0;o<r;o++){var i=t.charCodeAt(o),a=e.charCodeAt(o);if(i>=65&&i<=n&&(i+=32),a>=65&&a<=n&&(a+=32),i!==a)return!1}return!0}},{key:"caseLower",value:function(t){for(var e=this._getCaseMappingUpperAsciiBound(),r="",n=0;n<t.length;n++){var o=t.charCodeAt(n);r+=o>=65&&o<=e?String.fromCharCode(o+32):t[n]}return r}},{key:"caseUpper",value:function(t){for(var e=this._getCaseMappingUpperAsciiBound()+32,r="",n=0;n<t.length;n++){var o=t.charCodeAt(n);r+=o>=97&&o<=e?String.fromCharCode(o-32):t[n]}return r}},{key:"_getCaseMappingUpperAsciiBound",value:function(){return"ascii"===this.network.options.CASEMAPPING?90:"strict-rfc1459"===this.network.options.CASEMAPPING?93:94}}],i=[{key:"setDefaultTransport",value:function(t){S=t}}],n&&a(r.prototype,n),i&&a(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(h)},9394:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(52675),r(89463),r(2259),r(23792),r(84185),r(26099),r(47764),r(62953),r(45700),r(89572),r(23288),r(2892),r(27495);var a={clone:r(32629)},s=/^[0-9.]{1,}$/;t.exports=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.command=e+="",this.params=a.clone(r.params),this.tags=a.clone(r.tags),this.prefix=r.prefix,this.nick=r.nick,this.ident=r.ident,this.hostname=r.hostname},(e=[{key:"getTag",value:function(t){return this.tags[t.toLowerCase()]}},{key:"getServerTime",value:function(){var t=this.getTag("time");if(t){var e=Date.parse(t)||void 0;return!e&&s.test(t)?new Date(1e3*t).getTime():e}}}])&&o(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},83947:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}function a(t,e,r){return e=c(e),function(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,s()?Reflect.construct(e,r||[],c(t).constructor):e.apply(t,r))}function s(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(s=function(){return!!t})()}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}r(52675),r(89463),r(2259),r(45700),r(23792),r(89572),r(2892),r(40875),r(60825),r(47764),r(62953),r(28706),r(50113),r(72712),r(34782),r(94170),r(59904),r(84185),r(10287),r(26099);var f={reduce:r(40860),find:r(7309),uniq:r(63375)},l=r(30228),p=r(97575),h=r(9394);t.exports=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=a(this,e)).addAllEventName(),n.client=t,n.connection=t.connection,n.network=t.network,n.handlers=[],n.request_extra_caps=[],n.resetCache(),r(37900)(n),r(76370)(n),r(43538)(n),r(10185)(n),r(66281)(n),r(98675)(n),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}(e,t),n=e,i=[{key:"dispatch",value:function(t){var e=new h(t.command.toUpperCase(),t),r=e.getTag("batch");if(r){var n="batch."+r;this.hasCache(n)&&this.cache(n).commands.push(e)}else this.executeCommand(e)}},{key:"executeCommand",value:function(t){var e=t.command;p[t.command.toUpperCase()]&&(e=p[t.command.toUpperCase()]),this.handlers[e]?this.handlers[e](t,this):this.emitUnknownCommand(t)}},{key:"requestExtraCaps",value:function(t){this.request_extra_caps=f.uniq(this.request_extra_caps.concat(t))}},{key:"addHandler",value:function(t,e){if("function"!=typeof e)return!1;this.handlers[t]=e}},{key:"emitUnknownCommand",value:function(t){this.emit("unknown command",t)}},{key:"addAllEventName",value:function(){var t=this.emit;this.emit=function(){var e=Array.prototype.slice.call(arguments,0);t.apply(this,["all"].concat(e)),t.apply(this,e)}}},{key:"parseModeList",value:function(t,e){var r,n,o,i=this.network.options.CHANMODES||[],a=this.network.options.PREFIX||[],s=(i[0]||"").concat(i[1]||""),c=[];if(!t)return c;a=f.reduce(a,(function(t,e){return t.push(e.mode),t}),[]),s=s.split("").concat(a);var u=function(t,e){var r=function(e){return e===t};return!!f.find(s,r)||!(!e||!f.find((i[2]||"").split(""),r))};for(n=0,r=0;r<t.length;r++)switch(t[r]){case"+":o=!0;break;case"-":o=!1;break;default:u(t[r],o)?(c.push({mode:(o?"+":"-")+t[r],param:e[n]}),n++):c.push({mode:(o?"+":"-")+t[r],param:null})}return c}},{key:"cache",value:function(t){var e,r,n=this._caches[t];return n||(n=Object.defineProperty({},"destroy",{enumerable:!1,configurable:!1,value:(e=this._caches,r=t,function(){delete e[r]})}),this._caches[t]=n),n}},{key:"hasCache",value:function(t){return this._caches&&Object.prototype.hasOwnProperty.call(this._caches,t)}},{key:"resetCache",value:function(){this._caches=Object.create(null)}}],i&&o(n.prototype,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i}(l)},76370:(t,e,r)=>{"use strict";r(34782),r(58940);var n={each:r(76135)},o=r(24113),i={RPL_CHANNELMODEIS:function(t,e){var r=t.params[1],n=t.params[2],o=t.params.slice(3),i=e.parseModeList(n,o);e.emit("channel info",{channel:r,modes:i,raw_modes:n,raw_params:o,tags:t.tags})},RPL_CREATIONTIME:function(t,e){var r=t.params[1];e.emit("channel info",{channel:r,created_at:parseInt(t.params[2],10),tags:t.tags})},RPL_CHANNEL_URL:function(t,e){var r=t.params[1];e.emit("channel info",{channel:r,url:t.params[t.params.length-1],tags:t.tags})},RPL_NAMEREPLY:function(t,e){var r=t.params[t.params.length-1].split(" "),i=e.client.caseLower(t.params[2]),a=e.cache("names."+i);a.members||(a.members=[]),n.each(r,(function(r){if(r){var n,i=0,s=[];if(e.network.options.PREFIX)for(i=0;i<e.network.options.PREFIX.length;i++)r[0]===e.network.options.PREFIX[i].symbol&&(s.push(e.network.options.PREFIX[i].mode),r=r.substring(1));n=o.parseMask(r),a.members.push({nick:n.nick,ident:n.user,hostname:n.host,modes:s,tags:t.tags})}}))},RPL_ENDOFNAMES:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("names."+r);e.emit("userlist",{channel:t.params[1],users:n.members||[],tags:t.tags}),n.destroy()},RPL_INVITELIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("inviteList."+r);n.invites||(n.invites=[]),n.invites.push({channel:t.params[1],invited:t.params[2],invited_by:t.params[3],invited_at:t.params[4],tags:t.tags})},RPL_ENDOFINVITELIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("inviteList."+r);e.emit("inviteList",{channel:t.params[1],invites:n.invites||[],tags:t.tags}),n.destroy()},RPL_BANLIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("banlist."+r);n.bans||(n.bans=[]),n.bans.push({channel:t.params[1],banned:t.params[2],banned_by:t.params[3],banned_at:t.params[4],tags:t.tags})},RPL_ENDOFBANLIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("banlist."+r);e.emit("banlist",{channel:t.params[1],bans:n.bans||[],tags:t.tags}),n.destroy()},RPL_EXCEPTLIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("exceptlist."+r);n.excepts||(n.excepts=[]),n.excepts.push({channel:t.params[1],except:t.params[2],except_by:t.params[3],except_at:t.params[4],tags:t.tags})},RPL_ENDOFEXCEPTLIST:function(t,e){var r=e.client.caseLower(t.params[1]),n=e.cache("exceptlist."+r);e.emit("exceptlist",{channel:t.params[1],excepts:n.excepts||[],tags:t.tags}),n.destroy()},RPL_TOPIC:function(t,e){e.emit("topic",{channel:t.params[1],topic:t.params[t.params.length-1],tags:t.tags,batch:t.batch})},RPL_NOTOPIC:function(t,e){e.emit("topic",{channel:t.params[1],topic:"",tags:t.tags,batch:t.batch})},RPL_TOPICWHOTIME:function(t,e){var r=o.parseMask(t.params[2]);e.emit("topicsetby",{nick:r.nick,ident:r.user,hostname:r.host,channel:t.params[1],when:t.params[3],tags:t.tags})},JOIN:function(t,e){var r,n=1,o={};"string"==typeof t.params[0]&&""!==t.params[0]&&(r=t.params[0]),e.network.cap.isEnabled("extended-join")&&(o.account="*"!==t.params[1]&&t.params[1],n=2),o.nick=t.nick,o.ident=t.ident,o.hostname=t.hostname,o.gecos=t.params[n]||"",o.channel=r,o.time=t.getServerTime(),o.tags=t.tags,o.batch=t.batch,e.emit("join",o)},PART:function(t,e){var r=t.getServerTime();e.emit("part",{nick:t.nick,ident:t.ident,hostname:t.hostname,channel:t.params[0],message:t.params[t.params.length-1]||"",time:r,tags:t.tags,batch:t.batch})},KICK:function(t,e){var r=t.getServerTime();e.emit("kick",{kicked:t.params[1],nick:t.nick,ident:t.ident,hostname:t.hostname,channel:t.params[0],message:t.params[t.params.length-1]||"",time:r,tags:t.tags,batch:t.batch})},QUIT:function(t,e){var r=t.getServerTime();e.emit("quit",{nick:t.nick,ident:t.ident,hostname:t.hostname,message:t.params[t.params.length-1]||"",time:r,tags:t.tags,batch:t.batch})},TOPIC:function(t,e){if(t.params[0]){var r=t.getServerTime(),n=t.params[0],o=t.params[t.params.length-1]||"";e.emit("topic",{nick:t.nick,channel:n,topic:o,time:r,tags:t.tags})}},INVITE:function(t,e){var r=t.getServerTime();e.emit("invite",{nick:t.nick,ident:t.ident,hostname:t.hostname,invited:t.params[0],channel:t.params[1],time:r,tags:t.tags})},RPL_INVITING:function(t,e){var r=t.getServerTime();e.emit("invited",{nick:t.params[1],channel:t.params[2],time:r,tags:t.tags})}};t.exports=function(t){n.each(i,(function(e,r){t.addHandler(r,e)}))}},98675:(t,e,r)=>{"use strict";r(51629),r(79432),r(26099),r(23500);var n={ERROR:{event:"irc error",error:"irc",reason:-1},ERR_PASSWDMISMATCH:{event:"irc error",error:"password_mismatch"},ERR_LINKCHANNEL:{event:"channel_redirect",from:1,to:2},ERR_NOSUCHNICK:{event:"irc error",error:"no_such_nick",nick:1,reason:-1},ERR_NOSUCHSERVER:{event:"irc error",error:"no_such_server",server:1,reason:-1},ERR_CANNOTSENDTOCHAN:{event:"irc error",error:"cannot_send_to_channel",channel:1,reason:-1},ERR_CANNOTSENDTOUSER:{event:"irc error",error:"cannot_send_to_user",nick:1,reason:-1},ERR_TOOMANYCHANNELS:{event:"irc error",error:"too_many_channels",channel:1,reason:-1},ERR_USERNOTINCHANNEL:{event:"irc error",error:"user_not_in_channel",nick:0,channel:1,reason:-1},ERR_NOTONCHANNEL:{event:"irc error",error:"not_on_channel",channel:1,reason:-1},ERR_USERONCHANNEL:{event:"irc error",error:"user_on_channel",nick:1,channel:2},ERR_CHANNELISFULL:{event:"irc error",error:"channel_is_full",channel:1,reason:-1},ERR_INVITEONLYCHAN:{event:"irc error",error:"invite_only_channel",channel:1,reason:-1},ERR_BANNEDFROMCHAN:{event:"irc error",error:"banned_from_channel",channel:1,reason:-1},ERR_BADCHANNELKEY:{event:"irc error",error:"bad_channel_key",channel:1,reason:-1},ERR_CHANOPRIVSNEEDED:{event:"irc error",error:"chanop_privs_needed",channel:1,reason:-1},ERR_UNKNOWNCOMMAND:{event:"irc error",error:"unknown_command",command:1,reason:-1},ERR_YOUREBANNEDCREEP:{event:"irc error",error:"banned_from_network",reason:-1},ERR_MONLISTFULL:{event:"irc error",error:"monitor_list_full",reason:-1}},o=Object.keys(n);t.exports=function(t){o.forEach((function(e){var r=n[e];t.addHandler(e,(function(t,e){for(var n,o={},i=Object.keys(r),a=0;a<i.length;a++)"event"!==i[a]&&("string"==typeof(n=r[i[a]])?o[i[a]]=n:n>=0?o[i[a]]=t.params[n]:n<0&&(o[i[a]]=t.params[t.params.length+n]));if(o.channel){var s=e.network.extractTargetGroup(o.channel);s&&(o.channel=s.target,o.target_group=s.target_group)}e.emit(r.event,o)}))}))}},10185:(t,e,r)=>{"use strict";r(34782);var n={each:r(76135),find:r(7309)},o=r(40537),i={NOTICE:function(t,e){var r,n=t.getServerTime(),o=t.params[t.params.length-1],i=t.params[0];if(""===o.charAt(0)&&""===o.charAt(o.length-1))e.emit("ctcp response",{nick:t.nick,ident:t.ident,hostname:t.hostname,target:i,type:(o.substring(1,o.length-1).split(" ")||[null])[0],message:o.substring(1,o.length-1),time:n,account:t.getTag("account"),tags:t.tags});else{var a=e.network.extractTargetGroup(i);a&&(i=a.target,r=a.target_group),e.emit("notice",{from_server:!t.nick,nick:t.nick,ident:t.ident,hostname:t.hostname,target:i,group:r,message:o,tags:t.tags,time:n,account:t.getTag("account"),batch:t.batch})}},PRIVMSG:function(t,e){var r,n=t.getServerTime(),i=t.params[t.params.length-1],a=t.params[0],s=e.network.extractTargetGroup(a);if(s&&(a=s.target,r=s.target_group),""===i.charAt(0)&&""===i.charAt(i.length-1)){var c=i.slice(1,-1).split(" ")[0].toUpperCase();"ACTION"===c?e.emit("action",{from_server:!t.nick,nick:t.nick,ident:t.ident,hostname:t.hostname,target:a,group:r,message:i.substring(8,i.length-1),tags:t.tags,time:n,account:t.getTag("account"),batch:t.batch}):"VERSION"===c&&e.connection.options.version?e.connection.write(o.format("NOTICE %s :VERSION %s",t.nick,e.connection.options.version)):e.emit("ctcp request",{from_server:!t.nick,nick:t.nick,ident:t.ident,hostname:t.hostname,target:a,group:r,type:c||null,message:i.substring(1,i.length-1),time:n,account:t.getTag("account"),tags:t.tags})}else e.emit("privmsg",{from_server:!t.nick,nick:t.nick,ident:t.ident,hostname:t.hostname,target:a,group:r,message:i,tags:t.tags,time:n,account:t.getTag("account"),batch:t.batch})},TAGMSG:function(t,e){var r=t.getServerTime(),n=t.params[0];e.emit("tagmsg",{from_server:!t.nick,nick:t.nick,ident:t.ident,hostname:t.hostname,target:n,tags:t.tags,time:r,account:t.getTag("account"),batch:t.batch})},RPL_WALLOPS:function(t,e){e.emit("wallops",{from_server:!1,nick:t.nick,ident:t.ident,hostname:t.hostname,message:t.params[t.params.length-1],account:t.getTag("account"),tags:t.tags})}};t.exports=function(t){n.each(i,(function(e,r){t.addHandler(r,e)}))}},66281:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function a(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r(52675),r(89463),r(2259),r(45700),r(2008),r(23792),r(89572),r(2892),r(67945),r(84185),r(83851),r(81278),r(79432),r(47764),r(62953),r(51629),r(25276),r(48598),r(34782),r(54554),r(26099),r(58940),r(27495),r(23500);var s={each:r(76135),clone:r(32629),map:r(55378)},c=r(24113),u={RPL_LISTSTART:function(t,e){f(e).channels=[],e.emit("channel list start")},RPL_LISTEND:function(t,e){var r=f(e);r.channels.length&&(e.emit("channel list",r.channels),r.channels=[]),r.destroy(),e.emit("channel list end")},RPL_LIST:function(t,e){var r=f(e);r.channels.push({channel:t.params[1],num_users:parseInt(t.params[2],10),topic:t.params[3]||"",tags:t.tags}),r.channels.length>=50&&(e.emit("channel list",r.channels),r.channels=[])},RPL_MOTD:function(t,e){e.cache("motd").motd+=t.params[t.params.length-1]+"\n"},RPL_MOTDSTART:function(t,e){e.cache("motd").motd=""},RPL_ENDOFMOTD:function(t,e){var r=e.cache("motd");e.emit("motd",{motd:r.motd,tags:t.tags}),r.destroy()},ERR_NOMOTD:function(t,e){s.clone(t.params).shift(),e.emit("motd",{error:t.params[t.params.length-1],tags:t.tags})},RPL_OMOTD:function(t,e){e.cache("oper motd").motd+=t.params[t.params.length-1]+"\n"},RPL_OMOTDSTART:function(t,e){e.cache("oper motd").motd=""},RPL_ENDOFOMOTD:function(t,e){var r=e.cache("oper motd");e.emit("motd",{motd:r.motd,tags:t.tags}),r.destroy()},ERR_NOOPERMOTD:function(t,e){s.clone(t.params).shift(),e.emit("motd",{error:t.params[t.params.length-1],tags:t.tags})},RPL_WHOREPLY:function(t,e){var r=e.cache("who");r.members||(r.members=[]);var n=t.params,o=c.parseWhoFlags(n[6],e.network.options),a=o.parsedFlags,s=o.unparsedFlags,u=0,f=n[7],l=f.indexOf(" ");l>-1&&(u=parseInt(f.substr(0,l),10),f=f.substr(l+1)),r.members.push(i({nick:n[5],ident:n[2],hostname:n[3],server:n[4],real_name:f,num_hops_away:u,channel:n[1],tags:t.tags,unparsed_flags:s},a))},RPL_WHOSPCRPL:function(t,e){var r=e.cache("who");r.members||(r.members=[],r.type="whox");var n=e.client,o=t.params;if(0!==r.token){if(!r.token){var a=parseInt(o[1],10)||0;if(!a||12!==o.length||!n.whox_token.validate(a))return void(r.token=0);r.token=a}var s=c.parseWhoFlags(o[7],e.network.options),u=s.parsedFlags,f=s.unparsedFlags,l=/^[0-9]+$/.test(o[10])?parseInt(o[10],10):void 0;r.members.push(i({nick:o[6],ident:o[3],hostname:o[4],server:o[5],op_level:l,real_name:o[11],account:"0"===o[9]?"":o[9],num_hops_away:parseInt(o[8],10),channel:o[2],tags:t.tags,unparsed_flags:f},u))}},RPL_ENDOFWHO:function(t,e){var r=e.cache("who");"whox"!==r.type||r.token?(e.emit("wholist",{target:t.params[1],users:r.members||[],tags:t.tags}),r.destroy()):r.destroy()},PING:function(t,e){e.connection.write("PONG "+t.params[t.params.length-1]);var r=t.getServerTime();e.emit("ping",{message:t.params[1],time:r,tags:t.tags})},PONG:function(t,e){var r=t.getServerTime();r&&e.network.addServerTimeOffset(r),e.emit("pong",{message:t.params[1],time:r,tags:t.tags})},MODE:function(t,e){var r=t.getServerTime(),n=t.params[1],o=t.params.slice(2),i=e.parseModeList(n,o);e.emit("mode",{target:t.params[0],nick:t.nick||t.prefix||"",modes:i,time:r,raw_modes:n,raw_params:o,tags:t.tags,batch:t.batch})},RPL_LINKS:function(t,e){var r=e.cache("links");r.links=r.links||[],r.links.push({address:t.params[1],access_via:t.params[2],hops:parseInt(t.params[3].split(" ")[0]),description:t.params[3].split(" ").splice(1).join(" "),tags:t.tags})},RPL_ENDOFLINKS:function(t,e){var r=e.cache("links");e.emit("server links",{links:r.links}),r.destroy()},RPL_INFO:function(t,e){var r=e.cache("info");r.info||(r.info=""),r.info+=t.params[t.params.length-1]+"\n"},RPL_ENDOFINFO:function(t,e){var r=e.cache("info");e.emit("info",{info:r.info,tags:t.tags}),r.destroy()},RPL_HELPSTART:function(t,e){e.cache("help").help=t.params[t.params.length-1]+"\n"},RPL_HELPTXT:function(t,e){e.cache("help").help+=t.params[t.params.length-1]+"\n"},RPL_ENDOFHELP:function(t,e){var r=e.cache("help");e.emit("help",{help:r.help,tags:t.tags}),r.destroy()},BATCH:function(t,e){var r="+"===t.params[0].substr(0,1),n=t.params[0].substr(1),o="batch."+n;if(n){if(r){var i=e.cache(o);return i.commands=[],i.type=t.params[1],void(i.params=t.params.slice(2))}if(e.hasCache(o)){var a=e.cache(o),s={id:n,type:a.type,params:a.params,commands:a.commands};a.destroy(),e.emit("batch start",s),e.emit("batch start "+s.type,s),s.commands.forEach((function(t){t.batch={id:n,type:a.type,params:a.params},e.executeCommand(t)})),e.emit("batch end",s),e.emit("batch end "+s.type,s)}}}};function f(t){var e=t.cache("chanlist");return e.channels||(e.channels=[]),e}t.exports=function(t){s.each(u,(function(e,r){t.addHandler(r,e)}))}},37900:(t,e,r)=>{"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r(52675),r(89463),r(2259),r(23418),r(64346),r(23792),r(34782),r(47764),r(62953),r(28706),r(2008),r(74423),r(25276),r(48598),r(62062),r(59089),r(23288),r(62010),r(59904),r(26099),r(58940),r(27495),r(38781),r(21699),r(71761),r(25440);var o=r(24113),i={intersection:r(5287),difference:r(66245),each:r(76135),uniq:r(63375)},a={RPL_WELCOME:function(t,e){var r=t.params[0];e.network.server=t.prefix,e.network.cap.negotiating=!1,e.network.cap.isEnabled("server-time")&&e.connection.write("PING "+Date.now()),e.emit("registered",{nick:r,tags:t.tags})},RPL_YOURHOST:function(t,e){var r=(t.params[1]||"").match(/running version (.*)$/);e.network.ircd=r?r[1]:""},RPL_ISUPPORT:function(t,e){var r,n,i,a,s=t.params;for(r=1;r<s.length;r++)if((n=o.splitOnce(s[r],"="))[0]=n[0].toUpperCase(),n[1]&&(n[1]=n[1].replace(/\\x([0-9A-Fa-f]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))}))),e.network.options[n[0]]=void 0===n[1]||n[1],"PREFIX"===n[0])if((i=/\(([^)]*)\)(.*)/.exec(n[1]))&&3===i.length)for(e.network.options.PREFIX=[],a=0;a<i[2].length;a++)e.network.options.PREFIX.push({symbol:i[2].charAt(a),mode:i[1].charAt(a)});else""===n[1]&&(e.network.options.PREFIX=[]);else"CHANTYPES"===n[0]?e.network.options.CHANTYPES=e.network.options.CHANTYPES.split(""):"STATUSMSG"===n[0]?e.network.options.STATUSMSG=e.network.options.STATUSMSG.split(""):"CHANMODES"===n[0]?e.network.options.CHANMODES=n[1].split(","):"CASEMAPPING"===n[0]?e.network.options.CASEMAPPING=n[1]:"CLIENTTAGDENY"===n[0]?e.network.options.CLIENTTAGDENY=n[1].split(",").filter((function(t){return!!t})):"NETWORK"===n[0]?e.network.name=n[1]:"NAMESX"!==n[0]||e.network.cap.isEnabled("multi-prefix")||e.connection.write("PROTOCTL NAMESX");e.emit("server options",{options:e.network.options,cap:e.network.cap.enabled,tags:t.tags})},CAP:function(t,e){var r=[],o=Object.create(null),a=t.params[t.params.length-1].replace(/(?:^| )[-~=]/,"").split(" ").filter((function(t){return!!t})).map((function(r){var n=r.indexOf("=");if(-1===n)return o[r]="","LS"!==t.params[1]&&"NEW"!==t.params[1]||e.network.cap.available.set(r,""),r;var i=r.substr(0,n),a=r.substr(n+1);return o[i]=a,"LS"!==t.params[1]&&"NEW"!==t.params[1]||e.network.cap.available.set(i,a),i})),u=["cap-notify","batch","multi-prefix","message-tags","draft/message-tags-0.2","away-notify","invite-notify","account-notify","account-tag","server-time","userhost-in-names","extended-join","znc.in/server-time-iso","znc.in/server-time"],f=s(e);switch((f||"EXTERNAL"===e.connection.options.sasl_mechanism)&&u.push("sasl"),e.connection.options.enable_chghost&&u.push("chghost"),e.connection.options.enable_setname&&u.push("setname"),e.connection.options.enable_echomessage&&u.push("echo-message"),u=i.uniq(u.concat(e.request_extra_caps)),t.params[1]){case"LS":(r=i.intersection(a,u)).length>0&&(e.network.cap.requested=e.network.cap.requested.concat(r)),"*"!==t.params[2]&&(e.network.cap.requested.length>0?(e.network.cap.negotiating=!0,e.connection.write("CAP REQ :"+e.network.cap.requested.join(" "))):(e.connection.write("CAP END"),e.network.cap.negotiating=!1));break;case"ACK":if(a.length>0&&(e.network.cap.enabled=i.uniq(e.network.cap.enabled.concat(a)),e.network.cap.requested=i.difference(e.network.cap.requested,a)),e.network.cap.negotiating){var l=!1;if(e.network.cap.isEnabled("sasl")){var p=e.connection.options.sasl_mechanism,h="string"==typeof p?p.toUpperCase():"PLAIN",d=e.network.cap.available.get("sasl"),y=d.toUpperCase().split(",");!d||y.includes(h)?(e.connection.write("AUTHENTICATE "+h),l=!0):c(e,"unsupported_mechanism")}else(f||"EXTERNAL"===e.connection.options.sasl_mechanism)&&c(e,"capability_missing");l||0!==e.network.cap.requested.length||(e.connection.write("CAP END"),e.network.cap.negotiating=!1)}break;case"NAK":a.length>0&&(e.network.cap.requested=i.difference(e.network.cap.requested,a)),e.network.cap.negotiating&&0===e.network.cap.requested.length&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1);break;case"LIST":break;case"NEW":r=[];for(var v=0;v<a.length;v++){var g=a[v];u.indexOf(g)>-1&&-1===r.indexOf(g)&&!e.network.cap.isEnabled(g)&&(e.network.cap.requested.push(g),r.push(g))}e.connection.write("CAP REQ :"+r.join(" "));break;case"DEL":e.network.cap.enabled=i.difference(e.network.cap.enabled,a);var m,b=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}(a);try{for(b.s();!(m=b.n()).done;){var w=m.value;e.network.cap.available.delete(w)}}catch(t){b.e(t)}finally{b.f()}}e.emit("cap "+t.params[1].toLowerCase(),{command:t.params[1],capabilities:o})},AUTHENTICATE:function(t,e){if("+"===t.params[0])if("EXTERNAL"!==e.connection.options.sasl_mechanism){for(var r=s(e),n=r.account+"\0"+r.account+"\0"+r.password,o=Buffer.from(n,"utf8").toString("base64"),i=0;o.length>i;)e.connection.write("AUTHENTICATE "+o.substr(i,400)),i+=400;o.length===i&&e.connection.write("AUTHENTICATE +")}else e.connection.write("AUTHENTICATE +");else e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},RPL_LOGGEDIN:function(t,e){!0===e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1);var r=o.parseMask(t.params[1]),n=t.getServerTime();e.emit("loggedin",{nick:t.params[0],ident:r.user,hostname:r.host,account:t.params[2],time:n,tags:t.tags}),e.emit("account",{nick:t.params[0],ident:r.user,hostname:r.host,account:t.params[2],time:n,tags:t.tags})},RPL_LOGGEDOUT:function(t,e){var r=o.parseMask(t.params[1]),n=t.getServerTime();e.emit("loggedout",{nick:t.params[0],ident:r.user,hostname:r.host,account:!1,time:n,tags:t.tags}),e.emit("account",{nick:t.params[0],ident:r.user,hostname:r.host,account:!1,time:n,tags:t.tags})},RPL_SASLLOGGEDIN:function(t,e){e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},ERR_NICKLOCKED:function(t,e){c(e,"nick_locked",t),e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},ERR_SASLFAIL:function(t,e){c(e,"fail",t),e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},ERR_SASLTOOLONG:function(t,e){c(e,"too_long",t),e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},ERR_SASLABORTED:function(t,e){e.network.cap.negotiating&&(e.connection.write("CAP END"),e.network.cap.negotiating=!1)},ERR_SASLALREADYAUTHED:function(t,e){}};function s(t){var e=t.connection.options;return e.account&&e.account.account?{account:e.account.account,password:e.account.password||""}:e.account?null:e.password?{account:e.nick,password:e.password}:null}function c(t,e,r){var n={reason:e};if(r){var o=r.getServerTime();n.message=r.params[r.params.length-1],n.nick=r.params[0],n.time=o,n.tags=r.tags}t.emit("sasl failed",n),t.connection.options.sasl_disconnect_on_fail&&t.network.cap.negotiating&&t.connection.end()}t.exports=function(t){i.each(a,(function(e,r){t.addHandler(r,e)}))}},43538:(t,e,r)=>{"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}r(52675),r(89463),r(2259),r(23418),r(64346),r(23792),r(34782),r(23288),r(62010),r(26099),r(38781),r(47764),r(62953),r(25276),r(62062),r(69085),r(27495),r(71761);var o={each:r(76135),map:r(55378)},i=r(24113),a={NICK:function(t,e){var r=t.getServerTime();e.emit("nick",{nick:t.nick,ident:t.ident,hostname:t.hostname,new_nick:t.params[0],time:r,tags:t.tags,batch:t.batch})},ACCOUNT:function(t,e){var r=t.getServerTime(),n="*"!==t.params[0]&&t.params[0];e.emit("account",{nick:t.nick,ident:t.ident,hostname:t.hostname,account:n,time:r,tags:t.tags})},CHGHOST:function(t,e){var r=t.getServerTime();e.emit("user updated",{nick:t.nick,ident:t.ident,hostname:t.hostname,new_ident:t.params[0],new_hostname:t.params[1],time:r,tags:t.tags,batch:t.batch})},SETNAME:function(t,e){var r=t.getServerTime();e.emit("user updated",{nick:t.nick,ident:t.ident,hostname:t.hostname,new_gecos:t.params[0],time:r,tags:t.tags,batch:t.batch})},AWAY:function(t,e){var r=t.getServerTime(),n=t.params[t.params.length-1]||"";""===n?e.emit("back",{self:!1,nick:t.nick,message:"",time:r,tags:t.tags}):e.emit("away",{self:!1,nick:t.nick,message:n,time:r,tags:t.tags})},RPL_NOWAWAY:function(t,e){var r=t.getServerTime();e.emit("away",{self:!0,nick:t.params[0],message:t.params[1]||"",time:r,tags:t.tags})},RPL_UNAWAY:function(t,e){var r=t.getServerTime();e.emit("back",{self:!0,nick:t.params[0],message:t.params[1]||"",time:r,tags:t.tags})},RPL_ISON:function(t,e){e.emit("users online",{nicks:(t.params[t.params.length-1]||"").split(" "),tags:t.tags})},ERR_NICKNAMEINUSE:function(t,e){e.emit("nick in use",{nick:t.params[1],reason:t.params[t.params.length-1],tags:t.tags})},ERR_ERRONEOUSNICKNAME:function(t,e){e.emit("nick invalid",{nick:t.params[1],reason:t.params[t.params.length-1],tags:t.tags})},RPL_ENDOFWHOIS:function(t,e){var r=t.params[1].toLowerCase(),n=e.cache("whois."+r);n.nick||(n.nick=t.params[1],n.error="not_found"),e.emit("whois",n),n.destroy()},RPL_AWAY:function(t,e){var r="whois."+t.params[1].toLowerCase(),n=t.params[t.params.length-1]||"is away";if(e.hasCache(r))e.cache(r).away=n;else{var o=t.getServerTime();e.emit("away",{self:!1,nick:t.params[1],message:n,time:o,tags:t.tags})}},RPL_WHOISUSER:function(t,e){var r=t.params[1].toLowerCase(),n=e.cache("whois."+r);n.nick=t.params[1],n.ident=t.params[2],n.hostname=t.params[3],n.real_name=t.params[5]},RPL_WHOISHELPOP:function(t,e){var r=t.params[1].toLowerCase();e.cache("whois."+r).helpop=t.params[t.params.length-1]},RPL_WHOISBOT:function(t,e){var r=t.params[1].toLowerCase();e.cache("whois."+r).bot=t.params[t.params.length-1]},RPL_WHOISSERVER:function(t,e){var r=t.params[1].toLowerCase(),n=e.cache("whois."+r);n.server=t.params[2],n.server_info=t.params[t.params.length-1]},RPL_WHOISOPERATOR:function(t,e){var r=t.params[1].toLowerCase();e.cache("whois."+r).operator=t.params[t.params.length-1]},RPL_WHOISCHANNELS:function(t,e){var r=t.params[1].toLowerCase(),n=e.cache("whois."+r);n.channels?n.channels+=" "+t.params[t.params.length-1]:n.channels=t.params[t.params.length-1]},RPL_WHOISMODES:function(t,e){var r=t.params[1].toLowerCase();e.cache("whois."+r).modes=t.params[t.params.length-1]},RPL_WHOISIDLE:function(t,e){var r=t.params[1].toLowerCase(),n=e.cache("whois."+r);n.idle=t.params