├── .gitignore
├── LICENSE
├── README.md
├── index.html
├── index.js
├── package-lock.json
├── package.json
└── public
├── images
├── block.png
├── parachute.png
├── peg.png
├── piddles.png
├── pika.png
├── screenshot.jpg
├── star.png
├── target.png
├── targetgilokk0.png
├── waddles.png
└── wall.png
├── javascripts
├── comfy.min.js
├── phaser.min.js
└── tmi.min.js
└── stylesheets
└── style.css
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (https://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # TypeScript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # next.js build output
61 | .next
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Instafluff
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **PenguinDrop** Twitch-integrated Penguin Skydiving game!
2 |
3 | # Penguin Drop
4 | We built this Twitch-integrated Penguin Skydiving game live on Twitch for the Coding Cafe!
5 |
6 | ## Instafluff ##
7 | > *Like these projects? The best way to support my open-source projects is by becoming a Comfy Sponsor on GitHub!*
8 |
9 | > https://github.com/sponsors/instafluff
10 |
11 | > *Come and hang out with us at the Comfiest Corner on Twitch!*
12 |
13 | > https://twitch.tv/instafluff
14 |
15 | ## Instructions ##
16 |
17 | Add this as a Browser Source (1280x720) and replace `yourchannel` with your Twitch username!
18 |
19 | [https://www.instafluff.tv/PenguinDrop?channel=yourchannel](https://www.instafluff.tv/PenguinDrop?channel=yourchannel)
20 |
21 | ```
22 | For example:
23 | https://www.instafluff.tv/PenguinDrop?channel=instafluff
24 | ```
25 |
26 | Then type `!drop` in chat to play!
27 |
28 | ## Admin Commands
29 |
30 | The following commands are available to the Broadcaster and Moderators:
31 |
32 | - `resetdrop` - Reset the game
33 |
34 | ## Config ##
35 | Set these to true under gotyConfig to enable some enhanced features:
36 | windyFloat: Adds some additional randomness, occasionally changing the paratroopers' speed back and forth.
37 | newChute: Changes the paratroopers' animation, making it change with their direction and speed.
38 | randomTarget: Randomizes the target location. Still stays away from the edges, but moves around when it needs a new target.
39 |
40 | ## Credits ##
41 | Thank you to all the participants of this project!
42 |
43 | **MacabreMan2, losthewar, StreamElements, Instafriend, Instafluff, ChatTranslator, pookiepew, LastLeap, That_MS_Gamer, sethorizer, DevMerlin, kevkab, sparky_pugwash, csharpfritz, NULLYUKI, BountyHunterLani, doworkout, DutchGamer46, ravavyr, royoushi, Aririal, Dat1DUD3, MrRayKoma, AntiViGames, Stay_Hydrated_Bot, Levent133, nazabar, Kushimitama, fd_god92, Tomcii, FuriousFur, kukji232, NinjaFalcon_2, Deitypotato, PinataHero, LamerYo, adamisbest1231, donaldwm, BaristaJosh, simrose4u, mrstealyoguuurrl, stresstest, supremegoku5, oto_9717, StudsTwerkel, Breci, TheHungerService, rekaj3773, SenorTacoz12, antonm23, NoCeasefires, Rosuav, fakeeyou, mldevelopment, jellydance, kingswerv, Chibigirl24, DrJavaSaurus, BelowTheStoneDev, Bloom_molly, Rlchibi, SuperChihuahua, swattkidd, isaischannel, kyprimo, ImJustSteel, Krakka25, MisterHex, muppen1976, DEAD_P1XL, PokemoHero, KillFighter23, ThatNerdViolet, thegooseofwild, KitAnnLIVE, MStewGT, ReaLyfeOG, Clarkio, matthewkosloski, prasanthlouis, Il_Mika, UltraHal1, atd285, FerynTV, Zuulmofo, blakeparsons12, MoltenSnowman, SausageCam**
44 |
45 | And to all the folks that helped in adding scores and leaderboards!
46 |
47 | **Instafriend, Instafluff, ChatTranslator, jellydance, sparky_pugwash, MacabreMan2, thegooseofwild, Theoneandonlybigbadmo, stresstest, pipskidoodle, Moopaloo, oto_9717, KitAnnLIVE, UltraHal1, DevMerlin, nazabar, MrRayKoma, PinataHero, luaeo, Stay_Hydrated_Bot, Bloom_molly, LMOrchard, rdmusser, prasanthlouis, Jabokoe, IlyaBakhlin, XTlNAX, ScrtSolstice, Rkcteddy, tescogeorge1, Isidorf, kingflecki, SausageCam, malfunct, swolemaz, LamerYo, Kyoslilmonster, PokemoHero, codeheir, losthewar, CaseyGeske, BungalowGlow, FuriousFur, zivivi1, TheSabbyLife, donaldwm, NULLYUKI, Chibigirl24, smilesandcode, C0D3_Monkey, ZauzyDumpling, MalForTheWin, Gwozilla, simrose4u, cottonsmiles, NlghtSprites, 0BuRner, Sum_Wun, Jwh1o1, NinjaFalcon_2, joshbwr, thomasnhermansen, knugensugen, foxotic, fd_god92**
48 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PenguinDrop by Instafluff
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
375 |
376 |
377 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const Web = require( "webwebweb" );
2 | Web.Run( 8011 );
3 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "penguindrop",
3 | "version": "0.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "dotenv": {
8 | "version": "6.0.0",
9 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz",
10 | "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg=="
11 | },
12 | "webwebweb": {
13 | "version": "1.1.10",
14 | "resolved": "https://registry.npmjs.org/webwebweb/-/webwebweb-1.1.10.tgz",
15 | "integrity": "sha512-1USSML5iHpqH8KGcAwmck2dOlsxL6SxRX/c5qqPbi/dj1VdXiNff5DgZnPqtIFdINyuyc1WnKJaCZCFWwetvRQ=="
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "penguindrop",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "start": "node index.js"
7 | },
8 | "dependencies": {
9 | "dotenv": "^6.0.0",
10 | "webwebweb": "^1.1.10"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/public/images/block.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/block.png
--------------------------------------------------------------------------------
/public/images/parachute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/parachute.png
--------------------------------------------------------------------------------
/public/images/peg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/peg.png
--------------------------------------------------------------------------------
/public/images/piddles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/piddles.png
--------------------------------------------------------------------------------
/public/images/pika.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/pika.png
--------------------------------------------------------------------------------
/public/images/screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/screenshot.jpg
--------------------------------------------------------------------------------
/public/images/star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/star.png
--------------------------------------------------------------------------------
/public/images/target.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/target.png
--------------------------------------------------------------------------------
/public/images/targetgilokk0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/targetgilokk0.png
--------------------------------------------------------------------------------
/public/images/waddles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/waddles.png
--------------------------------------------------------------------------------
/public/images/wall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/instafluff/PenguinDrop/2066285208ff3ea0f4a962691af4317a14afbd06/public/images/wall.png
--------------------------------------------------------------------------------
/public/javascripts/comfy.min.js:
--------------------------------------------------------------------------------
1 | !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: "+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;ss&&(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;0s?(t.command=e.slice(s),t):null;for(t.command=e.slice(s,n),s=n+1;32===e.charCodeAt(s);)s++;for(;s").replace(/\\"\\;/g,'"').replace(/\\'\\;/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=0?"&":"?")+"callback="+a,document.body.appendChild(c)}};t.exports=o},{"./utils":9,request:10}],3:[function(e,t,s){(function(s){"use strict";var n=e("./api"),i=e("./commands"),o=e("./events").EventEmitter,r=e("./logger"),a=e("./parser"),c=e("./timer"),l=s.WebSocket||s.MozWebSocket||e("ws"),h=e("./utils"),u=function f(e){if(this instanceof f==!1)return new f(e);this.setMaxListeners(0),this.opts=h.get(e,{}),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=h.get(this.opts.options.clientId,null),this.maxReconnectAttempts=h.get(this.opts.connection.maxReconnectAttempts,1/0),this.maxReconnectInterval=h.get(this.opts.connection.maxReconnectInterval,3e4),this.reconnect=h.get(this.opts.connection.reconnect,!1),this.reconnectDecay=h.get(this.opts.connection.reconnectDecay,1.5),this.reconnectInterval=h.get(this.opts.connection.reconnectInterval,1e3),this.reconnecting=!1,this.reconnections=0,this.reconnectTimer=this.reconnectInterval,this.secure=h.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 t="error";this.opts.options.debug&&(t="info"),this.log=this.opts.logger||r;try{r.setLevel(t)}catch(s){}this.opts.channels.forEach(function(e,t,s){s[t]=h.channel(e)}),o.call(this)};h.inherits(u,o),u.prototype.api=n;for(var m in i)u.prototype[m]=i[m];u.prototype.handleMessage=function(e){var t=this;if(!h.isNull(e)){var s=h.channel(h.get(e.params[0],null)),n=h.get(e.params[1],null),i=h.get(e.tags["msg-id"],null);if(e.tags=a.badges(a.emotes(e.tags)),e.tags)for(var o in e.tags)"emote-sets"!==o&&"ban-duration"!==o&&"bits"!==o&&(h.isBoolean(e.tags[o])?e.tags[o]=null:"1"===e.tags[o]?e.tags[o]=!0:"0"===e.tags[o]&&(e.tags[o]=!1));if(h.isNull(e.prefix))switch(e.command){case"PING":this.emit("ping"),h.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],[this.currentLatency]]),clearTimeout(this.pingTimeout);break;default:this.log.warn("Could not parse message with no prefix:\n"+JSON.stringify(e,null,4))}else if("tmi.twitch.tv"===e.prefix)switch(e.command){case"002":case"003":case"004":case"375":case"376":case"CAP":break;case"001":this.username=e.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(){h.isNull(t.ws)||2===t.ws.readyState||3===t.ws.readyState||t.ws.send("PING"),t.latency=new Date,t.pingTimeout=setTimeout(function(){h.isNull(t.ws)||(t.wasCloseCalled=!1,t.log.error("Ping timeout."),t.ws.close(),clearInterval(t.pingLoop),clearTimeout(t.pingTimeout))},h.get(t.opts.connection.timeout,9999))},6e4);var l=new c.queue(2e3),u=h.union(this.opts.channels,this.channels);this.channels=[];for(var m=0;m=0;m--)""===d[m]&&d.splice(m,1);this.emits(["_promiseMods","mods"],[[null,d],[s,d]]);break;case"no_mods":this.emit("_promiseMods",null,[]);break;case"msg_channel_suspended":this.emits(["notice","_promiseJoin"],[[s,i,n],[i]]);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("["+s+"] "+n),this.emits(["notice","_promiseBan"],[[s,i,n],[i]]);break;case"ban_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseBan"],[[s,i,n],[null]]);break;case"usage_clear":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseClear"],[[s,i,n],[i]]);break;case"usage_mods":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseMods"],[[s,i,n],[i,[]]]);break;case"mod_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseMod"],[[s,i,n],[null]]);break;case"usage_mod":case"bad_mod_banned":case"bad_mod_mod":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseMod"],[[s,i,n],[i]]);break;case"unmod_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseUnmod"],[[s,i,n],[null]]);break;case"usage_unmod":case"bad_unmod_mod":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseUnmod"],[[s,i,n],[i]]);break;case"color_changed":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseColor"],[[s,i,n],[null]]);break;case"usage_color":case"turbo_only_color":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseColor"],[[s,i,n],[i]]);break;case"commercial_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseCommercial"],[[s,i,n],[null]]);break;case"usage_commercial":case"bad_commercial_error":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseCommercial"],[[s,i,n],[i]]);break;case"hosts_remaining":this.log.info("["+s+"] "+n);var g=isNaN(n.charAt(0))?0:n.charAt(0);this.emits(["notice","_promiseHost"],[[s,i,n],[null,~~g]]);break;case"bad_host_hosting":case"bad_host_rate_exceeded":case"bad_host_error":case"usage_host":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseHost"],[[s,i,n],[i,null]]);break;case"already_r9k_on":case"usage_r9k_on":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseR9kbeta"],[[s,i,n],[i]]);break;case"already_r9k_off":case"usage_r9k_off":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseR9kbetaoff"],[[s,i,n],[i]]);break;case"timeout_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseTimeout"],[[s,i,n],[null]]);break;case"already_subs_off":case"usage_subs_off":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseSubscribersoff"],[[s,i,n],[i]]);break;case"already_subs_on":case"usage_subs_on":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseSubscribers"],[[s,i,n],[i]]);break;case"already_emote_only_off":case"usage_emote_only_off":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseEmoteonlyoff"],[[s,i,n],[i]]);break;case"already_emote_only_on":case"usage_emote_only_on":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseEmoteonly"],[[s,i,n],[i]]);break;case"usage_slow_on":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseSlow"],[[s,i,n],[i]]);break;case"usage_slow_off":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseSlowoff"],[[s,i,n],[i]]);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("["+s+"] "+n),this.emits(["notice","_promiseTimeout"],[[s,i,n],[i]]);break;case"unban_success":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseUnban"],[[s,i,n],[null]]);break;case"usage_unban":case"bad_unban_no_ban":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseUnban"],[[s,i,n],[i]]);break;case"usage_unhost":case"not_hosting":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseUnhost"],[[s,i,n],[i]]);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("["+s+"] "+n),this.emits(["notice","_promiseWhisper"],[[s,i,n],[i]]);break;case"no_permission":case"msg_banned":this.log.info("["+s+"] "+n),this.emits(["notice","_promiseBan","_promiseClear","_promiseUnban","_promiseTimeout","_promiseMod","_promiseUnmod","_promiseCommercial","_promiseHost","_promiseUnhost","_promiseR9kbeta","_promiseR9kbetaoff","_promiseSlow","_promiseSlowoff","_promiseFollowers","_promiseFollowersoff","_promiseSubscribers","_promiseSubscribersoff","_promiseEmoteonly","_promiseEmoteonlyoff"],[[s,i,n],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i],[i]]);break;case"unrecognized_cmd":this.log.info("["+s+"] "+n),this.emit("notice",s,i,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"no_help":case"usage_disconnect":case"usage_help":case"usage_me":this.log.info("["+s+"] "+n),this.emit("notice",s,i,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(e,null,4))}break;case"USERNOTICE":if("resub"===i){var _=e.tags["display-name"]||e.tags.login,b=e.tags["msg-param-sub-plan"],y=h.replaceAll(h.get(e.tags["msg-param-sub-plan-name"],null),{"\\\\s":" ","\\\\:":";","\\\\\\\\":"\\","\\r":"\r","\\n":"\n"}),v=h.get(~~e.tags["msg-param-months"],null),w=b.includes("Prime"),C=null;n&&(C=e.tags,C["message-type"]="resub"),this.emits(["resub","subanniversary"],[[s,_,v,n,C,{prime:w,plan:b,planName:y}],[s,_,v,n,C,{prime:w,plan:b,planName:y}]])}else if("sub"==i){var _=e.tags["display-name"]||e.tags.login,b=e.tags["msg-param-sub-plan"],y=h.replaceAll(h.get(e.tags["msg-param-sub-plan-name"],null),{"\\\\s":" ","\\\\:":";","\\\\\\\\":"\\","\\r":"\r","\\n":"\n"}),w=b.includes("Prime"),C=null;n&&(C=e.tags,C["message-type"]="sub"),this.emit("subscription",s,_,{prime:w,plan:b,planName:y},n,C)}break;case"HOSTTARGET":if("-"===n.split(" ")[0])this.log.info("["+s+"] Exited host mode."),this.emits(["unhost","_promiseUnhost"],[[s,~~n.split(" ")[1]||0],[null]]);else{var k=~~n.split(" ")[1]||0;this.log.info("["+s+"] Now hosting "+n.split(" ")[0]+" for "+k+" viewer(s)."),this.emit("hosting",s,n.split(" ")[0],k)}break;case"CLEARCHAT":if(e.params.length>1){var x=h.get(e.tags["ban-duration"],null),T=h.replaceAll(h.get(e.tags["ban-reason"],null),{"\\\\s":" ","\\\\:":";","\\\\\\\\":"\\","\\r":"\r","\\n":"\n"});h.isNull(x)?(this.log.info("["+s+"] "+n+" has been banned. Reason: "+(T||"n/a")),this.emit("ban",s,n,T)):(this.log.info("["+s+"] "+n+" has been timed out for "+x+" seconds. Reason: "+(T||"n/a")),this.emit("timeout",s,n,T,~~x))}else this.log.info("["+s+"] Chat was cleared by a moderator."),this.emits(["clearchat","_promiseClear"],[[s],[null]]);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(){t.connect()},this.reconnectTimer);break;case"SERVERCHANGE":break;case"USERSTATE":e.tags.username=this.username,"mod"===e.tags["user-type"]&&(this.moderators[this.lastJoined]||(this.moderators[this.lastJoined]=[]),this.moderators[this.lastJoined].indexOf(this.username)<0&&this.moderators[this.lastJoined].push(this.username)),h.isJustinfan(this.getUsername())||this.userstate[s]||(this.userstate[s]=e.tags,this.lastJoined=s,this.channels.push(s),this.log.info("Joined "+s),this.emit("join",s,h.username(this.getUsername()),!0)),e.tags["emote-sets"]!==this.emotes&&this._updateEmoteset(e.tags["emote-sets"]),this.userstate[s]=e.tags;break;case"GLOBALUSERSTATE":this.globaluserstate=e.tags,"undefined"!=typeof e.tags["emote-sets"]&&this._updateEmoteset(e.tags["emote-sets"]);break;case"ROOMSTATE":if(h.channel(this.lastJoined)===h.channel(e.params[0])&&this.emit("_promiseJoin",null),e.tags.channel=h.channel(e.params[0]),this.emit("roomstate",h.channel(e.params[0]),e.tags),e.tags.hasOwnProperty("slow")&&!e.tags.hasOwnProperty("subs-only")&&("boolean"==typeof e.tags.slow?(this.log.info("["+s+"] This room is no longer in slow mode."),this.emits(["slow","slowmode","_promiseSlowoff"],[[s,!1,0],[s,!1,0],[null]])):(this.log.info("["+s+"] This room is now in slow mode."),this.emits(["slow","slowmode","_promiseSlow"],[[s,!0,~~e.tags.slow],[s,!0,~~e.tags.slow],[null]]))),e.tags.hasOwnProperty("followers-only")&&!e.tags.hasOwnProperty("subs-only"))if("-1"===e.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{var S=~~e.tags["followers-only"];this.log.info("["+s+"] This room is now in follower-only mode."),this.emits(["followersonly","followersmode","_promiseFollowers"],[[s,!0,S],[s,!0,S],[null]])}break;default:this.log.warn("Could not parse message from tmi.twitch.tv:\n"+JSON.stringify(e,null,4))}else if("jtv"===e.prefix)switch(e.command){case"MODE":"+o"===n?(this.moderators[s]||(this.moderators[s]=[]),this.moderators[s].indexOf(e.params[2])<0&&this.moderators[s].push(e.params[2]),this.emit("mod",s,e.params[2])):"-o"===n&&(this.moderators[s]||(this.moderators[s]=[]),this.moderators[s].filter(function(t){return t!=e.params[2]}),this.emit("unmod",s,e.params[2]));break;default:this.log.warn("Could not parse message from jtv:\n"+JSON.stringify(e,null,4))}else switch(e.command){case"353":this.emit("names",e.params[2],e.params[3].split(" "));break;case"366":break;case"JOIN":h.isJustinfan(this.getUsername())&&this.username===e.prefix.split("!")[0]&&(this.lastJoined=s,this.channels.push(s),this.log.info("Joined "+s),this.emit("join",s,e.prefix.split("!")[0],!0)),this.username!==e.prefix.split("!")[0]&&this.emit("join",s,e.prefix.split("!")[0],!1);break;case"PART":var E=!1;if(this.username===e.prefix.split("!")[0]){E=!0,this.userstate[s]&&delete this.userstate[s];var O=this.channels.indexOf(s);-1!==O&&this.channels.splice(O,1);var O=this.opts.channels.indexOf(s);-1!==O&&this.opts.channels.splice(O,1),this.log.info("Left "+s),this.emit("_promisePart",null)}this.emit("part",s,e.prefix.split("!")[0],E);break;case"WHISPER":this.log.info("[WHISPER] <"+e.prefix.split("!")[0]+">: "+n),e.tags.hasOwnProperty("username")||(e.tags.username=e.prefix.split("!")[0]),e.tags["message-type"]="whisper";var N=h.channel(e.tags.username);this.emits(["whisper","message"],[[N,e.tags,n,!1],[N,e.tags,n,!1]]);break;case"PRIVMSG":if(e.tags.username=e.prefix.split("!")[0],"jtv"===e.tags.username)if(n.includes("hosting you for")){var P=h.extractNumber(n);this.emit("hosted",s,h.username(n.split(" ")[0]),P,n.includes("auto"))}else n.includes("hosting you")&&this.emit("hosted",s,h.username(n.split(" ")[0]),0,n.includes("auto"));else n.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)?(e.tags["message-type"]="action",this.log.info("["+s+"] *<"+e.tags.username+">: "+n.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1]),this.emits(["action","message"],[[s,e.tags,n.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1],!1],[s,e.tags,n.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1],!1]])):e.tags.hasOwnProperty("bits")?this.emit("cheer",s,e.tags,n):(e.tags["message-type"]="chat",this.log.info("["+s+"] <"+e.tags.username+">: "+n),this.emits(["chat","message"],[[s,e.tags,n,!1],[s,e.tags,n,!1]]));break;default:this.log.warn("Could not parse message:\n"+JSON.stringify(e,null,4))}}},u.prototype.connect=function(){var e=this;return new Promise(function(t,s){e.server=h.get(e.opts.connection.server,"irc-ws.chat.twitch.tv"),e.port=h.get(e.opts.connection.port,80),e.secure&&(e.port=443),443===e.port&&(e.secure=!0),e.reconnectTimer=e.reconnectTimer*e.reconnectDecay,e.reconnectTimer>=e.maxReconnectInterval&&(e.reconnectTimer=e.maxReconnectInterval),e._openConnection(),e.once("_promiseConnect",function(n){n?s(n):t([e.server,~~e.port])})})},u.prototype._openConnection=function(){this.ws=new l((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)},u.prototype._onOpen=function(){h.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=h.get(this.opts.identity.username,h.justinfan()),this.password=h.password(h.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))},u.prototype._onMessage=function(e){var t=this,s=e.data.split("\r\n");s.forEach(function(e){h.isNull(e)||t.handleMessage(a.msg(e))})},u.prototype._onError=function(){var e=this;this.moderators={},this.userstate={},this.globaluserstate={},clearInterval(this.pingLoop),clearTimeout(this.pingTimeout),this.reason=h.isNull(this.ws)?"Connection closed.":"Unable to connect.",this.emits(["_promiseConnect","disconnected"],[[this.reason],[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},u.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.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},u.prototype._getPromiseDelay=function(){return this.currentLatency<=600?600:this.currentLatency+100},u.prototype._sendCommand=function(e,t,s,n){var i=this;return new Promise(function(o,r){h.promiseDelay(e).then(function(){r("No response from Twitch.")}),h.isNull(i.ws)||2===i.ws.readyState||3===i.ws.readyState?r("Not connected to server."):(h.isNull(t)?(i.log.info("Executing command: "+s),i.ws.send(s)):(i.log.info("["+h.channel(t)+"] Executing command: "+s),i.ws.send("PRIVMSG "+h.channel(t)+" :"+s)),n(o,r))})},u.prototype._sendMessage=function(e,t,s,n){var i=this;return new Promise(function(o,r){if(h.isNull(i.ws)||2===i.ws.readyState||3===i.ws.readyState||h.isJustinfan(i.getUsername()))r("Not connected to server.");else{if(i.userstate[h.channel(t)]||(i.userstate[h.channel(t)]={}),s.length>=500){var c=h.splitLine(s,500);s=c[0],setTimeout(function(){i._sendMessage(e,t,c[1],function(){})},350)}i.ws.send("PRIVMSG "+h.channel(t)+" :"+s);var l={};Object.keys(i.emotesets).forEach(function(e){i.emotesets[e].forEach(function(e){return h.isRegex(e.code)?a.emoteRegex(s,e.code,e.id,l):void a.emoteString(s,e.code,e.id,l)})});var u=h.merge(i.userstate[h.channel(t)],a.emotes({emotes:a.transformEmotes(l)||null}));s.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)?(u["message-type"]="action",i.log.info("["+h.channel(t)+"] *<"+i.getUsername()+">: "+s.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1]),i.emits(["action","message"],[[h.channel(t),u,s.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1],!0],[h.channel(t),u,s.match(/^\u0001ACTION ([^\u0001]+)\u0001$/)[1],!0]])):(u["message-type"]="chat",i.log.info("["+h.channel(t)+"] <"+i.getUsername()+">: "+s),i.emits(["chat","message"],[[h.channel(t),u,s,!0],[h.channel(t),u,s,!0]])),n(o,r)}})},u.prototype._updateEmoteset=function(e){var t=this;this.emotes=e,this.api({url:"/chat/emoticon_images?emotesets="+e,headers:{Authorization:"OAuth "+h.password(h.get(this.opts.identity.password,"")).replace("oauth:",""),"Client-ID":this.clientId}},function(s,n,i){return s?void setTimeout(function(){t._updateEmoteset(e)},6e4):(t.emotesets=i.emoticon_sets||{},t.emit("emotesets",e,t.emotesets))})},u.prototype.getUsername=function(){return this.username},u.prototype.getOptions=function(){return this.opts},u.prototype.getChannels=function(){return this.channels},u.prototype.isMod=function(e,t){return this.moderators[h.channel(e)]||(this.moderators[h.channel(e)]=[]),this.moderators[h.channel(e)].indexOf(h.username(t))>=0},u.prototype.readyState=function(){return h.isNull(this.ws)?"CLOSED":["CONNECTING","OPEN","CLOSING","CLOSED"][this.ws.readyState]},u.prototype.disconnect=function(){var e=this;return new Promise(function(t,s){h.isNull(e.ws)||3===e.ws.readyState?(e.log.error("Cannot disconnect from server. Socket is not opened or connection is already closing."),s("Cannot disconnect from server. Socket is not opened or connection is already closing.")):(e.wasCloseCalled=!0,e.log.info("Disconnecting from server.."),e.ws.close(),e.once("_promiseDisconnect",function(){t([e.server,~~e.port])}))})},u.prototype.utils={levenshtein:function(e,t,s){var n=1,i=1,o=1;if(s=h.get(s,!1),s||(e=e.toLowerCase(),t=t.toLowerCase()),e==t)return 0;var r=e.length,a=t.length;if(0===r)return a*n;if(0===a)return r*o;var c=!1;try{c=!"0"[0]}catch(l){c=!0}c&&(e=e.split(""),t=t.split(""));var u,m,f,p,d,g,_=new Array(a+1),b=new Array(a+1);for(m=0;a>=m;m++)_[m]=m*n;for(u=0;r>u;u++){for(b[0]=_[0]+o,m=0;a>m;m++)f=_[m]+(e[u]==t[m]?0:i),p=_[m+1]+o,f>p&&(f=p),d=b[m]+n,f>d&&(f=d),b[m+1]=f;g=_,_=b,b=g}return f=_[a]},raffle:{init:function(e){this.raffleChannels||(this.raffleChannels={}),this.raffleChannels[h.channel(e)]||(this.raffleChannels[h.channel(e)]=[])},enter:function(e,t){this.init(e),this.raffleChannels[h.channel(e)].push(t.toLowerCase())},leave:function(e,t){this.init(e);var s=this.raffleChannels[h.channel(e)].indexOf(h.username(t));return s>=0?(this.raffleChannels[h.channel(e)].splice(s,1),!0):!1},pick:function(e){this.init(e);var t=this.raffleChannels[h.channel(e)].length;return t>=1?this.raffleChannels[h.channel(e)][Math.floor(Math.random()*t)]:null},reset:function(e){this.init(e),this.raffleChannels[h.channel(e)]=[]},count:function(e){return this.init(e),this.raffleChannels[h.channel(e)]?this.raffleChannels[h.channel(e)].length:0},isParticipating:function(e,t){return this.init(e),this.raffleChannels[h.channel(e)].indexOf(h.username(t))>=0}},symbols:function(e){for(var t=0,s=0;s=n||n>=127||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 h.isNull(s)?0:s.length/t}},"undefined"!=typeof t&&t.exports&&(t.exports=u),"undefined"!=typeof window&&(window.tmi={},window.tmi.client=u)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./api":2,"./commands":4,"./events":5,"./logger":6,"./parser":7,"./timer":8,"./utils":9,ws:10}],4:[function(e,t,s){"use strict";function n(e,t){var s=this;return e=h.channel(e),t=h.get(t,30),this._sendCommand(this._getPromiseDelay(),e,"/followers "+t,function(n,i){s.once("_promiseFollowers",function(s){s?i(s):n([e,~~t])})})}function i(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/followersoff",function(s,n){t.once("_promiseFollowersoff",function(t){t?n(t):s([e])})})}function o(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),null,"PART "+e,function(s,n){t.once("_promisePart",function(t){t?n(t):s([e])})})}function r(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/r9kbeta",function(s,n){t.once("_promiseR9kbeta",function(t){t?n(t):s([e])})})}function a(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/r9kbetaoff",function(s,n){t.once("_promiseR9kbetaoff",function(t){t?n(t):s([e])})})}function c(e,t){var s=this;return e=h.channel(e),t=h.get(t,300),this._sendCommand(this._getPromiseDelay(),e,"/slow "+t,function(n,i){s.once("_promiseSlow",function(s){s?i(s):n([e,~~t])})})}function l(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/slowoff",function(s,n){t.once("_promiseSlowoff",function(t){t?n(t):s([e])})})}var h=e("./utils");t.exports={action:function(e,t){return e=h.channel(e),t="ACTION "+t+"",this._sendMessage(this._getPromiseDelay(),e,t,function(s,n){s([e,t])})},ban:function(e,t,s){var n=this;return e=h.channel(e),t=h.username(t),s=h.get(s,""),this._sendCommand(this._getPromiseDelay(),e,"/ban "+t+" "+s,function(i,o){n.once("_promiseBan",function(n){n?o(n):i([e,t,s])})})},clear:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/clear",function(s,n){t.once("_promiseClear",function(t){t?n(t):s([e])})})},color:function(e,t){var s=this;return t=h.get(t,e),this._sendCommand(this._getPromiseDelay(),"#tmijs","/color "+t,function(e,n){s.once("_promiseColor",function(s){s?n(s):e([t])})})},commercial:function(e,t){var s=this;return e=h.channel(e),t=h.get(t,30),this._sendCommand(this._getPromiseDelay(),e,"/commercial "+t,function(n,i){s.once("_promiseCommercial",function(s){s?i(s):n([e,~~t])})})},emoteonly:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/emoteonly",function(s,n){t.once("_promiseEmoteonly",function(t){t?n(t):s([e])})})},emoteonlyoff:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/emoteonlyoff",function(s,n){t.once("_promiseEmoteonlyoff",function(t){t?n(t):s([e])})})},followersonly:n,followersmode:n,followersonlyoff:i,followersmodeoff:i,host:function(e,t){var s=this;return e=h.channel(e),t=h.username(t),this._sendCommand(2e3,e,"/host "+t,function(n,i){s.once("_promiseHost",function(s,o){s?i(s):n([e,t,~~o])})})},join:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),null,"JOIN "+e,function(s,n){t.once("_promiseJoin",function(t){t?n(t):s([e])})})},mod:function(e,t){var s=this;return e=h.channel(e),t=h.username(t),this._sendCommand(this._getPromiseDelay(),e,"/mod "+t,function(n,i){s.once("_promiseMod",function(s){s?i(s):n([e,t])})})},mods:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/mods",function(s,n){t.once("_promiseMods",function(i,o){i?n(i):(o.forEach(function(s){t.moderators[e]||(t.moderators[e]=[]),t.moderators[e].indexOf(s)<0&&t.moderators[e].push(s)}),s(o))})})},part:o,leave:o,ping:function(){var e=this;return this._sendCommand(this._getPromiseDelay(),null,"PING",function(t,s){e.latency=new Date,e.pingTimeout=setTimeout(function(){null!==e.ws&&(e.wasCloseCalled=!1,e.log.error("Ping timeout."),e.ws.close(),clearInterval(e.pingLoop),clearTimeout(e.pingTimeout))},h.get(e.opts.connection.timeout,9999)),e.once("_promisePing",function(e){t([parseFloat(e)])})})},r9kbeta:r,r9kmode:r,r9kbetaoff:a,r9kmodeoff:a,raw:function(e){return this._sendCommand(this._getPromiseDelay(),null,e,function(t,s){t([e])})},say:function(e,t){return e=h.channel(e),t.startsWith(".")&&!t.startsWith("..")||t.startsWith("/")||t.startsWith("\\")?"me "===t.substr(1,3)?this.action(e,t.substr(4)):this._sendCommand(this._getPromiseDelay(),e,t,function(s,n){s([e,t])}):this._sendMessage(this._getPromiseDelay(),e,t,function(s,n){s([e,t])})},slow:c,slowmode:c,slowoff:l,slowmodeoff:l,subscribers:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/subscribers",function(s,n){t.once("_promiseSubscribers",function(t){t?n(t):s([e])})})},subscribersoff:function(e){var t=this;return e=h.channel(e),this._sendCommand(this._getPromiseDelay(),e,"/subscribersoff",function(s,n){t.once("_promiseSubscribersoff",function(t){t?n(t):s([e])})})},timeout:function(e,t,s,n){var i=this;return e=h.channel(e),t=h.username(t),h.isNull(s)||h.isInteger(s)||(n=s,s=300),s=h.get(s,300),n=h.get(n,""),this._sendCommand(this._getPromiseDelay(),e,"/timeout "+t+" "+s+" "+n,function(o,r){i.once("_promiseTimeout",function(i){i?r(i):o([e,t,~~s,n])})})},unban:function(e,t){var s=this;return e=h.channel(e),t=h.username(t),this._sendCommand(this._getPromiseDelay(),e,"/unban "+t,function(n,i){
2 | s.once("_promiseUnban",function(s){s?i(s):n([e,t])})})},unhost:function(e){var t=this;return e=h.channel(e),this._sendCommand(2e3,e,"/unhost",function(s,n){t.once("_promiseUnhost",function(t){t?n(t):s([e])})})},unmod:function(e,t){var s=this;return e=h.channel(e),t=h.username(t),this._sendCommand(this._getPromiseDelay(),e,"/unmod "+t,function(n,i){s.once("_promiseUnmod",function(s){s?i(s):n([e,t])})})},whisper:function(e,t){var s=this;return e=h.username(e),e===this.getUsername()?Promise.reject("Cannot send a whisper to the same account."):this._sendCommand(this._getPromiseDelay(),"#tmijs","/w "+e+" "+t,function(n,i){var o=h.channel(e),r=h.merge({"message-type":"whisper","message-id":null,"thread-id":null,username:s.getUsername()},s.globaluserstate);s.emits(["whisper","message"],[[o,r,t,!0],[o,r,t,!0]]),n([e,t])})}}},{"./utils":9}],5:[function(e,t,s){"use strict";function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function r(e){return"object"===("undefined"==typeof e?"undefined":c(e))&&null!==e}function a(e){return void 0===e}var c="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,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||0>e||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;sc;c++)l[c].apply(this,o);return!0},n.prototype.addListener=function(e,t){var s;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?r(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,r(this._events[e])&&!this._events[e].warned&&(s=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,s&&s>0&&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.on=n.prototype.addListener,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(!i(t))throw TypeError("listener must be a function");var n=!1;if(this._events.hasOwnProperty(e)&&"_"===e.charAt(0)){var o=1,r=e;for(var a in this._events)this._events.hasOwnProperty(a)&&a.startsWith(r)&&o++;e+=o}return s.listener=t,this.on(e,s),this},n.prototype.removeListener=function(e,t){var s,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=this._events[e],o=s.length,n=-1,s===t||i(s.listener)&&s.listener===t){if(delete this._events[e],this._events.hasOwnProperty(e+"2")&&"_"===e.charAt(0)){var c=e;for(var l in this._events)this._events.hasOwnProperty(l)&&l.startsWith(c)&&(isNaN(parseInt(l.substr(l.length-1)))||(this._events[e+parseInt(l.substr(l.length-1)-1)]=this._events[l],delete this._events[l]));this._events[e]=this._events[e+"1"],delete this._events[e+"1"]}this._events.removeListener&&this.emit("removeListener",e,t)}else if(r(s)){for(a=o;a-- >0;)if(s[a]===t||s[a].listener&&s[a].listener===t){n=a;break}if(0>n)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(s=this._events[e],i(s))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){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(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";function n(e){return function(t){r[e]>=r[o]&&console.log("["+i.formatDate(new Date)+"] "+e+": "+t)}}var i=e("./utils"),o="info",r={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};t.exports={setLevel:function(e){o=e},trace:n("trace"),debug:n("debug"),info:n("info"),warn:n("warn"),error:n("error"),fatal:n("fatal")}},{"./utils":9}],7:[function(e,t,s){"use strict";var n=e("./utils");t.exports={badges:function i(e){if(n.isString(e.badges)){for(var i={},t=e.badges.split(","),s=0;ss?(t.command=e.slice(s),t):null;for(t.command=e.slice(s,n),s=n+1;32===e.charCodeAt(s);)s++;for(;s").replace(/\\"\\;/g,'"').replace(/\\'\\;/g,"'")},addWord:function(e,t){return 0!=e.length&&(e+=" "),e+=t},channel:function i(e){var i="undefined"==typeof e||null===e?"":e;return"#"===i.charAt(0)?i.toLowerCase():"#"+i.toLowerCase()},extractNumber:function(e){for(var t=e.split(" "),s=0;st?"0":"")+t,s=(10>s?"0":"")+s,t+":"+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 t.exports="object"===("undefined"==typeof e?"undefined":s(e))&&"[object process]"===Object.prototype.toString.call(e)}catch(n){return!1}},isExtension:function(){try{return!!(window.chrome&&chrome.runtime&&chrome.runtime.id)}catch(e){return!1}},merge:function(e,t){for(var s in t)try{t[s].constructor==Object?e[s]=n.merge(e[s],t[s]):e[s]=t[s]}catch(i){e[s]=t[s]}return e},splitLine:function(e,t){var s=e.substring(0,t).lastIndexOf(" ");return[e.substring(0,s),e.substring(s+1)]},toNumber:function(e,t){if(null===e)return 0;var s=Math.pow(10,n.isFinite(t)?t:0);return Math.round(e*s)/s},union:function(e,t){for(var s={},n=[],i=0;i1)for(var s=1;s