diff --git a/.gitignore b/.gitignore index 2106bee..e0fb02f 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,7 @@ assets .idea .gitignore -cookies.tmp \ No newline at end of file +cookies.tmp + +# bin +bin diff --git a/README.md b/README.md index b969dd7..0942b97 100644 --- a/README.md +++ b/README.md @@ -1,124 +1,5 @@ -plugAPI -======= +#plugAPI-custom -[![NPM](https://nodei.co/npm/plugapi.png?downloads=true)](https://nodei.co/npm/plugapi/) +Our custom version of the API for sue with hoonzbot. -A generic API for creating plug.dj bots. - -Originally by [Chris Vickery](https://github.com/chrisinajar), now maintained by [TAT](https://github.com/TATDK) and [The plug³ Team](https://github.com/plugCubed). - -**NOTE:** Currently not supporting facebook login. - -## How to use -Run the following: - -```npm install plugapi --production``` - -You can choose to instantiate the instance both sync or async. - -**Sync** -```javascript -var PlugAPI = require('plugapi'); - -var bot = new PlugAPI({ - "email": "", - "password": "" -}); -bot.connect('roomslug'); // The part after https://plug.dj - -bot.on('roomJoin', function(room) { - console.log("Joined " + room); -}); -``` - -**Async** -```javascript -var PlugAPI = require('plugapi'); - -new PlugAPI({ - "email": "", - "password": "" -}, function(bot) { - bot.connect('roomslug'); // The part after https://plug.dj - - bot.on('roomJoin', function(room) { - console.log("Joined " + room); - }); -}); -``` - -## Examples -Here are some bots using this API. - -| Botname | Room | -| ---------------------------------------------------- | --------------------------------------------------------------- | -| AuntJackie | [Mix-N-Mash](https://plug.dj/mix-n-mash-2) | -| [BeavisBot](https://github.com/AvatarKava/BeavisBot) | [I <3 the 80's and 90's](https://plug.dj/i-the-80-s-and-90-s-1) | -| -DnB- | [Drum & Bass](https://plug.dj/drum-bass) | -| FlavorBar | [Flavorz](https://plug.dj/flavorz) | -| FoxBot | [Approaching Nirvana](https://plug.dj/approachingnirvana) | - -Have a bot that uses the API? Let me know! - -## EventListener -You can listen on essentially any event that plug emits. -```javascript -// basic chat handler to show incoming chats formatted nicely -bot.on('chat', function(data) { - if (data.type == 'emote') - console.log(data.from + data.message); - else - console.log(data.from + "> " + data.message); -}); -``` - -Here's an example for automatic reconnecting on errors / close events! -```javascript -var reconnect = function() { bot.connect(ROOM); }; - -bot.on('close', reconnect); -bot.on('error', reconnect); -``` - -## Events - -Read about some of the events on the [wiki](https://github.com/TATDK/plugapi/wiki/events). - -## Actions - -Read about the actions on the [wiki](https://github.com/TATDK/plugapi/wiki/actions). - -## Contribute -1. Clone repository to empty folder. -2. Cd to the repository. -3. Run `npm install` to set up the environment. -4. Edit your code. -5. Run `grunt` to compile the code and test. -6. After it's bug free, you may submit it as a Pull Request to the main repo. - -## Misc - -#### Multi line chat -Since Plug.dj cuts off chat messages at 250 characters, you can choose to have your bot split up chat messages into multiple lines: - -```javascript -var bot = new PlugAPI(auth); -bot.multiLine = true; // Set to true to enable multi line chat. Default is false -bot.multiLineLimit = 5; // Set to the maximum number of lines the bot should split messages up into. Any text beyond this number will just be omitted. Default is 5. -``` - -#### TCP Server -You can start up a TCP server the bot will listen to, for remote administration - -Example: -```javascript - bot.tcpListen(6666, 'localhost'); - bot.on('tcpConnect', function(socket) { - // executed when someone telnets into localhost port 6666 - }); - - bot.on('tcpMessage', function(socket, msg) { - // Use socket.write, for example, to send output back to the telnet session - // 'msg' is whatever was entered by the user in the telnet session - }); -``` +DISCONTINUED AS PLUG.DJ IS GONE diff --git a/bin/bufferObject.js b/bin/bufferObject.js deleted file mode 100644 index 70293ee..0000000 --- a/bin/bufferObject.js +++ /dev/null @@ -1,27 +0,0 @@ -//# sourceMappingURL=./bufferObject.js.map -require('source-map-support').install(); -/*The MIT License -=============== - -Copyright (c) 2014 Chris Vickery, Thomas "TAT" Andresen and other contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.*/ -var util=require("util"); -function BufferObject(c,d,b){if("function"!=typeof d)throw Error("BufferObject requires a update function");b=b||6E4;return{lastUpdate:c?Date.now():0,data:c||null,set:function(a){this.data=a;this.lastUpdate=Date.now()},get:function(a){if(null!=this.data&&(0>b||this.lastUpdate>=Date.now()-b))"function"==typeof a&&a(this.data);else{var e=this;d(function(b,c){b?e.get():(e.set(c),"function"==typeof a&&a(c))})}},push:function(a){this.get();util.isArray(this.data)&&this.data.push(a)},remove:function(a){this.get(); -for(var b in this.data)if(this.data.hasOwnProperty(b)&&this.data[b]==a){this.data.splice(b,1);break}},removeAt:function(a){this.get();util.isArray(this.data)&&a1E3*this.secondsSinceMidnight(b)&&a++;return~~a},hoursSince:function(a){return~~((this.ServerDate().getTime()-a.getTime())/36E5)},minutesSince:function(a){return~~((this.ServerDate().getTime()-a.getTime())/6E4)},secondsSince:function(a){return~~((this.ServerDate().getTime()-a.getTime())/1E3)},monthName:function(a,b){var c=this.MONTHS[a.getMonth()];return b?c:c.substr(0,3)},secondsSinceMidnight:function(a){var b= -new Date(a.getTime());this.midnight(b);return~~((a.getTime()-b.getTime())/1E3)},midnight:function(a){a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)},minutesUntil:function(a){return~~((a.getTime()-this.ServerDate().getTime())/6E4)},millisecondsUntil:function(a){return a.getTime()-this.ServerDate().getTime()},ServerDate:function(){return new Date((new Date).getTime()+this.OFFSET)},getServerEpoch:function(){return Date.now()+this.OFFSET},getSecondsElapsed:function(a){return a&&"0"!= -a?this.secondsSince(new Date(a.substr(0,a.indexOf(".")))):0},convertUnixDateStringToDate:function(a){return a?new Date(a.substr(0,4),Number(a.substr(5,2))-1,a.substr(8,2),a.substr(11,2),a.substr(14,2),a.substr(17,2)):null}}; -function queueTicker(){serverRequests.running=!0;var a=serverRequests.sent["POST","PUT","GET","DELETE"].indexOf(a)?logger.error(a,"needs update"):(d="function"===typeof d?__bind(d,that):function(){},a={method:a,url:"https://plug.dj/_/"+b,headers:{Accept:"application/json, text/javascript, */*; q=0.01","Content-Type":"application/json","User-Agent":"plugAPI_"+PlugAPIInfo.version,Cookie:_cookies.toString()}},void 0!==c&&(a.body=JSON.stringify(c)),e&&!0===e?sendREST(a,d):(serverRequests.queue.push({type:"rest",opts:a,callback:d}),serverRequests.running|| -queueTicker()))}function sendREST(a,b){request(a,function(a,d,e){if(a)logger.error("[REST Error]",a),b(a,null);else try{e=JSON.parse(e),"ok"===e.status?b(null,e.data):b(e.status,null)}catch(f){logger.error("[REST Error]",f),b(f,null)}})}function joinRoom(a,b){queueREST("POST","rooms/join",{slug:a},function(c){c?(logger.error("Error while joining:",c?c:"Unknown error"),setTimeout(function(){joinRoom(a,b)},1E3)):getRoomState(b)})} -function getRoomState(a){queueREST("GET","rooms/state",void 0,function(b,c){b?(logger.error("Error getting room state:",b?b:"Unknown error"),setTimeout(function(){getRoomState(a)},1E3)):(connectingRoomSlug=null,initRoom(c[0],function(){"function"===typeof a&&a(null,c)}))})} -function receivedChatMessage(a){var b,c,d,e,f;if(initialized){c=null==a.from;var h=!c&&room.isMuted(a.from.id),g=h&&!that.mutedTriggerNormalEvents?"muted:":"";if(c||0!==a.message.indexOf(commandPrefix)||!that.processOwnMessages&&a.from.id===room.getSelf().id)"emote"==a.type&&that.emit(g+PlugAPI.events.CHAT+":emote",a);else{c=a.message.substr(commandPrefix.length).split(" ")[0];a.command=c;a.args=a.message.substr(commandPrefix.length+c.length+1);d=a.args.indexOf("@");e=room.getUsers();for(f=Math.ceil(1E10* -Math.random());-1k.username.length)&&(k=e[b]);null!==k&&(a.args=a.args.substr(0,d)+"%MENTION-"+f+"-"+a.mentions.length+"%"+a.args.substr(d+k.username.length+1),a.mentions.push(k));d=a.args.indexOf("@",d+1)}a.args=a.args.split(" ");for(b in a.args)a.args.hasOwnProperty(b)&&(isNaN(a.args[b])||(a.args[b]=~~a.args[b]));for(b in a.mentions)a.mentions.hasOwnProperty(b)&&(a.args[a.args.indexOf("%MENTION-"+ -f+"-"+b+"%")]=a.mentions[b]);if("function"===typeof that.preCommandHandler&&!1===that.preCommandHandler(a))return;a.respond=function(){var a=Array.prototype.slice.call(arguments).join(" ");return that.sendChat("@"+this.from.username+" "+a)};a.respondTimeout=function(){var a,b;a=Array.prototype.slice.call(arguments);b=parseInt(a.splice(a.length-1,1),10);a=a.join(" ");return that.sendChat("@"+this.from.username+" "+a,b)};a.havePermission=function(a,b){void 0===a&&(a=0);if(that.havePermission(this.from.id, -a))return"function"===typeof b&&b(!0),!0;"function"===typeof b&&b(!1);return!1};a.isFrom=function(b,c,d){"string"===typeof b&&(b=[b]);if(void 0===b||!util.isArray(b))return"function"===typeof d&&d(),!1;(b=-1e.indexOf(f)&&(f=l)}""!=f&&(b=b.createHash(f), -b.update(a.email),b.update(a.password),c=b.digest("hex"))})(require("crypto"));_cookies=new CookieHandler(c);authenticationInfo=a;PerformLogin(b);this.multiLine=!1;this.multiLineLimit=5;this.processOwnMessages=!1;this.deleteCommands=!0;this.mutedTriggerNormalEvents=!1;room.registerUserExtensions(this);this.preCommandHandler=function(a){return!0};logger.info("Running plugAPI v."+PlugAPIInfo.version)};PlugAPI.CreateLogger=function(a){a||(a="Unknown");return new Logger(a)};PlugAPI.Utils=require("./utils"); -PlugAPI.ROOM_ROLE={NONE:0,RESIDENTDJ:1,BOUNCER:2,MANAGER:3,COHOST:4,HOST:5};PlugAPI.GLOBAL_ROLES={NONE:0,VOLUNTEER:2,AMBASSADOR:3,LEADER:4,ADMIN:5};PlugAPI.STATUS={AVAILABLE:0,AFK:1,WORKING:2,GAMING:3};PlugAPI.BAN={HOUR:"h",DAY:"d",PERMA:"f"};PlugAPI.BAN_REASON={SPAMMING_TROLLING:1,VERBAL_ABUSE:2,OFFENSIVE_MEDIA:3,INAPPROPRIATE_GENRE:4,NEGATIVE_ATTITUDE:5};PlugAPI.MUTE={SHORT:"s",MEDIUM:"m",LONG:"l"}; -PlugAPI.MUTE_REASON={VIOLATING_COMMUNITY_RULES:1,VERBAL_ABUSE:2,SPAMMING_TROLLING:3,OFFENSIVE_LANGUAGE:4,NEGATIVE_ATTITUDE:5}; -PlugAPI.events={ADVANCE:"advance",BAN:"ban",BOOTH_LOCKED:"boothLocked",CHAT:"chat",CHAT_COMMAND:"command",CHAT_DELETE:"chatDelete",COMMAND:"command",DJ_LIST_CYCLE:"djListCycle",DJ_LIST_UPDATE:"djListUpdate",DJ_LIST_LOCKED:"djListLocked",EARN:"earn",FOLLOW_JOIN:"followJoin",FLOOD_CHAT:"floodChat",GRAB:"grab",KILL_SESSION:"killSession",MODERATE_ADD_DJ:"modAddDJ",MODERATE_ADD_WAITLIST:"modAddWaitList",MODERATE_AMBASSADOR:"modAmbassador",MODERATE_BAN:"modBan",MODERATE_MOVE_DJ:"modMoveDJ",MODERATE_MUTE:"modMute", -MODERATE_REMOVE_DJ:"modRemoveDJ",MODERATE_REMOVE_WAITLIST:"modRemoveWaitList",MODERATE_SKIP:"modSkip",MODERATE_STAFF:"modStaff",NOTIFY:"notify",PDJ_MESSAGE:"pdjMessage",PDJ_UPDATE:"pdjUpdate",PING:"ping",PLAYLIST_CYCLE:"playlistCycle",REQUEST_DURATION:"requestDuration",REQUEST_DURATION_RETRY:"requestDurationRetry",ROOM_CHANGE:"roomChanged",ROOM_DESCRIPTION_UPDATE:"roomDescriptionUpdate",ROOM_JOIN:"roomJoin",ROOM_NAME_UPDATE:"roomNameUpdate",ROOM_VOTE_SKIP:"roomVoteSkip",ROOM_WELCOME_UPDATE:"roomWelcomeUpdate", -SESSION_CLOSE:"sessionClose",SKIP:"skip",STROBE_TOGGLE:"strobeToggle",USER_COUNTER_UPDATE:"userCounterUpdate",USER_FOLLOW:"userFollow",USER_JOIN:"userJoin",USER_LEAVE:"userLeave",USER_UPDATE:"userUpdate",VOTE:"vote"};PlugAPI.prototype.addListener=function(){EventEmitter.addListener.apply(EventEmitter,arguments);return this};PlugAPI.prototype.on=function(){EventEmitter.on.apply(EventEmitter,arguments);return this}; -PlugAPI.prototype.onAny=function(){EventEmitter.onAny.apply(EventEmitter,arguments);return this};PlugAPI.prototype.offAny=function(){EventEmitter.offAny.apply(EventEmitter,arguments);return this};PlugAPI.prototype.once=function(){EventEmitter.once.apply(EventEmitter,arguments);return this};PlugAPI.prototype.many=function(){EventEmitter.many.apply(EventEmitter,arguments);return this};PlugAPI.prototype.removeListener=function(){EventEmitter.removeListener.apply(EventEmitter,arguments);return this}; -PlugAPI.prototype.off=function(){EventEmitter.off.apply(EventEmitter,arguments);return this};PlugAPI.prototype.removeAllListeners=function(){EventEmitter.removeAllListeners.apply(EventEmitter,arguments);return this};PlugAPI.prototype.setMaxListeners=function(){EventEmitter.setMaxListeners.apply(EventEmitter,arguments);return this};PlugAPI.prototype.listeners=function(){EventEmitter.listeners.apply(EventEmitter,arguments);return this}; -PlugAPI.prototype.emit=function(){EventEmitter.emit.apply(EventEmitter,arguments);return this};PlugAPI.prototype.connect=function(a){if(!a||"string"!==typeof a||0===a.length||-1=this.multiLineLimit);d++);else queueChat(a,b)};PlugAPI.prototype.getAvatar=function(){return room.getUser().avatarID}; -PlugAPI.prototype.getAvatars=function(a){if(!room.getRoomMeta().slug)return!1;queueREST("GET",endpoints.USER_GET_AVATARS,void 0,a);return!0};PlugAPI.prototype.setAvatar=function(a,b){if(!room.getRoomMeta().slug||!a)return!1;queueREST("PUT",endpoints.USER_SET_AVATAR,{id:a},b);return!0};PlugAPI.prototype.getAdmins=function(){return room.getAdmins()};PlugAPI.prototype.getAllStaff=function(a){a&&"function"===typeof a?queueREST("GET","staff",void 0,a):logger.error("Missing callback for getAllStaff")}; -PlugAPI.prototype.getAmbassadors=function(){return room.getAmbassadors()};PlugAPI.prototype.getAudience=function(){return room.getAudience()};PlugAPI.prototype.getDJ=function(){return room.getDJ()};PlugAPI.prototype.getDJs=function(){return room.getDJs()};PlugAPI.prototype.getHost=function(){return room.getHost()};PlugAPI.prototype.getSelf=function(){return room.getSelf()};PlugAPI.prototype.getStaff=function(){return room.getStaff()};PlugAPI.prototype.getUser=function(a){return room.getUser(a)}; -PlugAPI.prototype.getUsers=function(){return room.getUsers()};PlugAPI.prototype.getWaitList=function(){return room.getWaitList()};PlugAPI.prototype.getWaitListPosition=function(a){return room.getWaitListPosition(a)};PlugAPI.prototype.havePermission=function(a,b,c){return c?room.haveGlobalPermission(a,b):room.haveRoomPermission(a,b)||room.haveGlobalPermission(a,b)};PlugAPI.prototype.getStatus=function(a){return room.getUser(a).status}; -PlugAPI.prototype.setStatus=function(a,b){if(!room.getRoomMeta().slug||!a||0>a||3a.length)return!1;commandPrefix=a;return!0};PlugAPI.prototype.getLoggerSettings=function(){return logger.settings};PlugAPI.prototype.setLogger=function(a){var b=["info","warn","warning","error"];if(a&&"object"===typeof a&&!util.isArray(a)){for(var c in b)if(b.hasOwnProperty(c)&&"function"!==typeof a[b[c]])return!1;logger=a;return!0}return!1}; -PlugAPI.prototype.woot=function(a){if(null==this.getMedia())return!1;queueREST("POST","votes",{direction:1,historyID:room.getHistoryID()},a);return!0};PlugAPI.prototype.meh=function(a){if(null==this.getMedia())return!1;queueREST("POST","votes",{direction:-1,historyID:room.getHistoryID()},a);return!0}; -PlugAPI.prototype.grab=function(a){if(!initialized||null==this.getMedia())return!1;var b=that.getActivePlaylist();if(null==b)return!1;queueREST("POST","grabs",{playlistID:b.id,historyID:room.getHistoryID()},function(c,d){c||b.count++;"function"==typeof a&&a(c,d)});return!0}; -PlugAPI.prototype.activatePlaylist=function(a,b){if(!room.getRoomMeta().slug||!a)return!1;var c=this.getPlaylist(a);if(null==c)return!1;queueREST("PUT",endpoints.PLAYLIST+"/"+a+"/activate",void 0,function(a,e){a||(that.getActivePlaylist().active=!1,c.active=!0);"function"==typeof b&&b(a,e)});return!0}; -PlugAPI.prototype.addSongToPlaylist=function(a,b,c){if(!room.getRoomMeta().slug||!a||!b)return!1;var d=that.getPlaylist(a);if(null==d)return!1;queueREST("GET",endpoints.PLAYLIST+"/"+a+"/media/insert",{media:b,append:!0},function(a,b){a||d.count++;"function"==typeof c&&c(a,b)});return!0}; -PlugAPI.prototype.createPlaylist=function(a,b){if(!room.getRoomMeta().slug||"String"!=typeof a||0==a.length)return!1;queueREST("POST",endpoints.PLAYLIST,{name:a},function(a,d){a||playlists.push(d[0]);"function"==typeof b&&b(a,d)});return!0}; -PlugAPI.prototype.deletePlaylist=function(a,b){if(!room.getRoomMeta().slug||!a||null==this.getPlaylist(a))return!1;queueREST("DELETE",endpoints.PLAYLIST+"/"+a,void 0,function(c,d){if(!c){var e=playlists.get(),f;for(f in e)if(e.hasOwnProperty(f)&&e[f].id==a){playlists.removeAt(f);break}}"function"==typeof b&&b(c,d)});return!0};PlugAPI.prototype.getActivePlaylist=function(){var a=playlists.get(),b;for(b in a)if(a.hasOwnProperty(b)&&a[b].active)return a[b];return null}; -PlugAPI.prototype.getPlaylist=function(a){var b=playlists.get(),c;for(c in b)if(b.hasOwnProperty(c)&&b[c].id==a)return b[c];return null};PlugAPI.prototype.getPlaylists=function(a){return playlists.get(a)};PlugAPI.prototype.getPlaylistMedias=function(a,b){if(null==this.getPlaylist(a))return!1;queueREST("GET",endpoints.PLAYLIST+"/"+a+"/media",void 0,b);return!0}; -PlugAPI.prototype.playlistMoveMedia=function(a,b,c,d){if(!(room.getRoomMeta().slug&&a&&b&&util.isArray(b))||util.isArray(b)&&0b?1:--b},c);return!0}; -PlugAPI.prototype.moderateMuteUser=function(a,b,c,d){if(!room.getRoomMeta().slug)return!1;if(null!=c){if(!objectContainsValue(PlugAPI.MUTE,c))return!1}else c=PlugAPI.MUTE.LONG;if(null!=b){if(!objectContainsValue(PlugAPI.MUTE_REASON,b))return!1}else b=PlugAPI.MUTE_REASON.VIOLATING_COMMUNITY_RULES;var e=this.getUser(a);(null!==e?room.getPermissions(e).canModMute:this.havePermission(void 0,PlugAPI.ROOM_ROLE.BOUNCER))&&queueREST("POST",endpoints.MODERATE_MUTE,{userID:a,reason:b,duration:c},d);return!0}; -PlugAPI.prototype.moderateRemoveDJ=function(a,b){if(!room.getRoomMeta().slug||!this.havePermission(void 0,PlugAPI.ROOM_ROLE.BOUNCER)||!room.isDJ(a)&&!room.isInWaitList(a)||room.getBoothMeta().isLocked&&!this.havePermission(void 0,PlugAPI.ROOM_ROLE.MANAGER))return!1;queueREST("DELETE",endpoints.MODERATE_REMOVE_DJ+a,void 0,b);return!0}; -PlugAPI.prototype.moderateSetRole=function(a,b,c){if(!room.getRoomMeta().slug||isNaN(b)||0>b||5b?"0"+b.toString(10):b.toString(10)}function timestamp(){var b=new Date,a=[pad(b.getHours()),pad(b.getMinutes()),pad(b.getSeconds())].join(":");return[pad(b.getDate()),months[b.getMonth()],a].join(" ")} -function chalkPaint(b,a){var c=chalk,d;for(d in b)b.hasOwnProperty(d)&&(c=c[b[d]]);return c(a)} -function Logger(b){function a(b){return function(){var a=Array.prototype.slice.call(arguments);a.unshift(b);c.apply(this,a)}}function c(){var a=Array.prototype.slice.call(arguments),c="info";void 0!==levels[a[0]]&&(c=a.shift());a.unshift(Array(10-b.length-2).join(" "));a.unshift("["+b+"]");a.unshift(Array(10-c.length-2).join(" "));a.unshift(chalkPaint(levels[c],"["+c.toUpperCase()+"]"));a.unshift(timestamp());d.consoleOutput&&console.log.apply(console,a);d.fileOutput&&fs.appendFileSync(d.filePath, -chalk.stripColor(a.join(" "))+"\n")}var d={fileOutput:!1,filePath:"",consoleOutput:!0};return{settings:d,success:a("success"),info:a("info"),warn:a("warning"),warning:a("warning"),error:a("error")}}module.exports=Logger; diff --git a/bin/logger.js.map b/bin/logger.js.map deleted file mode 100644 index 519e79f..0000000 --- a/bin/logger.js.map +++ /dev/null @@ -1,66 +0,0 @@ -{ - "version": 3, - "file": "", - "lineCount": 4, - "mappings": "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", - "sources": [ - "./src/logger.js" - ], - "names": [ - "fs", - "chalk", - "months", - "levels", - "require", - "success", - "info", - "warning", - "error", - "pad", - "n", - "toString", - "timestamp", - "d", - "Date", - "time", - "getHours", - "getMinutes", - "getSeconds", - "join", - "getDate", - "getMonth", - "chalkPaint", - "sidewalkChalks", - "text", - "combinedChalk", - "i", - "hasOwnProperty", - "Logger", - "channel", - "createLogFunc", - "level", - "args", - "Array", - "prototype", - "slice", - "call", - "arguments", - "unshift", - "log", - "apply", - "undefined", - "shift", - "length", - "toUpperCase", - "settings", - "consoleOutput", - "console", - "fileOutput", - "appendFileSync", - "filePath", - "stripColor", - "warn", - "module", - "exports" - ] -} \ No newline at end of file diff --git a/bin/room.js b/bin/room.js deleted file mode 100644 index ee6f5b2..0000000 --- a/bin/room.js +++ /dev/null @@ -1,42 +0,0 @@ -//# sourceMappingURL=./room.js.map -require('source-map-support').install(); -/*The MIT License -=============== - -Copyright (c) 2014 Chris Vickery, Thomas "TAT" Andresen and other contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.*/ -var util=require("util"),songHistory=[],that=null,User=function(a){this.avatarID=a.avatarID?a.avatarID:"";this.badge=a.badge?a.badge:0;this.blurb=a.blurb?a.blurb:void 0;this.ep=a.ep?a.ep:void 0;this.gRole=null!==a.gRole?a.gRole:0;this.grab=!0===grabs[a.id];this.id=a.id?a.id:-1;this.ignores=a.ignores?a.ignores:void 0;this.joined=a.joined?a.joined:"";this.language=a.language?a.language:"";this.level=a.level?a.level:0;this.notifications=a.notifications?a.notifications:void 0;this.pVibes=a.pVibes?a.pVibes: -void 0;this.pw=a.pw?a.pw:void 0;this.role=a.role?a.role:0;this.slug=a.slug?a.slug:void 0;this.status=a.status?a.status:0;this.username=a.username?a.username:"";this.vote=void 0!==votes[a.id]?-1===votes[a.id]?-1:1:0;this.xp=a.xp?a.xp:0};User.prototype.toString=function(){return this.username}; -var cacheUsers={},booth={currentDJ:-1,isLocked:!1,shouldCycle:!0,waitingDJs:[]},fx=[],grabs={},meta={description:"",favorite:!1,hostID:-1,hostName:"",id:-1,name:"",population:0,slug:"",welcome:""},mutes={},playback={historyID:"",media:{author:"",cid:"",duration:-1,format:-1,id:-1,image:"",title:""},playlistID:-1,startTime:""},mySelf={},role=0,users=[],votes={};setInterval(function(){for(var a in mutes)mutes.hasOwnProperty(a)&&0a.role,c.canModBan=b.role>a.role));5===b.gRole?c.canModStaff=!0:5!==a.gRole&&(c.canModStaff=Math.max(b.role,b.gRole)>Math.max(a.role,a.gRole));c.canModMute=!(0songHistory.length?setImmediate(this.advance,a):(songHistory[0].room=this.getRoomScore(),this.setMedia(a.media,a.startTime),this.setDJs(a.djs),booth.currentDJ=a.currentDJ,playback.historyID=a.historyID,playback.playlistID=a.playlistID,a={id:a.historyID,media:a.media,room:{name:meta.name,slug:meta.slug},score:{positive:0,listeners:null,grabs:0,negative:0,skipped:0},timestamp:a.startTime,user:{id:a.currentDJ,username:null===this.getUser(a.currentDJ)?"":this.getUser(a.currentDJ).username}}, -50a?-1:a+1};Room.prototype.getAdmins=function(){var a=[],b;b=[mySelf].concat(users);for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];5==d.gRole&&a.push(d.id)}return this.usersToArray(a)};Room.prototype.getAmbassadors=function(){var a=[],b;b=[mySelf].concat(users);for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];5>d.gRole&&1this.getWaitListPosition(d)&&a.push(d)}return this.usersToArray(a)};Room.prototype.getStaff=function(){var a=[],b;b=[mySelf].concat(users);for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];0d&&a.negative++}c=grabs;for(b in c)c.hasOwnProperty(b)&&0