text: !function i(r,a,c){function l(t,e){if(!a[t]){if(!r[t]){var s="function"==typeof require&&require;if(!e&&s)return s(t,!0);if(u)return u(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[t]={exports:{}};r[t][0].call(o.exports,function(e){return l(r[t][1][e]||e)},o,o.exports,i,r,a,c)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)l(c[e]);return l}({1:[function(e,t,s){var o=e("tmi.js"),i="",r=null,k={isDebug:!1,chatModes:{},version:function(){return"1.0.10"},onCommand:function(e,t,s,n,o){k.isDebug&&console.log("onCommand default handler")},onChat:function(e,t,s,n,o){k.isDebug&&console.log("onChat default handler")},onWhisper:function(e,t,s,n,o){k.isDebug&&console.log("onWhisper default handler")},onMessageDeleted:function(e,t){k.isDebug&&console.log("onMessageDeleted default handler")},onJoin:function(e,t){k.isDebug&&console.log("onJoin default handler")},onPart:function(e,t){k.isDebug&&console.log("onPart default handler")},onHosted:function(e,t,s){k.isDebug&&console.log("onHosted default handler")},onRaid:function(e,t){k.isDebug&&console.log("onRaid default handler")},onSub:function(e,t,s,n){k.isDebug&&console.log("onSub default handler")},onResub:function(e,t,s,n,o,i){k.isDebug&&console.log("onResub default handler")},onSubGift:function(e,t,s,n,o,i){k.isDebug&&console.log("onSubGift default handler")},onSubMysteryGift:function(e,t,s,n,o){k.isDebug&&console.log("onSubMysteryGift default handler")},onGiftSubContinue:function(e,t,s){k.isDebug&&console.log("onGiftSubContinue default handler")},onCheer:function(e,t,s){k.isDebug&&console.log("onCheer default handler")},onChatMode:function(e,t){k.isDebug&&console.log("onChatMode default handler")},Say:function(e,t){return!!r&&(t||(t=i),r.say(t,e).catch(function(e){console.log("Error:",e)}),!0)},Whisper:function(e,t){return!!r&&(r.whisper(t,e).catch(function(e){console.log("Error:",e)}),!0)},DeleteMessage:function(e,t){return!!r&&(t||(t=i),r.deletemessage(t,e).catch(function(e){console.log("Error:",e)}),!0)},GetClient:function(){return r},Init:function(C,e,t,s){if(("string"==typeof(t=t||[C])||t instanceof String)&&(t=[t]),!Array.isArray(t))throw new Error("Channels is not an array");k.isDebug=s,i=t[0];var n={options:{debug:s},connection:{reconnect:!0,secure:!0},channels:t};e&&(n.identity={username:C,password:e}),(r=new o.client(n)).on("roomstate",function(e,t){try{var s=e.replace("#","");k.chatModes[s]=k.chatModes[s]||{},"emote-only"in t&&(k.chatModes[s].emoteOnly=t["emote-only"]),"followers-only"in t&&(k.chatModes[s].followerOnly=0<=t["followers-only"]),"subs-only"in t&&(k.chatModes[s].subOnly=t["subs-only"]),"r9k"in t&&(k.chatModes[s].r9kMode=t.r9k),"slow"in t&&(k.chatModes[s].slowMode=t.slow),k.onChatMode(k.chatModes[s],s)}catch(e){console.log("Error:",e)}}),r.on("message",function(e,t,s,n){try{var o=t["display-name"]||t.username||C,i="#"+t.username===e,r=t.mod,a=t.badges&&void 0!==t.badges.subscriber||t.subscriber,c=t.badges&&"1"===t.badges.vip||!1,l=t["user-id"],u=t.id,m=t["room-id"],h=t.badges,f=t.color,d=t.emotes,p=t["emote-only"]||!1,g=t["message-type"],_={broadcaster:i,mod:r,subscriber:a,vip:c},b={id:u,roomId:m,messageType:g,messageEmotes:d,isEmoteOnly:p,userId:l,username:t.username,displayName:t["display-name"],userColor:f,userBadges:h};if(n||"!"!==s[0])"action"===g||"chat"===g?k.onChat(o,s,_,n,b):"whisper"===g&&k.onWhisper(o,s,_,n,b);else{var y=s.split(/ (.*)/),v=y[0].slice(1).toLowerCase(),w=y[1]||"";k.onCommand(o,v,w,_,b)}}catch(e){console.log("Error:",e)}}),r.on("messagedeleted",function(e,t,s,n){try{var o=n["target-msg-id"],i={id:o,roomId:n["room-id"],username:t,message:s};k.onMessageDeleted(o,i)}catch(e){console.log("Error:",e)}}),r.on("join",function(e,t,s){k.onJoin(t,s)}),r.on("part",function(e,t,s){k.onPart(t,s)}),r.on("hosted",function(e,t,s,n){k.onHosted(t,s,n)}),r.on("raided",function(e,t,s){k.onRaid(t,s)}),r.on("cheer",function(e,t,s){var n=~~t.bits,o={id:t.id,username:t.login,userColor:t.color,userBadges:t.badges,displayName:t["display-name"],messageEmotes:t.emotes,subscriber:t.subscriber};k.onCheer(s,n,o)}),r.on("subscription",function(e,t,s,n,o){var i={id:o.id,roomId:o["room-id"],messageType:o["message-type"],messageEmotes:o.emotes,userId:o["user-id"],username:o.login,displayName:o["display-name"],userColor:o.color,userBadges:o.badges};k.onSub(t,n,s,i)}),r.on("resub",function(e,t,s,n,o,i){var r=~~o["msg-param-cumulative-months"],a={id:o.id,roomId:o["room-id"],messageType:o["message-type"],messageEmotes:o.emotes,userId:o["user-id"],username:o.login,displayName:o["display-name"],userColor:o.color,userBadges:o.badges};k.onResub(t,n,s,r,i,a)}),r.on("subgift",function(e,t,s,n,o,i){var r=~~i["msg-param-sender-count"],a={id:i.id,roomId:i["room-id"],messageType:i["message-type"],messageEmotes:i.emotes,userId:i["user-id"],username:i.login,displayName:i["display-name"],userColor:i.color,userBadges:i.badges,recipientDisplayName:i["msg-param-recipient-display-name"],recipientUsername:i["msg-param-recipient-user-name"],recipientId:i["msg-param-recipient-id"]};k.onSubGift(t,s,n,r,o,a)}),r.on("submysterygift",function(e,t,s,n,o){var i=~~o["msg-param-sender-count"],r={id:o.id,roomId:o["room-id"],messageType:o["message-type"],messageEmotes:o.emotes,userId:o["user-id"],username:o.login,displayName:o["display-name"],userColor:o.color,userBadges:o.badges,recipientDisplayName:o["msg-param-recipient-display-name"],recipientUsername:o["msg-param-recipient-user-name"],recipientId:o["msg-param-recipient-id"],userMassGiftCount:~~o["msg-param-mass-gift-count"]};k.onSubMysteryGift(t,s,i,n,r)}),r.on("giftpaidupgrade",function(e,t,s,n){var o={id:n.id,roomId:n["room-id"],messageType:n["message-type"],messageEmotes:n.emotes,userId:n["user-id"],username:n.login,displayName:n["display-name"],userColor:n.color,userBadges:n.badges,gifterUsername:n["msg-param-sender-login"],gifterDisplayName:n["msg-param-sender-name"]};k.onGiftSubContinue(t,s,o)}),r.on("connected",function(e,t){console.log("Connected:"+e+":"+t)}),r.on("reconnect",function(){console.log("Reconnecting")}),r.connect().catch(function(e){console.log("Error:",e)})}};void 0!==t&&t.exports&&(t.exports=k),"undefined"!=typeof window&&(window.ComfyJS=k,o=window.tmi)},{"tmi.js":2}],2:[function(m,e,t){(function(t){!function i(r,a,c){function l(t,e){if(!a[t]){if(!r[t]){var s="function"==typeof m&&m;if(!e&&s)return s(t,!0);if(u)return u(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var o=a[t]={exports:{}};r[t][0].call(o.exports,function(e){return l(r[t][1][e]||e)},o,o.exports,i,r,a,c)}return a[t].exports}for(var u="function"==typeof m&&m,e=0;e<c.length;e++)l(c[e]);return l}({1:[function(e,t,s){"use strict";t.exports={client:e("./lib/client"),Client:e("./lib/client")}},{"./lib/client":3}],2:[function(e,t,s){"use strict";var a=e("request"),c=e("./utils");t.exports=function(e,t){var s=null===c.get(e.url,null)?c.get(e.uri,null):c.get(e.url,null);if(c.isURL(s)||(s="https://api.twitch.tv/kraken"+("/"===s[0]?s:"/"+s)),c.isNode())a(c.merge({method:"GET",json:!0},e,{url:s}),t);else if(c.isExtension()){e=c.merge({url:s,method:"GET",headers:{}},e);var n=new XMLHttpRequest;for(var o in n.open(e.method,e.url,!0),e.headers)n.setRequestHeader(o,e.headers[o]);n.responseType="json",n.addEventListener("load",function(e){4==n.readyState&&(200!=n.status?t(n.status,null,null):t(null,null,n.response))}),n.send()}else{var i="jsonp_callback_"+Math.round(1e5*Math.random());window[i]=function(e){delete window[i],document.body.removeChild(r),t(null,null,e)};var r=document.createElement("script");r.src=s+(s.includes("?")?"&":"?")+"callback="+i,document.body.appendChild(r)}}},{"./utils":10,request:11}],3:[function(l,u,e){(function(e){"use strict";var t=l("./api"),s=l("./commands"),n=l("./events").EventEmitter,o=l("./logger"),B=l("./parser"),F=l("./timer"),i=l("./extra-utils"),r=e.WebSocket||e.MozWebSocket||l("ws"),V=l("./utils"),a=function e(t){if(this instanceof e==0)return new e(t);this.setMaxListeners(0),this.opts=V.get(t,{}),this.opts.channels=this.opts.channels||[],this.opts.connection=this.opts.connection||{},this.opts.identity=this.opts.identity||{},this.opts.options=this.opts.options||{},this.clientId=V.get(this.opts.options.clientId,null),this.maxReconnectAttempts=V.get(this.opts.connection.maxReconnectAttempts,1/0),this.maxReconnectInterval=V.get(this.opts.connection.maxReconnectInterval,3e4),this.reconnect=V.get(this.opts.connection.reconnect,!1),this.reconnectDecay=V.get(this.opts.connection.reconnectDecay,1.5),this.reconnectInterval=V.get(this.opts.connection.reconnectInterval,1e3),this.reconnecting=!1,this.reconnections=0,this.reconnectTimer=this.reconnectInterval,this.secure=V.get(this.opts.connection.secure,!1),this.emotes="",this.emotesets={},this.channels=[],this.currentLatency=0,this.globaluserstate={},this.lastJoined="",this.latency=new Date,this.moderators={},this.pingLoop=null,this.pingTimeout=null,this.reason="",this.username="",this.userstate={},this.wasCloseCalled=!1,this.ws=null;var s="error";this.opts.options.debug&&(s="info"),this.log=this.opts.logger||o;try{o.setLevel(s)}catch(e){}this.opts.channels.forEach(function(e,t,s){s[t]=V.channel(e)}),n.call(this)};for(var c in V.inherits(a,n),a.prototype.api=t,s)a.prototype[c]=s[c];a.prototype.handleMessage=function(t){var e=this;if(!V.isNull(t)){this.emit("raw_message",JSON.parse(JSON.stringify(t)),t);var s=V.channel(V.get(t.params[0],null)),n=V.get(t.params[1],null),o=V.get(t.tags["msg-id"],null);if(t.tags=B.badges(B.emotes(t.tags)),t.tags)for(var i in t.tags)"emote-sets"!==i&&"ban-duration"!==i&&"bits"!==i&&(V.isBoolean(t.tags[i])?t.tags[i]=null:"1"===t.tags[i]?t.tags[i]=!0:"0"===t.tags[i]&&(t.tags[i]=!1));if(V.isNull(t.prefix))switch(t.command){case"PING":this.emit("ping"),V.isNull(this.ws)||2===this.ws.readyState||3===this.ws.readyState||this.ws.send("PONG");break;case"PONG":var r=new Date;this.currentLatency=(r.getTime()-this.latency.getTime())/1e3,this.emits(["pong","_promisePing"],[[this.currentLatency]]),clearTimeout(this.pingTimeout);break;default:this.log.warn("Could not parse message with no prefix:\n"+JSON.stringify(t,null,4))}else if("tmi.twitch.tv"===t.prefix)switch(t.command){case"002":case"003":case"004":case"375":case"376":case"CAP":break;case"001":this.username=t.params[0];break;case"372":this.log.info("Connected to server."),this.userstate["#tmijs"]={},this.emits(["connected","_promiseConnect"],[[this.server,this.port],[null]]),this.reconnections=0,this.reconnectTimer=this.reconnectInterval,this.pingLoop=setInterval(function(){V.isNull(e.ws)||2===e.ws.readyState||3===e.ws.readyState||e.ws.send("PING"),e.latency=new Date,e.pingTimeout=setTimeout(function(){V.isNull(e.ws)||(e.wasCloseCalled=!1,e.log.error("Ping timeout."),e.ws.close(),clearInterval(e.pingLoop),clearTimeout(e.pingTimeout))},V.get(e.opts.connection.timeout,9999))},6e4);var a=new F.queue(2e3),c=V.union(this.opts.channels,this.channels);this.channels=[];for(var l=0;l<c.length;l++){var u=this;a.add(function(e){V.isNull(u.ws)||2===u.ws.readyState||3===u.ws.readyState||u.ws.send("JOIN "+V.channel(c[e]))}.bind(this,l))}a.run();break;case"NOTICE":var m=[null],h=[s,o,n],f=[s,!0],d=[s,!1],p=[h,m],g=[h,[o]],_="["+s+"] "+n;switch(o){case"subs_on":this.log.info("["+s+"] This room is now in subscribers-only mode."),this.emits(["subscriber","subscribers","_promiseSubscribers"],[f,f,m]);break;case"subs_off":this.log.info("["+s+"] This room is no longer in subscribers-only mode."),this.emits(["subscriber","subscribers","_promiseSubscribersoff"],[d,d,m]);break;case"emote_only_on":this.log.info("["+s+"] This room is now in emote-only mode."),this.emits(["emoteonly","_promiseEmoteonly"],[f,m]);break;case"emote_only_off":this.log.info("["+s+"] This room is no longer in emote-only mode."),this.emits(["emoteonly","_promiseEmoteonlyoff"],[d,m]);break;case"slow_on":case"slow_off":break;case"followers_on_zero":case"followers_on":case"followers_off":break;case"r9k_on":this.log.info("["+s+"] This room is now in r9k mode."),this.emits(["r9kmode","r9kbeta","_promiseR9kbeta"],[f,f,m]);break;case"r9k_off":this.log.info("["+s+"] This room is no longer in r9k mode."),this.emits(["r9kmode","r9kbeta","_promiseR9kbetaoff"],[d,d,m]);break;case"room_mods":var b=n.split(": ")[1].toLowerCase().split(", ").filter(function(e){return e});this.emits(["_promiseMods","mods"],[[null,b],[s,b]]);break;case"no_mods":this.emits(["_promiseMods","mods"],[[null,[]],[s,[]]]);break;case"vips_success":n.endsWith(".")&&(n=n.slice(0,-1));var y=n.split(": ")[1].toLowerCase().split(", ").filter(function(e){return e});this.emits(["_promiseVips","vips"],[[null,y],[s,y]]);break;case"no_vips":this.emits(["_promiseVips","vips"],[[null,[]],[s,[]]]);break;case"already_banned":case"bad_ban_admin":case"bad_ban_broadcaster":case"bad_ban_global_mod":case"bad_ban_self":case"bad_ban_staff":case"usage_ban":this.log.info(_),this.emits(["notice","_promiseBan"],g);break;case"ban_success":this.log.info(_),this.emits(["notice","_promiseBan"],p);break;case"usage_clear":this.log.info(_),this.emits(["notice","_promiseClear"],g);break;case"usage_mods":this.log.info(_),this.emits(["notice","_promiseMods"],[h,[o,[]]]);break;case"mod_success":this.log.info(_),this.emits(["notice","_promiseMod"],p);break;case"usage_vips":this.log.info(_),this.emits(["notice","_promiseVips"],[h,[o,[]]]);break;case"usage_vip":case"bad_vip_grantee_banned":case"bad_vip_grantee_already_vip":this.log.info(_),this.emits(["notice","_promiseVip"],[h,[o,[]]]);break;case"vip_success":this.log.info(_),this.emits(["notice","_promiseVip"],p);break;case"usage_mod":case"bad_mod_banned":case"bad_mod_mod":this.log.info(_),this.emits(["notice","_promiseMod"],g);break;case"unmod_success":this.log.info(_),this.emits(["notice","_promiseUnmod"],p);break;case"unvip_success":this.log.info(_),this.emits(["notice","_promiseUnvip"],p);break;case"usage_unmod":case"bad_unmod_mod":this.log.info(_),this.emits(["notice","_promiseUnmod"],g);break;case"usage_unvip":case"bad_unvip_grantee_not_vip":this.log.info(_),this.emits(["notice","_promiseUnvip"],g);break;case"color_changed":this.log.info(_),this.emits(["notice","_promiseColor"],p);break;case"usage_color":case"turbo_only_color":this.log.info(_),this.emits(["notice","_promiseColor"],g);break;case"commercial_success":this.log.info(_),this.emits(["notice","_promiseCommercial"],p);break;case"usage_commercial":case"bad_commercial_error":this.log.info(_),this.emits(["notice","_promiseCommercial"],g);break;case"hosts_remaining":this.log.info(_);var v=isNaN(n[0])?0:parseInt(n[0]);this.emits(["notice","_promiseHost"],[h,[null,~~v]]);break;case"bad_host_hosting":case"bad_host_rate_exceeded":case"bad_host_error":case"usage_host":this.log.info(_),this.emits(["notice","_promiseHost"],[h,[o,null]]);break;case"already_r9k_on":case"usage_r9k_on":this.log.info(_),this.emits(["notice","_promiseR9kbeta"],g);break;case"already_r9k_off":case"usage_r9k_off":this.log.info(_),this.emits(["notice","_promiseR9kbetaoff"],g);break;case"timeout_success":this.log.info(_),this.emits(["notice","_promiseTimeout"],p);break;case"delete_message_success":this.log.info("["+s+" "+n+"]"),this.emits(["notice","_promiseDeletemessage"],p);case"already_subs_off":case"usage_subs_off":this.log.info(_),this.emits(["notice","_promiseSubscribersoff"],g);break;case"already_subs_on":case"usage_subs_on":this.log.info(_),this.emits(["notice","_promiseSubscribers"],g);break;case"already_emote_only_off":case"usage_emote_only_off":this.log.info(_),this.emits(["notice","_promiseEmoteonlyoff"],g);break;case"already_emote_only_on":case"usage_emote_only_on":this.log.info(_),this.emits(["notice","_promiseEmoteonly"],g);break;case"usage_slow_on":this.log.info(_),this.emits(["notice","_promiseSlow"],g);break;case"usage_slow_off":this.log.info(_),this.emits(["notice","_promiseSlowoff"],g);break;case"usage_timeout":case"bad_timeout_admin":case"bad_timeout_broadcaster":case"bad_timeout_duration":case"bad_timeout_global_mod":case"bad_timeout_self":case"bad_timeout_staff":this.log.info(_),this.emits(["notice","_promiseTimeout"],g);break;case"untimeout_success":case"unban_success":this.log.info(_),this.emits(["notice","_promiseUnban"],p);break;case"usage_unban":case"bad_unban_no_ban":this.log.info(_),this.emits(["notice","_promiseUnban"],g);break;case"usage_delete":case"bad_delete_message_error":case"bad_delete_message_broadcaster":case"bad_delete_message_mod":this.log.info(_),this.emits(["notice","_promiseDeletemessage"],g);break;case"usage_unhost":case"not_hosting":this.log.info(_),this.emits(["notice","_promiseUnhost"],g);break;case"whisper_invalid_login":case"whisper_invalid_self":case"whisper_limit_per_min":case"whisper_limit_per_sec":case"whisper_restricted_recipient":this.log.info(_),this.emits(["notice","_promiseWhisper"],g);break;case"no_permission":case"msg_banned":case"msg_room_not_found":case"msg_channel_suspended":case"tos_ban":this.log.info(_),this.emits(["notice","_promiseBan","_promiseClear","_promiseUnban","_promiseTimeout","_promiseDeletemessage","_promiseMods","_promiseMod","_promiseUnmod","_promiseVips","_promiseVip","_promiseUnvip","_promiseCommercial","_promiseHost","_promiseUnhost","_promiseJoin","_promisePart","_promiseR9kbeta","_promiseR9kbetaoff","_promiseSlow","_promiseSlowoff","_promiseFollowers","_promiseFollowersoff","_promiseSubscribers","_promiseSubscribersoff","_promiseEmoteonly","_promiseEmoteonlyoff"],g);break;case"unrecognized_cmd":this.log.info(_),this.emit("notice",s,o,n),"/w"===n.split(" ").splice(-1)[0]&&this.log.warn("You must be connected to a group server to send or receive whispers.");break;case"cmds_available":case"host_target_went_offline":case"msg_censored_broadcaster":case"msg_duplicate":case"msg_emoteonly":case"msg_verified_email":case"msg_ratelimit":case"msg_subsonly":case"msg_timedout":case"msg_bad_characters":case"msg_channel_blocked":case"msg_facebook":case"msg_followersonly":case"msg_followersonly_followed":case"msg_followersonly_zero":case"msg_rejected":case"msg_slowmode":case"msg_suspended":case"no_help":case"usage_disconnect":case"usage_help":case"usage_me":this.log.info(_),this.emit("notice",s,o,n);break;case"host_on":case"host_off":break;default:n.includes("Login unsuccessful")||n.includes("Login authentication failed")?(this.wasCloseCalled=!1,this.reconnect=!1,this.reason=n,this.log.error(this.reason),this.ws.close()):n.includes("Error logging in")||n.includes("Improperly formatted auth")?(this.wasCloseCalled=!1,this.reconnect=!1,this.reason=n,this.log.error(this.reason),this.ws.close()):n.includes("Invalid NICK")?(this.wasCloseCalled=!1,this.reconnect=!1,this.reason="Invalid NICK.",this.log.error(this.reason),this.ws.close()):this.log.warn("Could not parse NOTICE from tmi.twitch.tv:\n"+JSON.stringify(t,null,4))}break;case"USERNOTICE":var w=t.tags["display-name"]||t.tags.login,C=t.tags["msg-param-sub-plan"]||"",k=V.unescapeIRC(V.get(t.tags["msg-param-sub-plan-name"],""))||null,S=C.includes("Prime"),T=t.tags,E=~~(t.tags["msg-param-streak-months"]||0),x=t.tags["msg-param-recipient-display-name"]||t.tags["msg-param-recipient-user-name"],N=~~t.tags["msg-param-mass-gift-count"],D={prime:S,plan:C,planName:k};switch(T["message-type"]=o){case"resub":this.emits(["resub","subanniversary"],[[s,w,E,n,T,D]]);break;case"sub":this.emit("subscription",s,w,D,n,T);break;case"subgift":this.emit("subgift",s,w,E,x,D,T);break;case"anonsubgift":this.emit("anonsubgift",s,E,x,D,T);break;case"submysterygift":this.emit("submysterygift",s,w,N,D,T);break;case"anonsubmysterygift":this.emit("anonsubmysterygift",s,N,D,T);break;case"giftpaidupgrade":var P=t.tags["msg-param-sender-name"]||t.tags["msg-param-sender-login"];this.emit("giftpaidupgrade",s,w,P,T);break;case"anongiftpaidupgrade":this.emit("anongiftpaidupgrade",s,w,T);break;case"raid":w=t.tags["msg-param-displayName"]||t.tags["msg-param-login"];var M=t.tags["msg-param-viewerCount"];this.emit("raided",s,w,M)}break;case"HOSTTARGET":var I=n.split(" ");M=~~I[1]||0;"-"===I[0]?(this.log.info("["+s+"] Exited host mode."),this.emits(["unhost","_promiseUnhost"],[[s,M],[null]])):(this.log.info("["+s+"] Now hosting "+I[0]+" for "+M+" viewer(s)."),this.emit("hosting",s,I[0],M));break;case"CLEARCHAT":if(1<t.params.length){var L=V.get(t.tags["ban-duration"],null);V.isNull(L)?(this.log.info("["+s+"] "+n+" has been banned."),this.emit("ban",s,n,null,t.tags)):(this.log.info("["+s+"] "+n+" has been timed out for "+L+" seconds."),this.emit("timeout",s,n,null,~~L,t.tags))}else this.log.info("["+s+"] Chat was cleared by a moderator."),this.emits(["clearchat","_promiseClear"],[[s],[null]]);break;case"CLEARMSG":if(1<t.params.length){w=t.tags.login;var O=n;(T=t.tags)["message-type"]="messagedeleted",this.log.info("["+s+"] "+w+"'s message has been deleted."),this.emit("messagedeleted",s,w,O,T)}break;case"RECONNECT":this.log.info("Received RECONNECT request from Twitch.."),this.log.info("Disconnecting and reconnecting in "+Math.round(this.reconnectTimer/1e3)+" seconds.."),this.disconnect(),setTimeout(function(){e.connect()},this.reconnectTimer);break;case"SERVERCHANGE":break;case"USERSTATE":t.tags.username=this.username,"mod"===t.tags["user-type"]&&(this.moderators[this.lastJoined]||(this.moderators[this.lastJoined]=[]),this.moderators[this.lastJoined].includes(this.username)||this.moderators[this.lastJoined].push(this.username)),V.isJustinfan(this.getUsername())||this.userstate[s]||(this.userstate[s]=t.tags,this.lastJoined=s,this.channels.push(s),this.log.info("Joined "+s),this.emit("join",s,V.username(this.getUsername()),!0)),t.tags["emote-sets"]!==this.emotes&&this._updateEmoteset(t.tags["emote-sets"]),this.userstate[s]=t.tags;break;case"GLOBALUSERSTATE":this.globaluserstate=t.tags,void 0!==t.tags["emote-sets"]&&this._updateEmoteset(t.tags["emote-sets"]);break;case"ROOMSTATE":if(V.channel(this.lastJoined)===V.channel(t.params[0])&&this.emit("_promiseJoin",null),t.tags.channel=V.channel(t.params[0]),this.emit("roomstate",V.channel(t.params[0]),t.tags),!t.tags.hasOwnProperty("subs-only")){if(t.tags.hasOwnProperty("slow"))if("boolean"!=typeof t.tags.slow||t.tags.slow){var R=~~t.tags.slow;this.log.info("["+s+"] This room is now in slow mode."),this.emits(["slow","slowmode","_promiseSlow"],[[s,!0,R],[s,!0,R],[null]])}else this.log.info("["+s+"] This room is no longer in slow mode."),this.emits(["slow","slowmode","_promiseSlowoff"],[[s,!1,0],[s,!1,0],[null]]);if(t.tags.hasOwnProperty("followers-only"))if("-1"===t.tags["followers-only"])this.log.info("["+s+"] This room is no longer in followers-only mode."),this.emits(["followersonly","followersmode","_promiseFollowersoff"],[[s,!1,0],[s,!1,0],[null]]);else{R=~~t.tags["followers-only"];this.log.info("["+s+"] This room is now in follower-only mode."),this.emits(["followersonly","followersmode","_promiseFollowers"],[[s,!0,R],[s,!0,R],[null]])}}break;default:this.log.warn("Could not parse message from tmi.twitch.tv:\n"+JSON.stringify(t,null,4))}else if("jtv"===t.prefix)switch(t.command){case"MODE":"+o"===n?(this.moderators[s]||(this.moderators[s]=[]),this.moderators[s].includes(t.params[2])||this.moderators[s].push(t.params[2]),this.emit("mod",s,t.params[2])):"-o"===n&&(this.moderators[s]||(this.moderators[s]=[]),this.moderators[s].filter(function(e){return e!=t.params[2]}),this.emit("unmod",s,t.params[2]));break;default:this.log.warn("Could not parse message from jtv:\n"+JSON.stringify(t,null,4))}else switch(t.command){case"353":this.emit("names",t.params[2],t.params[3].split(" "));break;case"366":break;case"JOIN":var A=t.prefix.split("!")[0];V.isJustinfan(this.getUsername())&&this.username===A&&(this.lastJoined=s,this.channels.push(s),this.log.info("Joined "+s),this.emit("join",s,A,!0)),this.username!==A&&this.emit("join",s,A,!1);break;case"PART":var U,J=!1;A=t.prefix.split("!")[0];if(this.username===A)J=!0,this.userstate[s]&&delete this.userstate[s],-1!==(U=this.channels.indexOf(s))&&this.channels.splice(U,1),-1!==(U=this.opts.channels.indexOf(s))&&this.opts.channels.splice(U,1),this.log.info("Left "+s),this.emit("_promisePart",null);this.emit("part",s,A,J);break;case"WHISPER":A=t.prefix.split("!")[0];this.log.info("[WHISPER] <"+A+">: "+n),t.tags.hasOwnProperty("username")||(t.tags.username=A),t.tags["message-type"]="whisper";var j=V.channel(t.tags.username);this.emits(["whisper","message"],[[j,t.tags,n,!1]]);break;case"PRIVMSG":if(t.tags.username=t.prefix.split("!")[0],"jtv"===t.tags.username){var G=V.username(n.split(" ")[0]),H=n.includes("auto");if(n.includes("hosting you for")){var W=V.extractNumber(n);this.emit("hosted",s,G,W,H)}else n.includes("hosting you")&&this.emit("hosted",s,G,0,H)}else{var q=V.actionMessage(n);q?(t.tags["message-type"]="action",this.log.info("["+s+"] *<"+t.tags.username+">: "+q[1]),this.emits(["action","message"],[[s,t.tags,q[1],!1]])):t.tags.hasOwnProperty("bits")?this.emit("cheer",s,t.tags,n):(t.tags["message-type"]="chat",this.log.info("["+s+"] <"+t.tags.username+">: "+n),this.emits(["chat","message"],[[s,t.tags,n,!1]]))}break;default:this.log.warn("Could not parse message:\n"+JSON.stringify(t,null,4))}}},a.prototype.connect=function(){var n=this;return new Promise(function(t,s){n.server=V.get(n.opts.connection.server,"irc-ws.chat.twitch.tv"),n.port=V.get(n.opts.connection.port,80),n.secure&&(n.port=443),443===n.port&&(n.secure=!0),n.reconnectTimer=n.reconnectTimer*n.reconnectDecay,n.reconnectTimer>=n.maxReconnectInterval&&(n.reconnectTimer=n.maxReconnectInterval),n._openConnection(),n.once("_promiseConnect",function(e){e?s(e):t([n.server,~~n.port])})})},a.prototype._openConnection=function(){this.ws=new r((this.secure?"wss":"ws")+"://"+this.server+":"+this.port+"/","irc"),this.ws.onmessage=this._onMessage.bind(this),this.ws.onerror=this._onError.bind(this),this.ws.onclose=this._onClose.bind(this),this.ws.onopen=this._onOpen.bind(this)},a.prototype._onOpen=function(){V.isNull(this.ws)||1!==this.ws.readyState||(this.log.info("Connecting to "+this.server+" on port "+this.port+".."),this.emit("connecting",this.server,~~this.port),this.username=V.get(this.opts.identity.username,V.justinfan()),this.password=V.password(V.get(this.opts.identity.password,"SCHMOOPIIE")),this.log.info("Sending authentication to server.."),this.emit("logon"),this.ws.send("CAP REQ :twitch.tv/tags twitch.tv/commands twitch.tv/membership"),this.ws.send("PASS "+this.password),this.ws.send("NICK "+this.username),this.ws.send("USER "+this.username+" 8 * :"+this.username))},a.prototype._onMessage=function(e){var t=this;e.data.split("\r\n").forEach(function(e){V.isNull(e)||t.handleMessage(B.msg(e))})},a.prototype._onError=function(){var e=this;this.moderators={},this.userstate={},this.globaluserstate={},clearInterval(this.pingLoop),clearTimeout(this.pingTimeout),this.reason=V.isNull(this.ws)?"Connection closed.":"Unable to connect.",this.emits(["_promiseConnect","disconnected"],[[this.reason]]),this.reconnect&&this.reconnections===this.maxReconnectAttempts&&(this.emit("maxreconnect"),this.log.error("Maximum reconnection attempts reached.")),this.reconnect&&!this.reconnecting&&this.reconnections<=this.maxReconnectAttempts-1&&(this.reconnecting=!0,this.reconnections=this.reconnections+1,this.log.error("Reconnecting in "+Math.round(this.reconnectTimer/1e3)+" seconds.."),this.emit("reconnect"),setTimeout(function(){e.reconnecting=!1,e.connect()},this.reconnectTimer)),this.ws=null},a.prototype._onClose=function(){var e=this;this.moderators={},this.userstate={},this.globaluserstate={},clearInterval(this.pingLoop),clearTimeout(this.pingTimeout),this.wasCloseCalled?(this.wasCloseCalled=!1,this.reason="Connection closed.",this.log.info(this.reason),this.emits(["_promiseConnect","_promiseDisconnect","disconnected"],[[this.reason],[null],[this.reason]])):(this.emits(["_promiseConnect","disconnected"],[[this.reason]]),this.reconnect&&this.reconnections===this.maxReconnectAttempts&&(this.emit("maxreconnect"),this.log.error("Maximum reconnection attempts reached.")),this.reconnect&&!this.reconnecting&&this.reconnections<=this.maxReconnectAttempts-1&&(this.reconnecting=!0,this.reconnections=this.reconnections+1,this.log.error("Could not connect to server. Reconnecting in "+Math.round(this.reconnectTimer/1e3)+" seconds.."),this.emit("reconnect"),setTimeout(function(){e.reconnecting=!1,e.connect()},this.reconnectTimer))),this.ws=null},a.prototype._getPromiseDelay=function(){return this.currentLatency<=600?600:this.currentLatency+100},a.prototype._sendCommand=function(n,o,i,r){var a=this;return new Promise(function(e,t){if(V.promiseDelay(n).then(function(){t("No response from Twitch.")}),V.isNull(a.ws)||2===a.ws.readyState||3===a.ws.readyState)t("Not connected to server.");else{if(V.isNull(o))a.log.info("Executing command: "+i),a.ws.send(i);else{var s=V.channel(o);a.log.info("["+s+"] Executing command: "+i),a.ws.send("PRIVMSG "+s+" :"+i)}r(e,t)}})},a.prototype._sendMessage=function(a,c,l,u){var m=this;return new Promise(function(e,t){if(V.isNull(m.ws)||2===m.ws.readyState||3===m.ws.readyState||V.isJustinfan(m.getUsername()))t("Not connected to server.");else{var s=V.channel(c);if(m.userstate[s]||(m.userstate[s]={}),500<=l.length){var n=V.splitLine(l,500);l=n[0],setTimeout(function(){m._sendMessage(a,c,n[1],function(){})},350)}m.ws.send("PRIVMSG "+s+" :"+l);var o={};Object.keys(m.emotesets).forEach(function(e){m.emotesets[e].forEach(function(e){return V.isRegex(e.code)?B.emoteRegex(l,e.code,e.id,o):void B.emoteString(l,e.code,e.id,o)})});var i=V.merge(m.userstate[s],B.emotes({emotes:B.transformEmotes(o)||null})),r=V.actionMessage(l);r?(i["message-type"]="action",m.log.info("["+s+"] *<"+m.getUsername()+">: "+r[1]),m.emits(["action","message"],[[s,i,r[1],!0]])):(i["message-type"]="chat",m.log.info("["+s+"] <"+m.getUsername()+">: "+l),m.emits(["chat","message"],[[s,i,l,!0]])),u(e,t)}})},a.prototype._updateEmoteset=function(n){var o=this;this.emotes=n,this.api({url:"/chat/emoticon_images?emotesets="+n,headers:{Authorization:"OAuth "+V.password(V.get(this.opts.identity.password,"")).replace("oauth:",""),"Client-ID":this.clientId}},function(e,t,s){return e?void setTimeout(function(){o._updateEmoteset(n)},6e4):(o.emotesets=s.emoticon_sets||{},o.emit("emotesets",n,o.emotesets))})},a.prototype.getUsername=function(){return this.username},a.prototype.getOptions=function(){return this.opts},a.prototype.getChannels=function(){return this.channels},a.prototype.isMod=function(e,t){var s=V.channel(e);return this.moderators[s]||(this.moderators[s]=[]),this.moderators[s].includes(V.username(t))},a.prototype.readyState=function(){return V.isNull(this.ws)?"CLOSED":["CONNECTING","OPEN","CLOSING","CLOSED"][this.ws.readyState]},a.prototype.disconnect=function(){var s=this;return new Promise(function(e,t){V.isNull(s.ws)||3===s.ws.readyState?(s.log.error("Cannot disconnect from server. Socket is not opened or connection is already closing."),t("Cannot disconnect from server. Socket is not opened or connection is already closing.")):(s.wasCloseCalled=!0,s.log.info("Disconnecting from server.."),s.ws.close(),s.once("_promiseDisconnect",function(){e([s.server,~~s.port])}))})},a.prototype.utils=i,void 0!==u&&u.exports&&(u.exports=a),"undefined"!=typeof window&&(window.tmi={},window.tmi.client=a,window.tmi.Client=a)}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./api":2,"./commands":4,"./events":5,"./extra-utils":6,"./logger":7,"./parser":8,"./timer":9,"./utils":10,ws:11}],4:[function(e,t,s){"use strict";function n(n,o){var e=this;return n=u.channel(n),o=u.get(o,30),this._sendCommand(this._getPromiseDelay(),n,"/followers "+o,function(t,s){e.once("_promiseFollowers",function(e){e?s(e):t([n,~~o])})})}function o(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/followersoff",function(t,s){e.once("_promiseFollowersoff",function(e){e?s(e):t([n])})})}function i(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),null,"PART "+n,function(t,s){e.once("_promisePart",function(e){e?s(e):t([n])})})}function r(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/r9kbeta",function(t,s){e.once("_promiseR9kbeta",function(e){e?s(e):t([n])})})}function a(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/r9kbetaoff",function(t,s){e.once("_promiseR9kbetaoff",function(e){e?s(e):t([n])})})}function c(n,o){var e=this;return n=u.channel(n),o=u.get(o,300),this._sendCommand(this._getPromiseDelay(),n,"/slow "+o,function(t,s){e.once("_promiseSlow",function(e){e?s(e):t([n,~~o])})})}function l(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/slowoff",function(t,s){e.once("_promiseSlowoff",function(e){e?s(e):t([n])})})}var u=e("./utils");t.exports={action:function(s,n){return s=u.channel(s),n="ACTION "+n+"",this._sendMessage(this._getPromiseDelay(),s,n,function(e,t){e([s,n])})},ban:function(n,o,i){var e=this;return n=u.channel(n),o=u.username(o),i=u.get(i,""),this._sendCommand(this._getPromiseDelay(),n,"/ban "+o+" "+i,function(t,s){e.once("_promiseBan",function(e){e?s(e):t([n,o,i])})})},clear:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/clear",function(t,s){e.once("_promiseClear",function(e){e?s(e):t([n])})})},color:function(e,n){var o=this;return n=u.get(n,e),this._sendCommand(this._getPromiseDelay(),"#tmijs","/color "+n,function(t,s){o.once("_promiseColor",function(e){e?s(e):t([n])})})},commercial:function(n,o){var e=this;return n=u.channel(n),o=u.get(o,30),this._sendCommand(this._getPromiseDelay(),n,"/commercial "+o,function(t,s){e.once("_promiseCommercial",function(e){e?s(e):t([n,~~o])})})},deletemessage:function(n,e){var o=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/delete "+e,function(t,s){o.once("_promiseDeletemessage",function(e){e?s(e):t([n])})})},emoteonly:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/emoteonly",function(t,s){e.once("_promiseEmoteonly",function(e){e?s(e):t([n])})})},emoteonlyoff:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/emoteonlyoff",function(t,s){e.once("_promiseEmoteonlyoff",function(e){e?s(e):t([n])})})},followersonly:n,followersmode:n,followersonlyoff:o,followersmodeoff:o,host:function(o,i){var e=this;return o=u.channel(o),i=u.username(i),this._sendCommand(2e3,o,"/host "+i,function(s,n){e.once("_promiseHost",function(e,t){e?n(e):s([o,i,~~t])})})},join:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),null,"JOIN "+n,function(t,s){e.once("_promiseJoin",function(e){e?s(e):t([n])})})},mod:function(n,o){var e=this;return n=u.channel(n),o=u.username(o),this._sendCommand(this._getPromiseDelay(),n,"/mod "+o,function(t,s){e.once("_promiseMod",function(e){e?s(e):t([n,o])})})},mods:function(o){var i=this;return o=u.channel(o),this._sendCommand(this._getPromiseDelay(),o,"/mods",function(s,n){i.once("_promiseMods",function(e,t){e?n(e):(t.forEach(function(e){i.moderators[o]||(i.moderators[o]=[]),i.moderators[o].includes(e)||i.moderators[o].push(e)}),s(t))})})},part:i,leave:i,ping:function(){var s=this;return this._sendCommand(this._getPromiseDelay(),null,"PING",function(t,e){s.latency=new Date,s.pingTimeout=setTimeout(function(){null!==s.ws&&(s.wasCloseCalled=!1,s.log.error("Ping timeout."),s.ws.close(),clearInterval(s.pingLoop),clearTimeout(s.pingTimeout))},u.get(s.opts.connection.timeout,9999)),s.once("_promisePing",function(e){t([parseFloat(e)])})})},r9kbeta:r,r9kmode:r,r9kbetaoff:a,r9kmodeoff:a,raw:function(s){return this._sendCommand(this._getPromiseDelay(),null,s,function(e,t){e([s])})},say:function(s,n){return s=u.channel(s),n.startsWith(".")&&!n.startsWith("..")||n.startsWith("/")||n.startsWith("\\")?"me "===n.substr(1,3)?this.action(s,n.substr(4)):this._sendCommand(this._getPromiseDelay(),s,n,function(e,t){e([s,n])}):this._sendMessage(this._getPromiseDelay(),s,n,function(e,t){e([s,n])})},slow:c,slowmode:c,slowoff:l,slowmodeoff:l,subscribers:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/subscribers",function(t,s){e.once("_promiseSubscribers",function(e){e?s(e):t([n])})})},subscribersoff:function(n){var e=this;return n=u.channel(n),this._sendCommand(this._getPromiseDelay(),n,"/subscribersoff",function(t,s){e.once("_promiseSubscribersoff",function(e){e?s(e):t([n])})})},timeout:function(n,o,i,r){var e=this;return n=u.channel(n),o=u.username(o),u.isNull(i)||u.isInteger(i)||(r=i,i=300),i=u.get(i,300),r=u.get(r,""),this._sendCommand(this._getPromiseDelay(),n,"/timeout "+o+" "+i+" "+r,function(t,s){e.once("_promiseTimeout",function(e){e?s(e):t([n,o,~~i,r])})})},unban:function(n,o){var e=this;return n=u.channel(n),o=u.username(o),this._sendCommand(this._getPromiseDelay(),n,"/unban "+o,function(t,s){e.once("_promiseUnban",function(e){e?s(e):t([n,o])})})},unhost:function(n){var e=this;return n=u.channel(n),this._sendCommand(2e3,n,"/unhost",function(t,s){e.once("_promiseUnhost",function(e){e?s(e):t([n])})})},unmod:function(n,o){var e=this;return n=u.channel(n),o=u.username(o),this._sendCommand(this._getPromiseDelay(),n,"/unmod "+o,function(t,s){e.once("_promiseUnmod",function(e){e?s(e):t([n,o])})})},unvip:function(n,o){var e=this;return n=u.channel(n),o=u.username(o),this._sendCommand(this._getPromiseDelay(),n,"/unvip "+o,function(t,s){e.once("_promiseUnvip",function(e){e?s(e):t([n,o])})})},vip:function(n,o){var e=this;return n=u.channel(n),o=u.username(o),this._sendCommand(this._getPromiseDelay(),n,"/vip "+o,function(t,s){e.once("_promiseVip",function(e){e?s(e):t([n,o])})})},vips:function(e){var t=this;return e=u.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/vips",function(s,n){t.once("_promiseVips",function(e,t){e?n(e):s(t)})})},whisper:function(o,i){var r=this;return(o=u.username(o))===this.getUsername()?Promise.reject("Cannot send a whisper to the same account."):this._sendCommand(this._getPromiseDelay(),"#tmijs","/w "+o+" "+i,function(e,t){var s=u.channel(o),n=u.merge({"message-type":"whisper","message-id":null,"thread-id":null,username:r.getUsername()},r.globaluserstate);r.emits(["whisper","message"],[[s,n,i,!0],[s,n,i,!0]]),e([o,i])})}}},{"./utils":10}],5:[function(e,t,s){"use strict";function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function c(e){return"function"==typeof e}function l(e){return"object"===(void 0===e?"undefined":o(e))&&null!==e}function a(e){return void 0===e}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};String.prototype.startsWith||(String.prototype.startsWith=function(e,t){return t=t||0,this.indexOf(e,t)===t}),((t.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emits=function(e,t){for(var s=0;s<e.length;s++){var n=s<t.length?t[s]:t[t.length-1];this.emit.apply(this,[e[s]].concat(n))}},n.prototype.emit=function(e){var t,s,n,o,i,r;if(this._events||(this._events={}),"error"===e&&(!this._events.error||l(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(a(s=this._events[e]))return!1;if(c(s))switch(arguments.length){case 1:s.call(this);break;case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),s.apply(this,o)}else if(l(s))for(o=Array.prototype.slice.call(arguments,1),n=(r=s.slice()).length,i=0;i<n;i++)r[i].apply(this,o);return!0},n.prototype.on=n.prototype.addListener=function(e,t){var s;if(!c(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,c(t.listener)?t.listener:t),this._events[e]?l(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,l(this._events[e])&&!this._events[e].warned&&((s=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&0<s&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.once=function(e,t){function s(){"_"!==e.charAt(0)||isNaN(e.substr(e.length-1))||(e=e.substring(0,e.length-1)),this.removeListener(e,s),n||(n=!0,t.apply(this,arguments))}if(!c(t))throw TypeError("listener must be a function");var n=!1;if(this._events.hasOwnProperty(e)&&"_"===e.charAt(0)){var o=1,i=e;for(var r in this._events)this._events.hasOwnProperty(r)&&r.startsWith(i)&&o++;e+=o}return s.listener=t,this.on(e,s),this},n.prototype.removeListener=function(e,t){var s,n,o,i;if(!c(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(o=(s=this._events[e]).length,n=-1,s===t||c(s.listener)&&s.listener===t){if(delete this._events[e],this._events.hasOwnProperty(e+"2")&&"_"===e.charAt(0)){var r=e;for(var a in this._events)this._events.hasOwnProperty(a)&&a.startsWith(r)&&(isNaN(parseInt(a.substr(a.length-1)))||(this._events[e+parseInt(a.substr(a.length-1)-1)]=this._events[a],delete this._events[a]));this._events[e]=this._events[e+"1"],delete this._events[e+"1"]}this._events.removeListener&&this.emit("removeListener",e,t)}else if(l(s)){for(i=o;0<i--;)if(s[i]===t||s[i].listener&&s[i].listener===t){n=i;break}if(n<0)return this;1===s.length?(s.length=0,delete this._events[e]):s.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,s;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(c(s=this._events[e]))this.removeListener(e,s);else if(s)for(;s.length;)this.removeListener(e,s[s.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?c(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(c(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],6:[function(e,t,s){"use strict";var d=e("./utils");t.exports={levenshtein:function(e,t,s){if((s=d.get(s,!1))||(e=e.toLowerCase(),t=t.toLowerCase()),e==t)return 0;var n=e.length,o=t.length;if(0===n)return 1*o;if(0===o)return 1*n;var i=!1;try{i=!"0"[0]}catch(e){i=!0}i&&(e=e.split(""),t=t.split(""));var r,a,c,l,u,m,h=new Array(o+1),f=new Array(o+1);for(a=0;a<=o;a++)h[a]=1*a;for(r=0;r<n;r++){for(f[0]=h[0]+1,a=0;a<o;a++)c=h[a]+(e[r]==t[a]?0:1),(l=h[a+1]+1)<c&&(c=l),(u=f[a]+1)<c&&(c=u),f[a+1]=c;m=h,h=f,f=m}return h[o]},raffle:{init:function(e){this.raffleChannels||(this.raffleChannels={}),this.raffleChannels[d.channel(e)]||(this.raffleChannels[d.channel(e)]=[])},enter:function(e,t){this.init(e),this.raffleChannels[d.channel(e)].push(t.toLowerCase())},leave:function(e,t){this.init(e);var s=this.raffleChannels[d.channel(e)].indexOf(d.username(t));return 0<=s&&(this.raffleChannels[d.channel(e)].splice(s,1),!0)},pick:function(e){this.init(e);var t=this.raffleChannels[d.channel(e)].length;return 1<=t?this.raffleChannels[d.channel(e)][Math.floor(Math.random()*t)]:null},reset:function(e){this.init(e),this.raffleChannels[d.channel(e)]=[]},count:function(e){return this.init(e),this.raffleChannels[d.channel(e)]?this.raffleChannels[d.channel(e)].length:0},isParticipating:function(e,t){return this.init(e),this.raffleChannels[d.channel(e)].includes(d.username(t))}},symbols:function(e){for(var t=0,s=0;s<e.length;s++){var n=e.substring(s,s+1).charCodeAt(0);(n<=30||127<=n||65533===n)&&t++}return Math.ceil(t/e.length*100)/100},uppercase:function(e){var t=e.length,s=e.match(/[A-Z]/g);return d.isNull(s)?0:s.length/t}}},{"./utils":10}],7:[function(e,t,s){"use strict";function n(t){return function(e){r[i]<=r[t]&&console.log("["+o.formatDate(new Date)+"] "+t+": "+e)}}var o=e("./utils"),i="info",r={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};t.exports={setLevel:function(e){i=e},trace:n("trace"),debug:n("debug"),info:n("info"),warn:n("warn"),error:n("error"),fatal:n("fatal")}},{"./utils":10}],8:[function(e,t,s){"use strict";var a=e("./utils");t.exports={badges:function(e){if(a.isString(e.badges)){for(var t={},s=e.badges.split(","),n=0;n<s.length;n++){var o=s[n].split("/");if(!o[1])return;t[o[0]]=o[1]}e["badges-raw"]=e.badges,e.badges=t}return a.isBoolean(e.badges)&&(e["badges-raw"]=null),e},emotes:function(e){if(a.isString(e.emotes)){for(var t=e.emotes.split("/"),s={},n=0;n<t.length;n++){var o=t[n].split(":");if(!o[1])return;s[o[0]]=o[1].split(",")}e["emotes-raw"]=e.emotes,e.emotes=s}return a.isBoolean(e.emotes)&&(e["emotes-raw"]=null),e},emoteRegex:function(e,t,s,n){for(var o,i=/\S+/g,r=new RegExp("(\\b|^|s)"+a.unescapeHtml(t)+"(\\b|$|s)");null!==(o=i.exec(e));)r.test(o[0])&&(n[s]=n[s]||[],n[s].push([o.index,i.lastIndex-1]))},emoteString:function(e,t,s,n){for(var o,i=/\S+/g;null!==(o=i.exec(e));)o[0]===a.unescapeHtml(t)&&(n[s]=n[s]||[],n[s].push([o.index,i.lastIndex-1]))},transformEmotes:function(t){var s="";return Object.keys(t).forEach(function(e){s=s+e+":",t[e].forEach(function(e){s=s+e.join("-")+","}),s=s.slice(0,-1)+"/"}),s.slice(0,-1)},msg:function(e){var t={raw:e,tags:{},prefix:null,command:null,params:[]},s=0,n=0;if(64===e.charCodeAt(0)){if(-1===(n=e.indexOf(" ")))return null;for(var o=e.slice(1,n).split(";"),i=0;i<o.length;i++){var r=o[i],a=r.split("=");t.tags[a[0]]=r.substring(r.indexOf("=")+1)||!0}s=n+1}for(;32===e.charCodeAt(s);)s++;if(58===e.charCodeAt(s)){if(-1===(n=e.indexOf(" ",s)))return null;for(t.prefix=e.slice(s+1,n),s=n+1;32===e.charCodeAt(s);)s++}if(-1===(n=e.indexOf(" ",s)))return e.length>s?(t.command=e.slice(s),t):null;for(t.command=e.slice(s,n),s=n+1;32===e.charCodeAt(s);)s++;for(;s<e.length;){if(n=e.indexOf(" ",s),58===e.charCodeAt(s)){t.params.push(e.slice(s+1));break}if(-1===n){if(-1===n){t.params.push(e.slice(s));break}}else for(t.params.push(e.slice(s,n)),s=n+1;32===e.charCodeAt(s);)s++}return t}}},{"./utils":10}],9:[function(e,t,s){"use strict";function n(e){this.queue=[],this.index=0,this.defaultDelay=e||3e3}n.prototype.add=function(e,t){this.queue.push({fn:e,delay:t})},n.prototype.run=function(e){(e||0===e)&&(this.index=e),this.next()},n.prototype.next=function(){var e=this,t=this.index++,s=this.queue[t],n=this.queue[this.index];s&&(s.fn(),n&&setTimeout(function(){e.next()},n.delay||this.defaultDelay))},n.prototype.reset=function(){this.index=0},n.prototype.clear=function(){this.index=0,this.queue=[]},s.queue=n},{}],10:[function(e,a,t){(function(e){"use strict";var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=/^\u0001ACTION ([^\u0001]+)\u0001$/,n=/^(justinfan)(\d+$)/,o=/\\([sn:r\\])/g,i={s:" ",n:"",":":";",r:""},r=a.exports={get:function(e,t){return void 0===e?t:e},isBoolean:function(e){return"boolean"==typeof e},isFinite:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}(function(e){return isFinite(e)&&!isNaN(parseFloat(e))}),isInteger:function(e){return!isNaN(r.toNumber(e,0))},isJustinfan:function(e){return n.test(e)},isNull:function(e){return null===e},isRegex:function(e){return/[\|\\\^\$\*\+\?\:\#]/.test(e)},isString:function(e){return"string"==typeof e},isURL:function(e){return RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$","i").test(e)},justinfan:function(){return"justinfan"+Math.floor(8e4*Math.random()+1e3)},password:function(e){return["SCHMOOPIIE","",null].includes(e)?"SCHMOOPIIE":"oauth:"+e.toLowerCase().replace("oauth:","")},promiseDelay:function(t){return new Promise(function(e){setTimeout(e,t)})},replaceAll:function(e,t){if(null==e)return null;for(var s in t)e=e.replace(new RegExp(s,"g"),t[s]);return e},unescapeHtml:function(e){return e.replace(/\\&amp\\;/g,"&").replace(/\\&lt\\;/g,"<").replace(/\\&gt\\;/g,">").replace(/\\&quot\\;/g,'"').replace(/\\&#039\\;/g,"'")},unescapeIRC:function(e){return e&&e.includes("\\")?e.replace(o,function(e,t){return t in i?i[t]:t}):e},actionMessage:function(e){return e.match(s)},addWord:function(e,t){return e.length?e+" "+t:e+t},channel:function(e){var t=(e||"").toLowerCase();return"#"===t[0]?t:"#"+t},extractNumber:function(e){for(var t=e.split(" "),s=0;s<t.length;s++)if(r.isInteger(t[s]))return~~t[s];return 0},formatDate:function(e){var t=e.getHours(),s=e.getMinutes();return(t=(t<10?"0":"")+t)+":"+(s=(s<10?"0":"")+s)},inherits:function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e},isNode:function(){try{return a.exports="object"===(void 0===e?"undefined":t(e))&&"[object process]"===Object.prototype.toString.call(e)}catch(e){return!1}},isExtension:function(){try{return!!(window.chrome&&chrome.runtime&&chrome.runtime.id)}catch(e){return!1}},merge:Object.assign,splitLine:function(e,t){var s=e.substring(0,t).lastIndexOf(" ");return-1===s&&(s=t-1),[e.substring(0,s),e.substring(s+1)]},toNumber:function(e,t){if(null===e)return 0;var s=Math.pow(10,r.isFinite(t)?t:0);return Math.round(e*s)/s},union:function(e,t){for(var s={},n=[],o=0;o<e.length;o++){s[i=e[o]]||(s[i]=!0,n.push(i))}for(o=0;o<t.length;o++){var i;s[i=t[o]]||(s[i]=!0,n.push(i))}return n},username:function(e){var t=(e||"").toLowerCase();return"#"===t[0]?t.slice(1):t}}}).call(this,e("_process"))},{_process:12}],11:[function(e,t,s){},{}],12:[function(e,t,s){function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(u===setTimeout)return setTimeout(t,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function r(){p&&f&&(p=!1,f.length?d=f.concat(d):g=-1,d.length&&a())}function a(){if(!p){var e=i(r);p=!0;for(var t=d.length;t;){for(f=d,d=[];++g<t;)f&&f[g].run();g=-1,t=d.length}f=null,p=!1,function(t){if(m===clearTimeout)return clearTimeout(t);if((m===o||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(t);try{m(t)}catch(e){try{return m.call(null,t)}catch(e){return m.call(this,t)}}}(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var u,m,h=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(e){u=n}try{m="function"==typeof clearTimeout?clearTimeout:o}catch(e){m=o}}();var f,d=[],p=!1,g=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];d.push(new c(e,t)),1!==d.length||p||i(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},{}]},{},[1])}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);
  