shaarkdevil

foda-se

Mar 1st, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *Copyright 2014 Yemasthui
  3.  *Modifications (including forks) of the code to fit personal needs are allowed only for personal use and should refer back to the original source.
  4.  *This software is not for profit, any extension, or unauthorised person providing this software is not authorised to be in a position of any monetary gain from this use of this software. Any and all money gained under the use of the software (which includes donations) must be passed on to the original author.
  5.  */
  6.  
  7.  
  8. (function () {
  9.  
  10.     API.getWaitListPosition = function(id){
  11.         if(typeof id === 'undefined' || id === null){
  12.             id = API.getUser().id;
  13.         }
  14.         var wl = API.getWaitList();
  15.         for(var i = 0; i < wl.length; i++){
  16.             if(wl[i].id === id){
  17.                 return i;
  18.             }
  19.         }
  20.         return -1;
  21.     };
  22.  
  23.     var kill = function () {
  24.         clearInterval(basicBot.room.autodisableInterval);
  25.         clearInterval(basicBot.room.afkInterval);
  26.         basicBot.status = false;
  27.     };
  28.  
  29.     var storeToStorage = function () {
  30.         localStorage.setItem("basicBotsettings", JSON.stringify(basicBot.settings));
  31.         localStorage.setItem("basicBotRoom", JSON.stringify(basicBot.room));
  32.         var basicBotStorageInfo = {
  33.             time: Date.now(),
  34.             stored: true,
  35.             version: basicBot.version
  36.         };
  37.         localStorage.setItem("basicBotStorageInfo", JSON.stringify(basicBotStorageInfo));
  38.  
  39.     };
  40.  
  41.     var subChat = function (chat, obj) {
  42.         if (typeof chat === "undefined") {
  43.             API.chatLog("There is a chat text missing.");
  44.             console.log("There is a chat text missing.");
  45.             return "[Error] No text message found.";
  46.         }
  47.         var lit = '%%';
  48.         for (var prop in obj) {
  49.             chat = chat.replace(lit + prop.toUpperCase() + lit, obj[prop]);
  50.         }
  51.         return chat;
  52.     };
  53.  
  54.     var loadChat = function (cb) {
  55.         if (!cb) cb = function () {
  56.         };
  57.         $.get("https://rawgit.com/Yemasthui/basicBot/master/lang/langIndex.json", function (json) {
  58.             var link = basicBot.chatLink;
  59.             if (json !== null && typeof json !== "undefined") {
  60.                 langIndex = json;
  61.                 link = langIndex[basicBot.settings.language.toLowerCase()];
  62.                 if (basicBot.settings.chatLink !== basicBot.chatLink) {
  63.                     link = basicBot.settings.chatLink;
  64.                 }
  65.                 else {
  66.                     if (typeof link === "undefined") {
  67.                         link = basicBot.chatLink;
  68.                     }
  69.                 }
  70.                 $.get(link, function (json) {
  71.                     if (json !== null && typeof json !== "undefined") {
  72.                         if (typeof json === "string") json = JSON.parse(json);
  73.                         basicBot.chat = json;
  74.                         cb();
  75.                     }
  76.                 });
  77.             }
  78.             else {
  79.                 $.get(basicBot.chatLink, function (json) {
  80.                     if (json !== null && typeof json !== "undefined") {
  81.                         if (typeof json === "string") json = JSON.parse(json);
  82.                         basicBot.chat = json;
  83.                         cb();
  84.                     }
  85.                 });
  86.             }
  87.         });
  88.     };
  89.  
  90.     var retrieveSettings = function () {
  91.         var settings = JSON.parse(localStorage.getItem("basicBotsettings"));
  92.         if (settings !== null) {
  93.             for (var prop in settings) {
  94.                 basicBot.settings[prop] = settings[prop];
  95.             }
  96.         }
  97.     };
  98.  
  99.     var retrieveFromStorage = function () {
  100.         var info = localStorage.getItem("basicBotStorageInfo");
  101.         if (info === null) API.chatLog(basicBot.chat.nodatafound);
  102.         else {
  103.             var settings = JSON.parse(localStorage.getItem("basicBotsettings"));
  104.             var room = JSON.parse(localStorage.getItem("basicBotRoom"));
  105.             var elapsed = Date.now() - JSON.parse(info).time;
  106.             if ((elapsed < 1 * 60 * 60 * 1000)) {
  107.                 API.chatLog(basicBot.chat.retrievingdata);
  108.                 for (var prop in settings) {
  109.                     basicBot.settings[prop] = settings[prop];
  110.                 }
  111.                 basicBot.room.users = room.users;
  112.                 basicBot.room.afkList = room.afkList;
  113.                 basicBot.room.historyList = room.historyList;
  114.                 basicBot.room.mutedUsers = room.mutedUsers;
  115.                 basicBot.room.autoskip = room.autoskip;
  116.                 basicBot.room.roomstats = room.roomstats;
  117.                 basicBot.room.messages = room.messages;
  118.                 basicBot.room.queue = room.queue;
  119.                 basicBot.room.newBlacklisted = room.newBlacklisted;
  120.                 API.chatLog(basicBot.chat.datarestored);
  121.             }
  122.         }
  123.         var json_sett = null;
  124.         var roominfo = document.getElementById("room-info");
  125.         info = roominfo.textContent;
  126.         var ref_bot = "@basicBot=";
  127.         var ind_ref = info.indexOf(ref_bot);
  128.         if (ind_ref > 0) {
  129.             var link = info.substring(ind_ref + ref_bot.length, info.length);
  130.             var ind_space = null;
  131.             if (link.indexOf(" ") < link.indexOf("\n")) ind_space = link.indexOf(" ");
  132.             else ind_space = link.indexOf("\n");
  133.             link = link.substring(0, ind_space);
  134.             $.get(link, function (json) {
  135.                 if (json !== null && typeof json !== "undefined") {
  136.                     json_sett = JSON.parse(json);
  137.                     for (var prop in json_sett) {
  138.                         basicBot.settings[prop] = json_sett[prop];
  139.                     }
  140.                 }
  141.             });
  142.         }
  143.  
  144.     };
  145.  
  146.     String.prototype.splitBetween = function (a, b) {
  147.         var self = this;
  148.         self = this.split(a);
  149.         for (var i = 0; i < self.length; i++) {
  150.             self[i] = self[i].split(b);
  151.         }
  152.         var arr = [];
  153.         for (var i = 0; i < self.length; i++) {
  154.             if (Array.isArray(self[i])) {
  155.                 for (var j = 0; j < self[i].length; j++) {
  156.                     arr.push(self[i][j]);
  157.                 }
  158.             }
  159.             else arr.push(self[i]);
  160.         }
  161.         return arr;
  162.     };
  163.  
  164.     var linkFixer = function (msg) {
  165.         var parts = msg.splitBetween('<a href="', '<\/a>');
  166.         for (var i = 1; i < parts.length; i = i + 2) {
  167.             var link = parts[i].split('"')[0];
  168.             parts[i] = link;
  169.         }
  170.         var m = '';
  171.         for (var i = 0; i < parts.length; i++) {
  172.             m += parts[i];
  173.         }
  174.         return m;
  175.     };
  176.  
  177.     var botCreator = "Matthew aka. Yemasthui";
  178.     var botCreatorIDs = [];
  179.  
  180.     var basicBot = {
  181.         version: "2.1.4",
  182.         status: false,
  183.         name: "BotCeifador",
  184.         loggedInID: null,
  185.         scriptLink: "https://rawgit.com/Yemasthui/basicBot/master/basicBot.js",
  186.         cmdLink: "http://git.io/245Ppg",
  187.         chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json",
  188.         chat: null,
  189.         loadChat: loadChat,
  190.         retrieveSettings: retrieveSettings,
  191.         retrieveFromStorage: retrieveFromStorage,
  192.         settings: {
  193.             botName: "BotCeifador",
  194.             language: "portuguese",
  195.             chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json",
  196.             maximumAfk: 120,
  197.             afkRemoval: true,
  198.             maximumDc: 60,
  199.             bouncerPlus: true,
  200.             lockdownEnabled: false,
  201.             lockGuard: false,
  202.             maximumLocktime: 10,
  203.             cycleGuard: true,
  204.             maximumCycletime: 10,
  205.             voteSkip: false,
  206.             voteSkipLimit: 10,
  207.             timeGuard: true,
  208.             maximumSongLength: 8,
  209.             autodisable: true,
  210.             commandCooldown: 30,
  211.             usercommandsEnabled: true,
  212.             lockskipPosition: 1,
  213.             lockskipReasons: [
  214.                 ["theme", "This song does not fit the room theme. "],
  215.                 ["op", "This song is on the OP list. "],
  216.                 ["history", "This song is in the history. "],
  217.                 ["mix", "You played a mix, which is against the rules. "],
  218.                 ["sound", "The song you played had bad sound quality or no sound. "],
  219.                 ["nsfw", "The song you contained was NSFW (image or sound). "],
  220.                 ["unavailable", "The song you played was not available for some users. "]
  221.             ],
  222.             afkpositionCheck: 15,
  223.             afkRankCheck: "ambassador",
  224.             motdEnabled: false,
  225.             motdInterval: 5,
  226.             motd: "Um belo dia pra vocĂȘ ir se foder",
  227.             filterChat: true,
  228.             etaRestriction: false,
  229.             welcome: true,
  230.             opLink: null,
  231.             rulesLink: null,
  232.             themeLink: null,
  233.             fbLink: null,
  234.             youtubeLink: null,
  235.             website: null,
  236.             intervalMessages: [],
  237.             messageInterval: 5,
  238.             songstats: true,
  239.             commandLiteral: "!",
  240.             blacklists: {
  241.                 NSFW: "https://rawgit.com/Yemasthui/basicBot-customization/master/blacklists/ExampleNSFWlist.json",
  242.                 OP: "https://rawgit.com/Yemasthui/basicBot-customization/master/blacklists/ExampleOPlist.json"
  243.             }
  244.         },
  245.         room: {
  246.             users: [],
  247.             afkList: [],
  248.             mutedUsers: [],
  249.             bannedUsers: [],
  250.             skippable: true,
  251.             usercommand: true,
  252.             allcommand: true,
  253.             afkInterval: null,
  254.             autoskip: null,
  255.             autoskipTimer: null,
  256.             autodisableInterval: null,
  257.             autodisableFunc: function () {
  258.                 if (basicBot.status && basicBot.settings.autodisable) {
  259.                     API.sendChat('!afkdisable');
  260.                     API.sendChat('!joindisable');
  261.                 }
  262.             },
  263.             queueing: 0,
  264.             queueable: true,
  265.             currentDJID: null,
  266.             historyList: [],
  267.             cycleTimer: setTimeout(function () {
  268.             }, 1),
  269.             roomstats: {
  270.                 accountName: null,
  271.                 totalWoots: 0,
  272.                 totalCurates: 0,
  273.                 totalMehs: 0,
  274.                 launchTime: null,
  275.                 songCount: 0,
  276.                 chatmessages: 0
  277.             },
  278.             messages: {
  279.                 from: [],
  280.                 to: [],
  281.                 message: []
  282.             },
  283.             queue: {
  284.                 id: [],
  285.                 position: []
  286.             },
  287.             blacklists: {
  288.  
  289.             },
  290.             newBlacklisted: [],
  291.             newBlacklistedSongFunction: null,
  292.             roulette: {
  293.                 rouletteStatus: false,
  294.                 participants: [],
  295.                 countdown: null,
  296.                 startRoulette: function () {
  297.                     basicBot.room.roulette.rouletteStatus = true;
  298.                     basicBot.room.roulette.countdown = setTimeout(function () {
  299.                         basicBot.room.roulette.endRoulette();
  300.                     }, 60 * 1000);
  301.                     API.sendChat(basicBot.chat.isopen);
  302.                 },
  303.                 endRoulette: function () {
  304.                     basicBot.room.roulette.rouletteStatus = false;
  305.                     var ind = Math.floor(Math.random() * basicBot.room.roulette.participants.length);
  306.                     var winner = basicBot.room.roulette.participants[ind];
  307.                     basicBot.room.roulette.participants = [];
  308.                     var pos = Math.floor((Math.random() * 1) + 1);
  309.                     var user = basicBot.userUtilities.lookupUser(winner);
  310.                     var name = user.username;
  311.                     API.sendChat(subChat(basicBot.chat.winnerpicked, {name: name, position: 1}));
  312.                     setTimeout(function (winner, pos) {
  313.                         basicBot.userUtilities.moveUser(winner, pos, false);
  314.                     }, 1 * 1000, winner, pos);
  315.                 }
  316.             }
  317.         },
  318.         User: function (id, name) {
  319.             this.id = id;
  320.             this.username = name;
  321.             this.jointime = Date.now();
  322.             this.lastActivity = Date.now();
  323.             this.votes = {
  324.                 woot: 0,
  325.                 meh: 0,
  326.                 curate: 0
  327.             };
  328.             this.lastEta = null;
  329.             this.afkWarningCount = 0;
  330.             this.afkCountdown = null;
  331.             this.inRoom = true;
  332.             this.isMuted = false;
  333.             this.lastDC = {
  334.                 time: null,
  335.                 position: null,
  336.                 songCount: 0
  337.             };
  338.             this.lastKnownPosition = null;
  339.         },
  340.         userUtilities: {
  341.             getJointime: function (user) {
  342.                 return user.jointime;
  343.             },
  344.             getUser: function (user) {
  345.                 return API.getUser(user.id);
  346.             },
  347.             updatePosition: function (user, newPos) {
  348.                 user.lastKnownPosition = newPos;
  349.             },
  350.             updateDC: function (user) {
  351.                 user.lastDC.time = Date.now();
  352.                 user.lastDC.position = user.lastKnownPosition;
  353.                 user.lastDC.songCount = basicBot.room.roomstats.songCount;
  354.             },
  355.             setLastActivity: function (user) {
  356.                 user.lastActivity = Date.now();
  357.                 user.afkWarningCount = 0;
  358.                 clearTimeout(user.afkCountdown);
  359.             },
  360.             getLastActivity: function (user) {
  361.                 return user.lastActivity;
  362.             },
  363.             getWarningCount: function (user) {
  364.                 return user.afkWarningCount;
  365.             },
  366.             setWarningCount: function (user, value) {
  367.                 user.afkWarningCount = value;
  368.             },
  369.             lookupUser: function (id) {
  370.                 for (var i = 0; i < basicBot.room.users.length; i++) {
  371.                     if (basicBot.room.users[i].id === id) {
  372.                         return basicBot.room.users[i];
  373.                     }
  374.                 }
  375.                 return false;
  376.             },
  377.             lookupUserName: function (name) {
  378.                 for (var i = 0; i < basicBot.room.users.length; i++) {
  379.                     var match = basicBot.room.users[i].username.trim() == name.trim();
  380.                     if (match) {
  381.                         return basicBot.room.users[i];
  382.                     }
  383.                 }
  384.                 return false;
  385.             },
  386.             voteRatio: function (id) {
  387.                 var user = basicBot.userUtilities.lookupUser(id);
  388.                 var votes = user.votes;
  389.                 if (votes.meh === 0) votes.ratio = 1;
  390.                 else votes.ratio = (votes.woot / votes.meh).toFixed(2);
  391.                 return votes;
  392.  
  393.             },
  394.             getPermission: function (obj) { //1 requests
  395.                 var u;
  396.                 if (typeof obj === "object") u = obj;
  397.                 else u = API.getUser(obj);
  398.                 if (botCreatorIDs.indexOf(u.id) > -1) return 10;
  399.                 if (u.gRole < 2) return u.role;
  400.                 else {
  401.                     switch (u.gRole) {
  402.                         case 2:
  403.                             return 7;
  404.                         case 3:
  405.                             return 8;
  406.                         case 4:
  407.                             return 9;
  408.                         case 5:
  409.                             return 10;
  410.                     }
  411.                 }
  412.                 return 0;
  413.             },
  414.             moveUser: function (id, pos, priority) {
  415.                 var user = basicBot.userUtilities.lookupUser(id);
  416.                 var wlist = API.getWaitList();
  417.                 if (API.getWaitListPosition(id) === -1) {
  418.                     if (wlist.length < 50) {
  419.                         API.moderateAddDJ(id);
  420.                         if (pos !== 0) setTimeout(function (id, pos) {
  421.                             API.moderateMoveDJ(id, pos);
  422.                         }, 1250, id, pos);
  423.                     }
  424.                     else {
  425.                         var alreadyQueued = -1;
  426.                         for (var i = 0; i < basicBot.room.queue.id.length; i++) {
  427.                             if (basicBot.room.queue.id[i] === id) alreadyQueued = i;
  428.                         }
  429.                         if (alreadyQueued !== -1) {
  430.                             basicBot.room.queue.position[alreadyQueued] = pos;
  431.                             return API.sendChat(subChat(basicBot.chat.alreadyadding, {position: basicBot.room.queue.position[alreadyQueued]}));
  432.                         }
  433.                         basicBot.roomUtilities.booth.lockBooth();
  434.                         if (priority) {
  435.                             basicBot.room.queue.id.unshift(id);
  436.                             basicBot.room.queue.position.unshift(pos);
  437.                         }
  438.                         else {
  439.                             basicBot.room.queue.id.push(id);
  440.                             basicBot.room.queue.position.push(pos);
  441.                         }
  442.                         var name = user.username;
  443.                         return API.sendChat(subChat(basicBot.chat.adding, {name: name, position: basicBot.room.queue.position.length}));
  444.                     }
  445.                 }
  446.                 else API.moderateMoveDJ(id, pos);
  447.             },
  448.             dclookup: function (id) {
  449.                 var user = basicBot.userUtilities.lookupUser(id);
  450.                 if (typeof user === 'boolean') return basicBot.chat.usernotfound;
  451.                 var name = user.username;
  452.                 if (user.lastDC.time === null) return subChat(basicBot.chat.notdisconnected, {name: name});
  453.                 var dc = user.lastDC.time;
  454.                 var pos = user.lastDC.position;
  455.                 if (pos === null) return basicBot.chat.noposition;
  456.                 var timeDc = Date.now() - dc;
  457.                 var validDC = false;
  458.                 if (basicBot.settings.maximumDc * 60 * 1000 > timeDc) {
  459.                     validDC = true;
  460.                 }
  461.                 var time = basicBot.roomUtilities.msToStr(timeDc);
  462.                 if (!validDC) return (subChat(basicBot.chat.toolongago, {name: basicBot.userUtilities.getUser(user).username, time: time}));
  463.                 var songsPassed = basicBot.room.roomstats.songCount - user.lastDC.songCount;
  464.                 var afksRemoved = 0;
  465.                 var afkList = basicBot.room.afkList;
  466.                 for (var i = 0; i < afkList.length; i++) {
  467.                     var timeAfk = afkList[i][1];
  468.                     var posAfk = afkList[i][2];
  469.                     if (dc < timeAfk && posAfk < pos) {
  470.                         afksRemoved++;
  471.                     }
  472.                 }
  473.                 var newPosition = user.lastDC.position - songsPassed - afksRemoved;
  474.                 if (newPosition <= 0) newPosition = 1;
  475.                 var msg = subChat(basicBot.chat.valid, {name: basicBot.userUtilities.getUser(user).username, time: time, position: newPosition});
  476.                 basicBot.userUtilities.moveUser(user.id, newPosition, true);
  477.                 return msg;
  478.             }
  479.         },
  480.  
  481.         roomUtilities: {
  482.             rankToNumber: function (rankString) {
  483.                 var rankInt = null;
  484.                 switch (rankString) {
  485.                     case "admin":
  486.                         rankInt = 10;
  487.                         break;
  488.                     case "ambassador":
  489.                         rankInt = 7;
  490.                         break;
  491.                     case "host":
  492.                         rankInt = 5;
  493.                         break;
  494.                     case "cohost":
  495.                         rankInt = 4;
  496.                         break;
  497.                     case "manager":
  498.                         rankInt = 3;
  499.                         break;
  500.                     case "bouncer":
  501.                         rankInt = 2;
  502.                         break;
  503.                     case "residentdj":
  504.                         rankInt = 1;
  505.                         break;
  506.                     case "user":
  507.                         rankInt = 0;
  508.                         break;
  509.                 }
  510.                 return rankInt;
  511.             },
  512.             msToStr: function (msTime) {
  513.                 var ms, msg, timeAway;
  514.                 msg = '';
  515.                 timeAway = {
  516.                     'days': 0,
  517.                     'hours': 0,
  518.                     'minutes': 0,
  519.                     'seconds': 0
  520.                 };
  521.                 ms = {
  522.                     'day': 24 * 60 * 60 * 1000,
  523.                     'hour': 60 * 60 * 1000,
  524.                     'minute': 60 * 1000,
  525.                     'second': 1000
  526.                 };
  527.                 if (msTime > ms.day) {
  528.                     timeAway.days = Math.floor(msTime / ms.day);
  529.                     msTime = msTime % ms.day;
  530.                 }
  531.                 if (msTime > ms.hour) {
  532.                     timeAway.hours = Math.floor(msTime / ms.hour);
  533.                     msTime = msTime % ms.hour;
  534.                 }
  535.                 if (msTime > ms.minute) {
  536.                     timeAway.minutes = Math.floor(msTime / ms.minute);
  537.                     msTime = msTime % ms.minute;
  538.                 }
  539.                 if (msTime > ms.second) {
  540.                     timeAway.seconds = Math.floor(msTime / ms.second);
  541.                 }
  542.                 if (timeAway.days !== 0) {
  543.                     msg += timeAway.days.toString() + 'd';
  544.                 }
  545.                 if (timeAway.hours !== 0) {
  546.                     msg += timeAway.hours.toString() + 'h';
  547.                 }
  548.                 if (timeAway.minutes !== 0) {
  549.                     msg += timeAway.minutes.toString() + 'm';
  550.                 }
  551.                 if (timeAway.minutes < 1 && timeAway.hours < 1 && timeAway.days < 1) {
  552.                     msg += timeAway.seconds.toString() + 's';
  553.                 }
  554.                 if (msg !== '') {
  555.                     return msg;
  556.                 } else {
  557.                     return false;
  558.                 }
  559.             },
  560.             booth: {
  561.                 lockTimer: setTimeout(function () {
  562.                 }, 1000),
  563.                 locked: false,
  564.                 lockBooth: function () {
  565.                     API.moderateLockWaitList(!basicBot.roomUtilities.booth.locked);
  566.                     basicBot.roomUtilities.booth.locked = false;
  567.                     if (basicBot.settings.lockGuard) {
  568.                         basicBot.roomUtilities.booth.lockTimer = setTimeout(function () {
  569.                             API.moderateLockWaitList(basicBot.roomUtilities.booth.locked);
  570.                         }, basicBot.settings.maximumLocktime * 60 * 1000);
  571.                     }
  572.                 },
  573.                 unlockBooth: function () {
  574.                     API.moderateLockWaitList(basicBot.roomUtilities.booth.locked);
  575.                     clearTimeout(basicBot.roomUtilities.booth.lockTimer);
  576.                 }
  577.             },
  578.             afkCheck: function () {
  579.                 if (!basicBot.status || !basicBot.settings.afkRemoval) return void (0);
  580.                 var rank = basicBot.roomUtilities.rankToNumber(basicBot.settings.afkRankCheck);
  581.                 var djlist = API.getWaitList();
  582.                 var lastPos = Math.min(djlist.length, basicBot.settings.afkpositionCheck);
  583.                 if (lastPos - 1 > djlist.length) return void (0);
  584.                 for (var i = 0; i < lastPos; i++) {
  585.                     if (typeof djlist[i] !== 'undefined') {
  586.                         var id = djlist[i].id;
  587.                         var user = basicBot.userUtilities.lookupUser(id);
  588.                         if (typeof user !== 'boolean') {
  589.                             var plugUser = basicBot.userUtilities.getUser(user);
  590.                             if (rank !== null && basicBot.userUtilities.getPermission(plugUser) <= rank) {
  591.                                 var name = plugUser.username;
  592.                                 var lastActive = basicBot.userUtilities.getLastActivity(user);
  593.                                 var inactivity = Date.now() - lastActive;
  594.                                 var time = basicBot.roomUtilities.msToStr(inactivity);
  595.                                 var warncount = user.afkWarningCount;
  596.                                 if (inactivity > basicBot.settings.maximumAfk * 60 * 1000) {
  597.                                     if (warncount === 0) {
  598.                                         API.sendChat(subChat(basicBot.chat.warning1, {name: name, time: time}));
  599.                                         user.afkWarningCount = 3;
  600.                                         user.afkCountdown = setTimeout(function (userToChange) {
  601.                                             userToChange.afkWarningCount = 1;
  602.                                         }, 90 * 1000, user);
  603.                                     }
  604.                                     else if (warncount === 1) {
  605.                                         API.sendChat(subChat(basicBot.chat.warning2, {name: name}));
  606.                                         user.afkWarningCount = 3;
  607.                                         user.afkCountdown = setTimeout(function (userToChange) {
  608.                                             userToChange.afkWarningCount = 2;
  609.                                         }, 30 * 1000, user);
  610.                                     }
  611.                                     else if (warncount === 2) {
  612.                                         var pos = API.getWaitListPosition(id);
  613.                                         if (pos !== -1) {
  614.                                             pos++;
  615.                                             basicBot.room.afkList.push([id, Date.now(), pos]);
  616.                                             user.lastDC = {
  617.  
  618.                                                 time: null,
  619.                                                 position: null,
  620.                                                 songCount: 0
  621.                                             };
  622.                                             API.moderateRemoveDJ(id);
  623.                                             API.sendChat(subChat(basicBot.chat.afkremove, {name: name, time: time, position: pos, maximumafk: basicBot.settings.maximumAfk}));
  624.                                         }
  625.                                         user.afkWarningCount = 0;
  626.                                     }
  627.                                 }
  628.                             }
  629.                         }
  630.                     }
  631.                 }
  632.             },
  633.             changeDJCycle: function () {
  634.                 var toggle = $(".cycle-toggle");
  635.                 if (toggle.hasClass("disabled")) {
  636.                     toggle.click();
  637.                     if (basicBot.settings.cycleGuard) {
  638.                         basicBot.room.cycleTimer = setTimeout(function () {
  639.                             if (toggle.hasClass("enabled")) toggle.click();
  640.                         }, basicBot.settings.cycleMaxTime * 60 * 1000);
  641.                     }
  642.                 }
  643.                 else {
  644.                     toggle.click();
  645.                     clearTimeout(basicBot.room.cycleTimer);
  646.                 }
  647.             },
  648.             intervalMessage: function () {
  649.                 var interval;
  650.                 if (basicBot.settings.motdEnabled) interval = basicBot.settings.motdInterval;
  651.                 else interval = basicBot.settings.messageInterval;
  652.                 if ((basicBot.room.roomstats.songCount % interval) === 0 && basicBot.status) {
  653.                     var msg;
  654.                     if (basicBot.settings.motdEnabled) {
  655.                         msg = basicBot.settings.motd;
  656.                     }
  657.                     else {
  658.                         if (basicBot.settings.intervalMessages.length === 0) return void (0);
  659.                         var messageNumber = basicBot.room.roomstats.songCount % basicBot.settings.intervalMessages.length;
  660.                         msg = basicBot.settings.intervalMessages[messageNumber];
  661.                     }
  662.                     API.sendChat('/me ' + msg);
  663.                 }
  664.             },
  665.             updateBlacklists: function () {
  666.                 for (var bl in basicBot.settings.blacklists) {
  667.                     basicBot.room.blacklists[bl] = [];
  668.                     if (typeof basicBot.settings.blacklists[bl] === 'function') {
  669.                         basicBot.room.blacklists[bl] = basicBot.settings.blacklists();
  670.                     }
  671.                     else if (typeof basicBot.settings.blacklists[bl] === 'string') {
  672.                         if (basicBot.settings.blacklists[bl] === '') {
  673.                             continue;
  674.                         }
  675.                         try {
  676.                             (function (l) {
  677.                                 $.get(basicBot.settings.blacklists[l], function (data) {
  678.                                     if (typeof data === 'string') {
  679.                                         data = JSON.parse(data);
  680.                                     }
  681.                                     var list = [];
  682.                                     for (var prop in data) {
  683.                                         if (typeof data[prop].mid !== 'undefined') {
  684.                                             list.push(data[prop].mid);
  685.                                         }
  686.                                     }
  687.                                     basicBot.room.blacklists[l] = list;
  688.                                 })
  689.                             })(bl);
  690.                         }
  691.                         catch (e) {
  692.                             API.chatLog('Error setting' + bl + 'blacklist.');
  693.                             console.log('Error setting' + bl + 'blacklist.');
  694.                             console.log(e);
  695.                         }
  696.                     }
  697.                 }
  698.             },
  699.             logNewBlacklistedSongs: function () {
  700.                 if (typeof console.table !== 'undefined') {
  701.                     console.table(basicBot.room.newBlacklisted);
  702.                 }
  703.                 else {
  704.                     console.log(basicBot.room.newBlacklisted);
  705.                 }
  706.             },
  707.             exportNewBlacklistedSongs: function () {
  708.                 var list = {};
  709.                 for (var i = 0; i < basicBot.room.newBlacklisted.length; i++) {
  710.                     var track = basicBot.room.newBlacklisted[i];
  711.                     list[track.list] = [];
  712.                     list[track.list].push({
  713.                         title: track.title,
  714.                         author: track.author,
  715.                         mid: track.mid
  716.                     });
  717.                 }
  718.                 return list;
  719.             }
  720.         },
  721.         eventChat: function (chat) {
  722.             chat.message = linkFixer(chat.message);
  723.             chat.message = chat.message.trim();
  724.             for (var i = 0; i < basicBot.room.users.length; i++) {
  725.                 if (basicBot.room.users[i].id === chat.uid) {
  726.                     basicBot.userUtilities.setLastActivity(basicBot.room.users[i]);
  727.                     if (basicBot.room.users[i].username !== chat.un) {
  728.                         basicBot.room.users[i].username = chat.un;
  729.                     }
  730.                 }
  731.             }
  732.             if (basicBot.chatUtilities.chatFilter(chat)) return void (0);
  733.             if (!basicBot.chatUtilities.commandCheck(chat))
  734.                 basicBot.chatUtilities.action(chat);
  735.         },
  736.         eventUserjoin: function (user) {
  737.             var known = false;
  738.             var index = null;
  739.             for (var i = 0; i < basicBot.room.users.length; i++) {
  740.                 if (basicBot.room.users[i].id === user.id) {
  741.                     known = true;
  742.                     index = i;
  743.                 }
  744.             }
  745.             var greet = true;
  746.             var welcomeback = null;
  747.             if (known) {
  748.                 basicBot.room.users[index].inRoom = true;
  749.                 var u = basicBot.userUtilities.lookupUser(user.id);
  750.                 var jt = u.jointime;
  751.                 var t = Date.now() - jt;
  752.                 if (t < 10 * 1000) greet = false;
  753.                 else welcomeback = true;
  754.             }
  755.             else {
  756.                 basicBot.room.users.push(new basicBot.User(user.id, user.username));
  757.                 welcomeback = false;
  758.             }
  759.             for (var j = 0; j < basicBot.room.users.length; j++) {
  760.                 if (basicBot.userUtilities.getUser(basicBot.room.users[j]).id === user.id) {
  761.                     basicBot.userUtilities.setLastActivity(basicBot.room.users[j]);
  762.                     basicBot.room.users[j].jointime = Date.now();
  763.                 }
  764.  
  765.             }
  766.             if (basicBot.settings.welcome && greet) {
  767.                 welcomeback ?
  768.                     setTimeout(function (user) {
  769.                         API.sendChat(subChat(basicBot.chat.welcomeback, {name: user.username}));
  770.                     }, 1 * 1000, user)
  771.                     :
  772.                     setTimeout(function (user) {
  773.                         API.sendChat(subChat(basicBot.chat.welcome, {name: user.username}));
  774.                     }, 1 * 1000, user);
  775.             }
  776.         },
  777.         eventUserleave: function (user) {
  778.             for (var i = 0; i < basicBot.room.users.length; i++) {
  779.                 if (basicBot.room.users[i].id === user.id) {
  780.                     basicBot.userUtilities.updateDC(basicBot.room.users[i]);
  781.                     basicBot.room.users[i].inRoom = false;
  782.                 }
  783.             }
  784.         },
  785.         eventVoteupdate: function (obj) {
  786.             for (var i = 0; i < basicBot.room.users.length; i++) {
  787.                 if (basicBot.room.users[i].id === obj.user.id) {
  788.                     if (obj.vote === 1) {
  789.                         basicBot.room.users[i].votes.woot++;
  790.                     }
  791.                     else {
  792.                         basicBot.room.users[i].votes.meh++;
  793.                     }
  794.                 }
  795.             }
  796.  
  797.             var mehs = API.getScore().negative;
  798.             var woots = API.getScore().positive;
  799.             var dj = API.getDJ();
  800.  
  801.             if (basicBot.settings.voteSkip) {
  802.                 if ((mehs - woots) >= (basicBot.settings.voteSkipLimit)) {
  803.                     API.sendChat(subChat(basicBot.chat.voteskipexceededlimit, {name: dj.username, limit: basicBot.settings.voteSkipLimit}));
  804.                     API.moderateForceSkip();
  805.                 }
  806.             }
  807.  
  808.         },
  809.         eventCurateupdate: function (obj) {
  810.             for (var i = 0; i < basicBot.room.users.length; i++) {
  811.                 if (basicBot.room.users[i].id === obj.user.id) {
  812.                     basicBot.room.users[i].votes.curate++;
  813.                 }
  814.             }
  815.         },
  816.         eventDjadvance: function (obj) {
  817.             var user = basicBot.userUtilities.lookupUser(obj.dj.id)
  818.             for(var i = 0; i < basicBot.room.users.length; i++){
  819.                 if(basicBot.room.users[i].id === user.id){
  820.                     basicBot.room.users[i].lastDC = {
  821.                         time: null,
  822.                         position: null,
  823.                         songCount: 0
  824.                     };
  825.                 }
  826.             }
  827.  
  828.             var lastplay = obj.lastPlay;
  829.             if (typeof lastplay === 'undefined') return;
  830.             if (basicBot.settings.songstats) {
  831.                 if (typeof basicBot.chat.songstatistics === "undefined") {
  832.                     API.sendChat("/me " + lastplay.media.author + " - " + lastplay.media.title + ": " + lastplay.score.positive + "W/" + lastplay.score.grabs + "G/" + lastplay.score.negative + "M.")
  833.                 }
  834.                 else {
  835.                     API.sendChat(subChat(basicBot.chat.songstatistics, {artist: lastplay.media.author, title: lastplay.media.title, woots: lastplay.score.positive, grabs: lastplay.score.grabs, mehs: lastplay.score.negative}))
  836.                 }
  837.             }
  838.             basicBot.room.roomstats.totalWoots += lastplay.score.positive;
  839.             basicBot.room.roomstats.totalMehs += lastplay.score.negative;
  840.             basicBot.room.roomstats.totalCurates += lastplay.score.grabs;
  841.             basicBot.room.roomstats.songCount++;
  842.             basicBot.roomUtilities.intervalMessage();
  843.             basicBot.room.currentDJID = obj.dj.id;
  844.  
  845.             var mid = obj.media.format + ':' + obj.media.cid;
  846.             for (var bl in basicBot.room.blacklists) {
  847.                 if (basicBot.room.blacklists[bl].indexOf(mid) > -1) {
  848.                     API.sendChat(subChat(basicBot.chat.isblacklisted, {blacklist: bl}));
  849.                     return API.moderateForceSkip();
  850.                 }
  851.             }
  852.  
  853.             var alreadyPlayed = false;
  854.             for (var i = 0; i < basicBot.room.historyList.length; i++) {
  855.                 if (basicBot.room.historyList[i][0] === obj.media.cid) {
  856.                     var firstPlayed = basicBot.room.historyList[i][1];
  857.                     var plays = basicBot.room.historyList[i].length - 1;
  858.                     var lastPlayed = basicBot.room.historyList[i][plays];
  859.                     API.sendChat(subChat(basicBot.chat.songknown, {plays: plays, timetotal: basicBot.roomUtilities.msToStr(Date.now() - firstPlayed), lasttime: basicBot.roomUtilities.msToStr(Date.now() - lastPlayed)}));
  860.                     basicBot.room.historyList[i].push(+new Date());
  861.                     alreadyPlayed = true;
  862.                 }
  863.             }
  864.             if (!alreadyPlayed) {
  865.                 basicBot.room.historyList.push([obj.media.cid, +new Date()]);
  866.             }
  867.             var newMedia = obj.media;
  868.             if (basicBot.settings.timeGuard && newMedia.duration > basicBot.settings.maximumSongLength * 60 && !basicBot.room.roomevent) {
  869.                 var name = obj.dj.username;
  870.                 API.sendChat(subChat(basicBot.chat.timelimit, {name: name, maxlength: basicBot.settings.maximumSongLength}));
  871.                 API.moderateForceSkip();
  872.             }
  873.             if (user.ownSong) {
  874.                 API.sendChat(subChat(basicBot.chat.permissionownsong, {name: user.username}));
  875.                 user.ownSong = false;
  876.             }
  877.             clearTimeout(basicBot.room.autoskipTimer);
  878.             if (basicBot.room.autoskip) {
  879.                 var remaining = obj.media.duration * 1000;
  880.                 basicBot.room.autoskipTimer = setTimeout(function () {
  881.                     console.log("Skipping track.");
  882.                     //API.sendChat('Song stuck, skipping...');
  883.                     API.moderateForceSkip();
  884.                 }, remaining + 3000);
  885.             }
  886.             storeToStorage();
  887.  
  888.         },
  889.         eventWaitlistupdate: function (users) {
  890.             if (users.length < 50) {
  891.                 if (basicBot.room.queue.id.length > 0 && basicBot.room.queueable) {
  892.                     basicBot.room.queueable = false;
  893.                     setTimeout(function () {
  894.                         basicBot.room.queueable = true;
  895.                     }, 500);
  896.                     basicBot.room.queueing++;
  897.                     var id, pos;
  898.                     setTimeout(
  899.                         function () {
  900.                             id = basicBot.room.queue.id.splice(0, 1)[0];
  901.                             pos = basicBot.room.queue.position.splice(0, 1)[0];
  902.                             API.moderateAddDJ(id, pos);
  903.                             setTimeout(
  904.                                 function (id, pos) {
  905.                                     API.moderateMoveDJ(id, pos);
  906.                                     basicBot.room.queueing--;
  907.                                     if (basicBot.room.queue.id.length === 0) setTimeout(function () {
  908.                                         basicBot.roomUtilities.booth.unlockBooth();
  909.                                     }, 1000);
  910.                                 }, 1000, id, pos);
  911.                         }, 1000 + basicBot.room.queueing * 2500);
  912.                 }
  913.             }
  914.             for (var i = 0; i < users.length; i++) {
  915.                 var user = basicBot.userUtilities.lookupUser(users[i].id);
  916.                 basicBot.userUtilities.updatePosition(user, API.getWaitListPosition(users[i].id) + 1);
  917.             }
  918.         },
  919.         chatcleaner: function (chat) {
  920.             if (!basicBot.settings.filterChat) return false;
  921.             if (basicBot.userUtilities.getPermission(chat.uid) > 1) return false;
  922.             var msg = chat.message;
  923.             var containsLetters = false;
  924.             for (var i = 0; i < msg.length; i++) {
  925.                 ch = msg.charAt(i);
  926.                 if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch === ':' || ch === '^') containsLetters = true;
  927.             }
  928.             if (msg === '') {
  929.                 return true;
  930.             }
  931.             if (!containsLetters && (msg.length === 1 || msg.length > 3)) return true;
  932.             msg = msg.replace(/[ ,;.:\/=~+%^*\-\\"'&@#]/g, '');
  933.             var capitals = 0;
  934.             var ch;
  935.             for (var i = 0; i < msg.length; i++) {
  936.                 ch = msg.charAt(i);
  937.                 if (ch >= 'A' && ch <= 'Z') capitals++;
  938.             }
  939.             if (capitals >= 40) {
  940.                 API.sendChat(subChat(basicBot.chat.caps, {name: chat.un}));
  941.                 return true;
  942.             }
  943.             msg = msg.toLowerCase();
  944.             if (msg === 'skip') {
  945.                 API.sendChat(subChat(basicBot.chat.askskip, {name: chat.un}));
  946.                 return true;
  947.             }
  948.             for (var j = 0; j < basicBot.chatUtilities.spam.length; j++) {
  949.                 if (msg === basicBot.chatUtilities.spam[j]) {
  950.                     API.sendChat(subChat(basicBot.chat.spam, {name: chat.un}));
  951.                     return true;
  952.                 }
  953.             }
  954.             return false;
  955.         },
  956.         chatUtilities: {
  957.             chatFilter: function (chat) {
  958.                 var msg = chat.message;
  959.                 var perm = basicBot.userUtilities.getPermission(chat.uid);
  960.                 var user = basicBot.userUtilities.lookupUser(chat.uid);
  961.                 var isMuted = false;
  962.                 for (var i = 0; i < basicBot.room.mutedUsers.length; i++) {
  963.                     if (basicBot.room.mutedUsers[i] === chat.uid) isMuted = true;
  964.                 }
  965.                 if (isMuted) {
  966.                     API.moderateDeleteChat(chat.cid);
  967.                     return true;
  968.                 }
  969.                 if (basicBot.settings.lockdownEnabled) {
  970.                     if (perm === 0) {
  971.                         API.moderateDeleteChat(chat.cid);
  972.                         return true;
  973.                     }
  974.                 }
  975.                 if (basicBot.chatcleaner(chat)) {
  976.                     API.moderateDeleteChat(chat.cid);
  977.                     return true;
  978.                 }
  979.                 /**
  980.                  var plugRoomLinkPatt = /(\bhttps?:\/\/(www.)?plug\.dj[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  981.                  if (plugRoomLinkPatt.exec(msg)) {
  982.                     if (perm === 0) {
  983.                         API.sendChat(subChat(basicBot.chat.roomadvertising, {name: chat.un}));
  984.                         API.moderateDeleteChat(chat.cid);
  985.                         return true;
  986.                     }
  987.                 }
  988.                  **/
  989.                 if (msg.indexOf('http://adf.ly/') > -1) {
  990.                     API.moderateDeleteChat(chat.cid);
  991.                     API.sendChat(subChat(basicBot.chat.adfly, {name: chat.un}));
  992.                     return true;
  993.                 }
  994.                 if (msg.indexOf('autojoin was not enabled') > 0 || msg.indexOf('AFK message was not enabled') > 0 || msg.indexOf('!afkdisable') > 0 || msg.indexOf('!joindisable') > 0 || msg.indexOf('autojoin disabled') > 0 || msg.indexOf('AFK message disabled') > 0) {
  995.                     API.moderateDeleteChat(chat.cid);
  996.                     return true;
  997.                 }
  998.  
  999.                 var rlJoinChat = basicBot.chat.roulettejoin;
  1000.                 var rlLeaveChat = basicBot.chat.rouletteleave;
  1001.  
  1002.                 var joinedroulette = rlJoinChat.split('%%NAME%%');
  1003.                 if (joinedroulette[1].length > joinedroulette[0].length) joinedroulette = joinedroulette[1];
  1004.                 else joinedroulette = joinedroulette[0];
  1005.  
  1006.                 var leftroulette = rlLeaveChat.split('%%NAME%%');
  1007.                 if (leftroulette[1].length > leftroulette[0].length) leftroulette = leftroulette[1];
  1008.                 else leftroulette = leftroulette[0];
  1009.  
  1010.                 if ((msg.indexOf(joinedroulette) > -1 || msg.indexOf(leftroulette) > -1) && chat.uid === basicBot.loggedInID) {
  1011.                     setTimeout(function (id) {
  1012.                         API.moderateDeleteChat(id);
  1013.                     }, 2 * 1000, chat.cid);
  1014.                     return true;
  1015.                 }
  1016.                 return false;
  1017.             },
  1018.             commandCheck: function (chat) {
  1019.                 var cmd;
  1020.                 if (chat.message.charAt(0) === '!') {
  1021.                     var space = chat.message.indexOf(' ');
  1022.                     if (space === -1) {
  1023.                         cmd = chat.message;
  1024.                     }
  1025.                     else cmd = chat.message.substring(0, space);
  1026.                 }
  1027.                 else return false;
  1028.                 var userPerm = basicBot.userUtilities.getPermission(chat.uid);
  1029.                 //console.log("name: " + chat.un + ", perm: " + userPerm);
  1030.                 if (chat.message !== "!join" && chat.message !== "!leave") {
  1031.                     if (userPerm === 0 && !basicBot.room.usercommand) return void (0);
  1032.                     if (!basicBot.room.allcommand) return void (0);
  1033.                 }
  1034.                 if (chat.message === '!eta' && basicBot.settings.etaRestriction) {
  1035.                     if (userPerm < 2) {
  1036.                         var u = basicBot.userUtilities.lookupUser(chat.uid);
  1037.                         if (u.lastEta !== null && (Date.now() - u.lastEta) < 1 * 60 * 60 * 1000) {
  1038.                             API.moderateDeleteChat(chat.cid);
  1039.                             return void (0);
  1040.                         }
  1041.                         else u.lastEta = Date.now();
  1042.                     }
  1043.                 }
  1044.                 var executed = false;
  1045.  
  1046.                 for (var comm in basicBot.commands) {
  1047.                     var cmdCall = basicBot.commands[comm].command;
  1048.                     if (!Array.isArray(cmdCall)) {
  1049.                         cmdCall = [cmdCall]
  1050.                     }
  1051.                     for (var i = 0; i < cmdCall.length; i++) {
  1052.                         if (basicBot.settings.commandLiteral + cmdCall[i] === cmd) {
  1053.                             basicBot.commands[comm].functionality(chat, basicBot.settings.commandLiteral + cmdCall[i]);
  1054.                             executed = true;
  1055.                             break;
  1056.                         }
  1057.                     }
  1058.                 }
  1059.  
  1060.                 if (executed && userPerm === 0) {
  1061.                     basicBot.room.usercommand = false;
  1062.                     setTimeout(function () {
  1063.                         basicBot.room.usercommand = true;
  1064.                     }, basicBot.settings.commandCooldown * 1000);
  1065.                 }
  1066.                 if (executed) {
  1067.                     API.moderateDeleteChat(chat.cid);
  1068.                     basicBot.room.allcommand = false;
  1069.                     setTimeout(function () {
  1070.                         basicBot.room.allcommand = true;
  1071.                     }, 5 * 1000);
  1072.                 }
  1073.                 return executed;
  1074.             },
  1075.             action: function (chat) {
  1076.                 var user = basicBot.userUtilities.lookupUser(chat.uid);
  1077.                 if (chat.type === 'message') {
  1078.                     for (var j = 0; j < basicBot.room.users.length; j++) {
  1079.                         if (basicBot.userUtilities.getUser(basicBot.room.users[j]).id === chat.uid) {
  1080.                             basicBot.userUtilities.setLastActivity(basicBot.room.users[j]);
  1081.                         }
  1082.  
  1083.                     }
  1084.                 }
  1085.                 basicBot.room.roomstats.chatmessages++;
  1086.             },
  1087.             spam: [
  1088.                 'hueh', 'brbr', 'heu', 'brbr', 'kkkkkkk', 'spoder', 'mafia', 'zuera', 'zueira', 'euheuhehueheueheueh',  
  1089.                 'zueria', 'aehoo', 'aheu', 'algum', 'brazil', 'zoeira', 'fuckadmins', 'affff', 'vaisefoder', 'huenaarea',
  1090.                 'hitler', 'ashua', 'ahsu', 'ashau', 'lulz', 'huehue', 'hue', 'huehuehue', 'merda', 'pqp', 'puta', 'mulher', 'pula', 'retarda', 'caralho', 'filha', 'ppk', 'fuder', 'foder', 'hua', 'ahue', 'modafuka', 'modafoka', 'mudafuka', 'mudafoka', 'ooooooooooooooo', 'holeshit'
  1091.             ],
  1092.             curses: [
  1093.                 'nigger', 'faggot', 'nigga', 'niqqa', '***', 'modafocka'
  1094.             ]
  1095.         },
  1096.         connectAPI: function () {
  1097.             this.proxy = {
  1098.                 eventChat: $.proxy(this.eventChat, this),
  1099.                 eventUserskip: $.proxy(this.eventUserskip, this),
  1100.                 eventUserjoin: $.proxy(this.eventUserjoin, this),
  1101.                 eventUserleave: $.proxy(this.eventUserleave, this),
  1102.                 eventUserfan: $.proxy(this.eventUserfan, this),
  1103.                 eventFriendjoin: $.proxy(this.eventFriendjoin, this),
  1104.                 eventFanjoin: $.proxy(this.eventFanjoin, this),
  1105.                 eventVoteupdate: $.proxy(this.eventVoteupdate, this),
  1106.                 eventCurateupdate: $.proxy(this.eventCurateupdate, this),
  1107.                 eventRoomscoreupdate: $.proxy(this.eventRoomscoreupdate, this),
  1108.                 eventDjadvance: $.proxy(this.eventDjadvance, this),
  1109.                 eventDjupdate: $.proxy(this.eventDjupdate, this),
  1110.                 eventWaitlistupdate: $.proxy(this.eventWaitlistupdate, this),
  1111.                 eventVoteskip: $.proxy(this.eventVoteskip, this),
  1112.                 eventModskip: $.proxy(this.eventModskip, this),
  1113.                 eventChatcommand: $.proxy(this.eventChatcommand, this),
  1114.                 eventHistoryupdate: $.proxy(this.eventHistoryupdate, this)
  1115.  
  1116.             };
  1117.             API.on(API.CHAT, this.proxy.eventChat);
  1118.             API.on(API.USER_SKIP, this.proxy.eventUserskip);
  1119.             API.on(API.USER_JOIN, this.proxy.eventUserjoin);
  1120.             API.on(API.USER_LEAVE, this.proxy.eventUserleave);
  1121.             API.on(API.USER_FAN, this.proxy.eventUserfan);
  1122.             API.on(API.VOTE_UPDATE, this.proxy.eventVoteupdate);
  1123.             API.on(API.GRAB_UPDATE, this.proxy.eventCurateupdate);
  1124.             API.on(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate);
  1125.             API.on(API.ADVANCE, this.proxy.eventDjadvance);
  1126.             API.on(API.WAIT_LIST_UPDATE, this.proxy.eventWaitlistupdate);
  1127.             API.on(API.MOD_SKIP, this.proxy.eventModskip);
  1128.             API.on(API.CHAT_COMMAND, this.proxy.eventChatcommand);
  1129.             API.on(API.HISTORY_UPDATE, this.proxy.eventHistoryupdate);
  1130.         },
  1131.         disconnectAPI: function () {
  1132.             API.off(API.CHAT, this.proxy.eventChat);
  1133.             API.off(API.USER_SKIP, this.proxy.eventUserskip);
  1134.             API.off(API.USER_JOIN, this.proxy.eventUserjoin);
  1135.             API.off(API.USER_LEAVE, this.proxy.eventUserleave);
  1136.             API.off(API.USER_FAN, this.proxy.eventUserfan);
  1137.             API.off(API.VOTE_UPDATE, this.proxy.eventVoteupdate);
  1138.             API.off(API.CURATE_UPDATE, this.proxy.eventCurateupdate);
  1139.             API.off(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate);
  1140.             API.off(API.ADVANCE, this.proxy.eventDjadvance);
  1141.             API.off(API.WAIT_LIST_UPDATE, this.proxy.eventWaitlistupdate);
  1142.             API.off(API.MOD_SKIP, this.proxy.eventModskip);
  1143.             API.off(API.CHAT_COMMAND, this.proxy.eventChatcommand);
  1144.             API.off(API.HISTORY_UPDATE, this.proxy.eventHistoryupdate);
  1145.         },
  1146.         startup: function () {
  1147.             Function.prototype.toString = function () {
  1148.                 return 'Function.'
  1149.             };
  1150.             var u = API.getUser();
  1151.             if (basicBot.userUtilities.getPermission(u) < 2) return API.chatLog(basicBot.chat.greyuser);
  1152.             if (basicBot.userUtilities.getPermission(u) === 2) API.chatLog(basicBot.chat.bouncer);
  1153.             basicBot.connectAPI();
  1154.             API.moderateDeleteChat = function (cid) {
  1155.                 $.ajax({
  1156.                     url: "https://plug.dj/_/chat/" + cid,
  1157.                     type: "DELETE"
  1158.                 })
  1159.             };
  1160.             retrieveSettings();
  1161.             retrieveFromStorage();
  1162.             window.bot = basicBot;
  1163.             basicBot.roomUtilities.updateBlacklists();
  1164.             setInterval(basicBot.roomUtilities.updateBlacklists, 60 * 60 * 1000);
  1165.             basicBot.getNewBlacklistedSongs = basicBot.roomUtilities.exportNewBlacklistedSongs;
  1166.             basicBot.logNewBlacklistedSongs = basicBot.roomUtilities.logNewBlacklistedSongs;
  1167.             if (basicBot.room.roomstats.launchTime === null) {
  1168.                 basicBot.room.roomstats.launchTime = Date.now();
  1169.             }
  1170.  
  1171.             for (var j = 0; j < basicBot.room.users.length; j++) {
  1172.                 basicBot.room.users[j].inRoom = false;
  1173.             }
  1174.             var userlist = API.getUsers();
  1175.             for (var i = 0; i < userlist.length; i++) {
  1176.                 var known = false;
  1177.                 var ind = null;
  1178.                 for (var j = 0; j < basicBot.room.users.length; j++) {
  1179.                     if (basicBot.room.users[j].id === userlist[i].id) {
  1180.                         known = true;
  1181.                         ind = j;
  1182.                     }
  1183.                 }
  1184.                 if (known) {
  1185.                     basicBot.room.users[ind].inRoom = true;
  1186.                 }
  1187.                 else {
  1188.                     basicBot.room.users.push(new basicBot.User(userlist[i].id, userlist[i].username));
  1189.                     ind = basicBot.room.users.length - 1;
  1190.                 }
  1191.                 var wlIndex = API.getWaitListPosition(basicBot.room.users[ind].id) + 1;
  1192.                 basicBot.userUtilities.updatePosition(basicBot.room.users[ind], wlIndex);
  1193.             }
  1194.             basicBot.room.afkInterval = setInterval(function () {
  1195.                 basicBot.roomUtilities.afkCheck()
  1196.             }, 10 * 1000);
  1197.             basicBot.room.autodisableInterval = setInterval(function () {
  1198.                 basicBot.room.autodisableFunc();
  1199.             }, 60 * 60 * 1000);
  1200.             basicBot.loggedInID = API.getUser().id;
  1201.             basicBot.status = true;
  1202.             API.sendChat('/cap 1');
  1203.             API.setVolume(0);
  1204.             var emojibutton = $(".icon-emoji-on");
  1205.             if (emojibutton.length > 0) {
  1206.                 emojibutton[0].click();
  1207.             }
  1208.             loadChat(API.sendChat(subChat(basicBot.chat.online, {botname: basicBot.settings.botName, version: basicBot.version})));
  1209.         },
  1210.         commands: {
  1211.             executable: function (minRank, chat) {
  1212.                 var id = chat.uid;
  1213.                 var perm = basicBot.userUtilities.getPermission(id);
  1214.                 var minPerm;
  1215.                 switch (minRank) {
  1216.                     case 'admin':
  1217.                         minPerm = 10;
  1218.                         break;
  1219.                     case 'ambassador':
  1220.                         minPerm = 7;
  1221.                         break;
  1222.                     case 'host':
  1223.                         minPerm = 5;
  1224.                         break;
  1225.                     case 'cohost':
  1226.                         minPerm = 4;
  1227.                         break;
  1228.                     case 'manager':
  1229.                         minPerm = 3;
  1230.                         break;
  1231.                     case 'mod':
  1232.                         if (basicBot.settings.bouncerPlus) {
  1233.                             minPerm = 2;
  1234.                         }
  1235.                         else {
  1236.                             minPerm = 3;
  1237.                         }
  1238.                         break;
  1239.                     case 'bouncer':
  1240.                         minPerm = 2;
  1241.                         break;
  1242.                     case 'residentdj':
  1243.                         minPerm = 1;
  1244.                         break;
  1245.                     case 'user':
  1246.                         minPerm = 0;
  1247.                         break;
  1248.                     default:
  1249.                         API.chatLog('error assigning minimum permission');
  1250.                 }
  1251.                 return perm >= minPerm;
  1252.  
  1253.             },
  1254.             /**
  1255.              command: {
  1256.                         command: 'cmd',
  1257.                         rank: 'user/bouncer/mod/manager',
  1258.                         type: 'startsWith/exact',
  1259.                         functionality: function(chat, cmd){
  1260.                                 if(this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1261.                                 if( !basicBot.commands.executable(this.rank, chat) ) return void (0);
  1262.                                 else{
  1263.                                
  1264.                                 }
  1265.                         }
  1266.                 },
  1267.              **/
  1268.  
  1269.             activeCommand: {
  1270.                 command: 'active',
  1271.                 rank: 'bouncer',
  1272.                 type: 'startsWith',
  1273.                 functionality: function (chat, cmd) {
  1274.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1275.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1276.                     else {
  1277.                         var msg = chat.message;
  1278.                         var now = Date.now();
  1279.                         var chatters = 0;
  1280.                         var time;
  1281.                         if (msg.length === cmd.length) time = 60;
  1282.                         else {
  1283.                             time = msg.substring(cmd.length + 1);
  1284.                             if (isNaN(time)) return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  1285.                         }
  1286.                         for (var i = 0; i < basicBot.room.users.length; i++) {
  1287.                             userTime = basicBot.userUtilities.getLastActivity(basicBot.room.users[i]);
  1288.                             if ((now - userTime) <= (time * 60 * 1000)) {
  1289.                                 chatters++;
  1290.                             }
  1291.                         }
  1292.                         API.sendChat(subChat(basicBot.chat.activeusersintime, {name: chat.un, amount: chatters, time: time}));
  1293.                     }
  1294.                 }
  1295.             },
  1296.  
  1297.             addCommand: {
  1298.                 command: 'add',
  1299.                 rank: 'mod',
  1300.                 type: 'startsWith',
  1301.                 functionality: function (chat, cmd) {
  1302.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1303.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1304.                     else {
  1305.                         var msg = chat.message;
  1306.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1307.                         var name = msg.substr(cmd.length + 2);
  1308.                         var user = basicBot.userUtilities.lookupUserName(name);
  1309.                         if (msg.length > cmd.length + 2) {
  1310.                             if (typeof user !== 'undefined') {
  1311.                                 if (basicBot.room.roomevent) {
  1312.                                     basicBot.room.eventArtists.push(user.id);
  1313.                                 }
  1314.                                 API.moderateAddDJ(user.id);
  1315.                             } else API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1316.                         }
  1317.                     }
  1318.                 }
  1319.             },
  1320.  
  1321.             afklimitCommand: {
  1322.                 command: 'afklimit',
  1323.                 rank: 'manager',
  1324.                 type: 'startsWith',
  1325.                 functionality: function (chat, cmd) {
  1326.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1327.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1328.                     else {
  1329.                         var msg = chat.message;
  1330.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nolimitspecified, {name: chat.un}));
  1331.                         var limit = msg.substring(cmd.length + 1);
  1332.                         if (!isNaN(limit)) {
  1333.                             basicBot.settings.maximumAfk = parseInt(limit, 10);
  1334.                             API.sendChat(subChat(basicBot.chat.maximumafktimeset, {name: chat.un, time: basicBot.settings.maximumAfk}));
  1335.                         }
  1336.                         else API.sendChat(subChat(basicBot.chat.invalidlimitspecified, {name: chat.un}));
  1337.                     }
  1338.                 }
  1339.             },
  1340.  
  1341.             afkremovalCommand: {
  1342.                 command: 'afkremoval',
  1343.                 rank: 'mod',
  1344.                 type: 'exact',
  1345.                 functionality: function (chat, cmd) {
  1346.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1347.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1348.                     else {
  1349.                         if (basicBot.settings.afkRemoval) {
  1350.                             basicBot.settings.afkRemoval = !basicBot.settings.afkRemoval;
  1351.                             clearInterval(basicBot.room.afkInterval);
  1352.                             API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.afkremoval}));
  1353.                         }
  1354.                         else {
  1355.                             basicBot.settings.afkRemoval = !basicBot.settings.afkRemoval;
  1356.                             basicBot.room.afkInterval = setInterval(function () {
  1357.                                 basicBot.roomUtilities.afkCheck()
  1358.                             }, 2 * 1000);
  1359.                             API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.afkremoval}));
  1360.                         }
  1361.                     }
  1362.                 }
  1363.             },
  1364.  
  1365.             afkresetCommand: {
  1366.                 command: 'afkreset',
  1367.                 rank: 'bouncer',
  1368.                 type: 'startsWith',
  1369.                 functionality: function (chat, cmd) {
  1370.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1371.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1372.                     else {
  1373.                         var msg = chat.message;
  1374.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1375.                         var name = msg.substring(cmd.length + 2);
  1376.                         var user = basicBot.userUtilities.lookupUserName(name);
  1377.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1378.                         basicBot.userUtilities.setLastActivity(user);
  1379.                         API.sendChat(subChat(basicBot.chat.afkstatusreset, {name: chat.un, username: name}));
  1380.                     }
  1381.                 }
  1382.             },
  1383.  
  1384.             afktimeCommand: {
  1385.                 command: 'afktime',
  1386.                 rank: 'bouncer',
  1387.                 type: 'startsWith',
  1388.                 functionality: function (chat, cmd) {
  1389.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1390.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1391.                     else {
  1392.                         var msg = chat.message;
  1393.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1394.                         var name = msg.substring(cmd.length + 2);
  1395.                         var user = basicBot.userUtilities.lookupUserName(name);
  1396.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1397.                         var lastActive = basicBot.userUtilities.getLastActivity(user);
  1398.                         var inactivity = Date.now() - lastActive;
  1399.                         var time = basicBot.roomUtilities.msToStr(inactivity);
  1400.                         API.sendChat(subChat(basicBot.chat.inactivefor, {name: chat.un, username: name, time: time}));
  1401.                     }
  1402.                 }
  1403.             },
  1404.  
  1405.             autoskipCommand: {
  1406.                 command: 'autoskip',
  1407.                 rank: 'mod',
  1408.                 type: 'exact',
  1409.                 functionality: function (chat, cmd) {
  1410.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1411.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1412.                     else {
  1413.                         if (basicBot.room.autoskip) {
  1414.                             basicBot.room.autoskip = !basicBot.room.autoskip;
  1415.                             clearTimeout(basicBot.room.autoskipTimer);
  1416.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.autoskip}));
  1417.                         }
  1418.                         else {
  1419.                             basicBot.room.autoskip = !basicBot.room.autoskip;
  1420.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.autoskip}));
  1421.                         }
  1422.                     }
  1423.                 }
  1424.             },
  1425.  
  1426.             autowootCommand: {
  1427.                 command: 'autowoot',
  1428.                 rank: 'user',
  1429.                 type: 'exact',
  1430.                 functionality: function (chat, cmd) {
  1431.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1432.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1433.                     else {
  1434.                         API.sendChat(basicBot.chat.autowoot);
  1435.                     }
  1436.                 }
  1437.             },
  1438.  
  1439.             baCommand: {
  1440.                 command: 'ba',
  1441.                 rank: 'user',
  1442.                 type: 'exact',
  1443.                 functionality: function (chat, cmd) {
  1444.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1445.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1446.                     else {
  1447.                         API.sendChat(basicBot.chat.brandambassador);
  1448.                     }
  1449.                 }
  1450.             },
  1451.  
  1452.             banCommand: {
  1453.                 command: 'ban',
  1454.                 rank: 'bouncer',
  1455.                 type: 'startsWith',
  1456.                 functionality: function (chat, cmd) {
  1457.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1458.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1459.                     else {
  1460.                         var msg = chat.message;
  1461.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1462.                         var name = msg.substr(cmd.length + 2);
  1463.                         var user = basicBot.userUtilities.lookupUserName(name);
  1464.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1465.                         API.moderateBanUser(user.id, 1, API.BAN.DAY);
  1466.                     }
  1467.                 }
  1468.             },
  1469.  
  1470.             blacklistCommand: {
  1471.                 command: ['blacklist', 'bl'],
  1472.                 rank: 'bouncer',
  1473.                 type: 'startsWith',
  1474.                 functionality: function (chat, cmd) {
  1475.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1476.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1477.                     else {
  1478.                         var msg = chat.message;
  1479.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nolistspecified, {name: chat.un}));
  1480.                         var list = msg.substr(cmd.length + 1);
  1481.                         if (typeof basicBot.room.blacklists[list] === 'undefined') return API.sendChat(subChat(basicBot.chat.invalidlistspecified, {name: chat.un}));
  1482.                         else {
  1483.                             var media = API.getMedia();
  1484.                             var track = {
  1485.                                 list: list,
  1486.                                 author: media.author,
  1487.                                 title: media.title,
  1488.                                 mid: media.format + ':' + media.cid
  1489.                             };
  1490.                             basicBot.room.newBlacklisted.push(track);
  1491.                             basicBot.room.blacklists[list].push(media.format + ':' + media.cid);
  1492.                             API.sendChat(subChat(basicBot.chat.newblacklisted, {name: chat.un, blacklist: list, author: media.author, title: media.title, mid: media.format + ':' + media.cid}));
  1493.                             API.moderateForceSkip();
  1494.                             if (typeof basicBot.room.newBlacklistedSongFunction === 'function') {
  1495.                                 basicBot.room.newBlacklistedSongFunction(track);
  1496.                             }
  1497.                         }
  1498.                     }
  1499.                 }
  1500.             },
  1501.  
  1502.             bouncerPlusCommand: {
  1503.                 command: 'bouncer+',
  1504.                 rank: 'mod',
  1505.                 type: 'exact',
  1506.                 functionality: function (chat, cmd) {
  1507.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1508.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1509.                     else {
  1510.                         var msg = chat.message;
  1511.                         if (basicBot.settings.bouncerPlus) {
  1512.                             basicBot.settings.bouncerPlus = false;
  1513.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': 'Bouncer+'}));
  1514.                         }
  1515.                         else {
  1516.                             if (!basicBot.settings.bouncerPlus) {
  1517.                                 var id = chat.uid;
  1518.                                 var perm = basicBot.userUtilities.getPermission(id);
  1519.                                 if (perm > 2) {
  1520.                                     basicBot.settings.bouncerPlus = true;
  1521.                                     return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': 'Bouncer+'}));
  1522.                                 }
  1523.                             }
  1524.                             else return API.sendChat(subChat(basicBot.chat.bouncerplusrank, {name: chat.un}));
  1525.                         }
  1526.                     }
  1527.                 }
  1528.             },
  1529.  
  1530.             clearchatCommand: {
  1531.                 command: 'clearchat',
  1532.                 rank: 'manager',
  1533.                 type: 'exact',
  1534.                 functionality: function (chat, cmd) {
  1535.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1536.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1537.                     else {
  1538.                         var currentchat = $('#chat-messages').children();
  1539.                         for (var i = 0; i < currentchat.length; i++) {
  1540.                             API.moderateDeleteChat(currentchat[i].getAttribute("data-cid"));
  1541.                         }
  1542.                         return API.sendChat(subChat(basicBot.chat.chatcleared, {name: chat.un}));
  1543.                     }
  1544.                 }
  1545.             },
  1546.  
  1547.             commandsCommand: {
  1548.                 command: 'commands',
  1549.                 rank: 'user',
  1550.                 type: 'exact',
  1551.                 functionality: function (chat, cmd) {
  1552.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1553.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1554.                     else {
  1555.                         API.sendChat(subChat(basicBot.chat.commandslink, {botname: basicBot.settings.botName, link: basicBot.cmdLink}));
  1556.                     }
  1557.                 }
  1558.             },
  1559.  
  1560.             cookieCommand: {
  1561.                 command: 'cookie',
  1562.                 rank: 'user',
  1563.                 type: 'startsWith',
  1564.                 cookies: ['has given you a chocolate chip cookie!',
  1565.                     'has given you a soft homemade oatmeal cookie!',
  1566.                     'has given you a plain, dry, old cookie. It was the last one in the bag. Gross.',
  1567.                     'gives you a sugar cookie. What, no frosting and sprinkles? 0/10 would not touch.',
  1568.                     'gives you a chocolate chip cookie. Oh wait, those are raisins. Bleck!',
  1569.                     'gives you an enormous cookie. Poking it gives you more cookies. Weird.',
  1570.                     'gives you a fortune cookie. It reads "Why aren\'t you working on any projects?"',
  1571.                     'gives you a fortune cookie. It reads "Give that special someone a compliment"',
  1572.                     'gives you a fortune cookie. It reads "Take a risk!"',
  1573.                     'gives you a fortune cookie. It reads "Go outside."',
  1574.                     'gives you a fortune cookie. It reads "Don\'t forget to eat your veggies!"',
  1575.                     'gives you a fortune cookie. It reads "Do you even lift?"',
  1576.                     'gives you a fortune cookie. It reads "m808 pls"',
  1577.                     'gives you a fortune cookie. It reads "If you move your hips, you\'ll get all the ladies."',
  1578.                     'gives you a fortune cookie. It reads "I love you."',
  1579.                     'gives you a Golden Cookie. You can\'t eat it because it is made of gold. Dammit.',
  1580.                     'gives you an Oreo cookie with a glass of milk!',
  1581.                     'gives you a rainbow cookie made with love :heart:',
  1582.                     'gives you an old cookie that was left out in the rain, it\'s moldy.',
  1583.                     'bakes you fresh cookies, it smells amazing.'
  1584.                 ],
  1585.                 getCookie: function () {
  1586.                     var c = Math.floor(Math.random() * this.cookies.length);
  1587.                     return this.cookies[c];
  1588.                 },
  1589.                 functionality: function (chat, cmd) {
  1590.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1591.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1592.                     else {
  1593.                         var msg = chat.message;
  1594.  
  1595.                         var space = msg.indexOf(' ');
  1596.                         if (space === -1) {
  1597.                             API.sendChat(basicBot.chat.eatcookie);
  1598.                             return false;
  1599.                         }
  1600.                         else {
  1601.                             var name = msg.substring(space + 2);
  1602.                             var user = basicBot.userUtilities.lookupUserName(name);
  1603.                             if (user === false || !user.inRoom) {
  1604.                                 return API.sendChat(subChat(basicBot.chat.nousercookie, {name: name}));
  1605.                             }
  1606.                             else if (user.username === chat.un) {
  1607.                                 return API.sendChat(subChat(basicBot.chat.selfcookie, {name: name}));
  1608.                             }
  1609.                             else {
  1610.                                 return API.sendChat(subChat(basicBot.chat.cookie, {nameto: user.username, namefrom: chat.un, cookie: this.getCookie()}));
  1611.                             }
  1612.                         }
  1613.                     }
  1614.                 }
  1615.             },
  1616.  
  1617.             cycleCommand: {
  1618.                 command: 'cycle',
  1619.                 rank: 'manager',
  1620.                 type: 'exact',
  1621.                 functionality: function (chat, cmd) {
  1622.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1623.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1624.                     else {
  1625.                         basicBot.roomUtilities.changeDJCycle();
  1626.                     }
  1627.                 }
  1628.             },
  1629.  
  1630.             cycleguardCommand: {
  1631.                 command: 'cycleguard',
  1632.                 rank: 'bouncer',
  1633.                 type: 'exact',
  1634.                 functionality: function (chat, cmd) {
  1635.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1636.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1637.                     else {
  1638.                         if (basicBot.settings.cycleGuard) {
  1639.                             basicBot.settings.cycleGuard = !basicBot.settings.cycleGuard;
  1640.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.cycleguard}));
  1641.                         }
  1642.                         else {
  1643.                             basicBot.settings.cycleGuard = !basicBot.settings.cycleGuard;
  1644.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.cycleguard}));
  1645.                         }
  1646.  
  1647.                     }
  1648.                 }
  1649.             },
  1650.  
  1651.             cycletimerCommand: {
  1652.                 command: 'cycletimer',
  1653.                 rank: 'manager',
  1654.                 type: 'startsWith',
  1655.                 functionality: function (chat, cmd) {
  1656.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1657.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1658.                     else {
  1659.                         var msg = chat.message;
  1660.                         var cycleTime = msg.substring(cmd.length + 1);
  1661.                         if (!isNaN(cycleTime) && cycleTime !== "") {
  1662.                             basicBot.settings.maximumCycletime = cycleTime;
  1663.                             return API.sendChat(subChat(basicBot.chat.cycleguardtime, {name: chat.un, time: basicBot.settings.maximumCycletime}));
  1664.                         }
  1665.                         else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  1666.  
  1667.                     }
  1668.                 }
  1669.             },
  1670.  
  1671.             voteskipCommand: {
  1672.                 command: 'voteskip',
  1673.                 rank: 'manager',
  1674.                 type: 'startsWith',
  1675.                 functionality: function (chat, cmd) {
  1676.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1677.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1678.                     else {
  1679.                         var msg = chat.message;
  1680.                         if (msg.length <= cmd.length + 1) return API.sendChat(subChat(basicBot.chat.voteskiplimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit}));
  1681.                         var argument = msg.substring(cmd.length + 1);
  1682.                         if (!basicBot.settings.voteSkip) basicBot.settings.voteSkip = !basicBot.settings.voteSkip;
  1683.                         if (isNaN(argument)) {
  1684.                             API.sendChat(subChat(basicBot.chat.voteskipinvalidlimit, {name: chat.un}));
  1685.                         }
  1686.                         else {
  1687.                             basicBot.settings.voteSkipLimit = argument;
  1688.                             API.sendChat(subChat(basicBot.chat.voteskipsetlimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit}));
  1689.                         }
  1690.                     }
  1691.                 }
  1692.             },
  1693.  
  1694.             togglevoteskipCommand: {
  1695.                 command: 'togglevoteskip',
  1696.                 rank: 'bouncer',
  1697.                 type: 'exact',
  1698.                 functionality: function (chat, cmd) {
  1699.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1700.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1701.                     else {
  1702.                         if (basicBot.settings.voteSkip) {
  1703.                             basicBot.settings.voteSkip = !basicBot.settings.voteSkip;
  1704.                             API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.voteskip}));
  1705.                         }
  1706.                         else {
  1707.                             basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled;
  1708.                             API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.voteskip}));
  1709.                         }
  1710.                     }
  1711.                 }
  1712.             },
  1713.  
  1714.             dclookupCommand: {
  1715.                 command: ['dclookup', 'dc'],
  1716.                 rank: 'user',
  1717.                 type: 'startsWith',
  1718.                 functionality: function (chat, cmd) {
  1719.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1720.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1721.                     else {
  1722.                         var msg = chat.message;
  1723.                         var name;
  1724.                         if (msg.length === cmd.length) name = chat.un;
  1725.                         else {
  1726.                             name = msg.substring(cmd.length + 2);
  1727.                             var perm = basicBot.userUtilities.getPermission(chat.uid);
  1728.                             if (perm < 2) return API.sendChat(subChat(basicBot.chat.dclookuprank, {name: chat.un}));
  1729.                         }
  1730.                         var user = basicBot.userUtilities.lookupUserName(name);
  1731.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1732.                         var toChat = basicBot.userUtilities.dclookup(user.id);
  1733.                         API.sendChat(toChat);
  1734.                     }
  1735.                 }
  1736.             },
  1737.  
  1738.             deletechatCommand: {
  1739.                 command: 'deletechat',
  1740.                 rank: 'mod',
  1741.                 type: 'startsWith',
  1742.                 functionality: function (chat, cmd) {
  1743.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1744.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1745.                     else {
  1746.                         var msg = chat.message;
  1747.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1748.                         var name = msg.substring(cmd.length + 2);
  1749.                         var user = basicBot.userUtilities.lookupUserName(name);
  1750.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1751.                         var chats = $('.from');
  1752.                         for (var i = 0; i < chats.length; i++) {
  1753.                             var n = chats[i].textContent;
  1754.                             if (name.trim() === n.trim()) {
  1755.                                 var cid = $(chats[i]).parent()[0].getAttribute('data-cid');
  1756.                                 API.moderateDeleteChat(cid);
  1757.                             }
  1758.                         }
  1759.                         API.sendChat(subChat(basicBot.chat.deletechat, {name: chat.un, username: name}));
  1760.                     }
  1761.                 }
  1762.             },
  1763.  
  1764.             emojiCommand: {
  1765.                 command: 'emoji',
  1766.                 rank: 'user',
  1767.                 type: 'exact',
  1768.                 functionality: function (chat, cmd) {
  1769.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1770.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1771.                     else {
  1772.                         var link = 'http://www.emoji-cheat-sheet.com/';
  1773.                         API.sendChat(subChat(basicBot.chat.emojilist, {link: link}));
  1774.                     }
  1775.                 }
  1776.             },
  1777.  
  1778.             etaCommand: {
  1779.                 command: 'eta',
  1780.                 rank: 'user',
  1781.                 type: 'startsWith',
  1782.                 functionality: function (chat, cmd) {
  1783.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1784.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1785.                     else {
  1786.                         var perm = basicBot.userUtilities.getPermission(chat.uid);
  1787.                         var msg = chat.message;
  1788.                         var name;
  1789.                         if (msg.length > cmd.length) {
  1790.                             if (perm < 2) return void (0);
  1791.                             name = msg.substring(cmd.length + 2);
  1792.                         } else name = chat.un;
  1793.                         var user = basicBot.userUtilities.lookupUserName(name);
  1794.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1795.                         var pos = API.getWaitListPosition(user.id);
  1796.                         if (pos < 0) return API.sendChat(subChat(basicBot.chat.notinwaitlist, {name: name}));
  1797.                         var timeRemaining = API.getTimeRemaining();
  1798.                         var estimateMS = ((pos + 1) * 4 * 60 + timeRemaining) * 1000;
  1799.                         var estimateString = basicBot.roomUtilities.msToStr(estimateMS);
  1800.                         API.sendChat(subChat(basicBot.chat.eta, {name: name, time: estimateString}));
  1801.                     }
  1802.                 }
  1803.             },
  1804.  
  1805.             fbCommand: {
  1806.                 command: 'fb',
  1807.                 rank: 'user',
  1808.                 type: 'exact',
  1809.                 functionality: function (chat, cmd) {
  1810.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1811.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1812.                     else {
  1813.                         if (typeof basicBot.settings.fbLink === "string")
  1814.                             API.sendChat(subChat(basicBot.chat.facebook, {link: basicBot.settings.fbLink}));
  1815.                     }
  1816.                 }
  1817.             },
  1818.  
  1819.             filterCommand: {
  1820.                 command: 'filter',
  1821.                 rank: 'bouncer',
  1822.                 type: 'exact',
  1823.                 functionality: function (chat, cmd) {
  1824.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1825.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1826.                     else {
  1827.                         if (basicBot.settings.filterChat) {
  1828.                             basicBot.settings.filterChat = !basicBot.settings.filterChat;
  1829.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.chatfilter}));
  1830.                         }
  1831.                         else {
  1832.                             basicBot.settings.filterChat = !basicBot.settings.filterChat;
  1833.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.chatfilter}));
  1834.                         }
  1835.                     }
  1836.                 }
  1837.             },
  1838.  
  1839.             helpCommand: {
  1840.                 command: 'help',
  1841.                 rank: 'user',
  1842.                 type: 'exact',
  1843.                 functionality: function (chat, cmd) {
  1844.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1845.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1846.                     else {
  1847.                         var link = "http://i.imgur.com/SBAso1N.jpg";
  1848.                         API.sendChat(subChat(basicBot.chat.starterhelp, {link: link}));
  1849.                     }
  1850.                 }
  1851.             },
  1852.  
  1853.             joinCommand: {
  1854.                 command: 'join',
  1855.                 rank: 'user',
  1856.                 type: 'exact',
  1857.                 functionality: function (chat, cmd) {
  1858.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1859.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1860.                     else {
  1861.                         if (basicBot.room.roulette.rouletteStatus && basicBot.room.roulette.participants.indexOf(chat.uid) < 0) {
  1862.                             basicBot.room.roulette.participants.push(chat.uid);
  1863.                             API.sendChat(subChat(basicBot.chat.roulettejoin, {name: chat.un}));
  1864.                         }
  1865.                     }
  1866.                 }
  1867.             },
  1868.  
  1869.             jointimeCommand: {
  1870.                 command: 'jointime',
  1871.                 rank: 'bouncer',
  1872.                 type: 'startsWith',
  1873.                 functionality: function (chat, cmd) {
  1874.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1875.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1876.                     else {
  1877.                         var msg = chat.message;
  1878.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1879.                         var name = msg.substring(cmd.length + 2);
  1880.                         var user = basicBot.userUtilities.lookupUserName(name);
  1881.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  1882.                         var join = basicBot.userUtilities.getJointime(user);
  1883.                         var time = Date.now() - join;
  1884.                         var timeString = basicBot.roomUtilities.msToStr(time);
  1885.                         API.sendChat(subChat(basicBot.chat.jointime, {namefrom: chat.un, username: name, time: timeString}));
  1886.                     }
  1887.                 }
  1888.             },
  1889.  
  1890.             kickCommand: {
  1891.                 command: 'kick',
  1892.                 rank: 'bouncer',
  1893.                 type: 'startsWith',
  1894.                 functionality: function (chat, cmd) {
  1895.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1896.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1897.                     else {
  1898.                         var msg = chat.message;
  1899.                         var lastSpace = msg.lastIndexOf(' ');
  1900.                         var time;
  1901.                         var name;
  1902.                         if (lastSpace === msg.indexOf(' ')) {
  1903.                             time = 0.25;
  1904.                             name = msg.substring(cmd.length + 2);
  1905.                         }
  1906.                         else {
  1907.                             time = msg.substring(lastSpace + 1);
  1908.                             name = msg.substring(cmd.length + 2, lastSpace);
  1909.                         }
  1910.  
  1911.                         var user = basicBot.userUtilities.lookupUserName(name);
  1912.                         var from = chat.un;
  1913.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  1914.  
  1915.                         var permFrom = basicBot.userUtilities.getPermission(chat.uid);
  1916.                         var permTokick = basicBot.userUtilities.getPermission(user.id);
  1917.  
  1918.                         if (permFrom <= permTokick)
  1919.                             return API.sendChat(subChat(basicBot.chat.kickrank, {name: chat.un}));
  1920.  
  1921.                         if (!isNaN(time)) {
  1922.                             API.sendChat(subChat(basicBot.chat.kick, {name: chat.un, username: name, time: time}));
  1923.                             if (time > 24 * 60 * 60) API.moderateBanUser(user.id, 1, API.BAN.PERMA);
  1924.                             else API.moderateBanUser(user.id, 1, API.BAN.DAY);
  1925.                             setTimeout(function (id, name) {
  1926.                                 API.moderateUnbanUser(id);
  1927.                                 console.log('Unbanned @' + name + '. (' + id + ')');
  1928.                             }, time * 60 * 1000, user.id, name);
  1929.                         }
  1930.                         else API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  1931.                     }
  1932.                 }
  1933.             },
  1934.  
  1935.             killCommand: {
  1936.                 command: 'kill',
  1937.                 rank: 'bouncer',
  1938.                 type: 'exact',
  1939.                 functionality: function (chat, cmd) {
  1940.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1941.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1942.                     else {
  1943.                         storeToStorage();
  1944.                         API.sendChat(basicBot.chat.kill);
  1945.                         basicBot.disconnectAPI();
  1946.                         setTimeout(function () {
  1947.                             kill();
  1948.                         }, 1000);
  1949.                     }
  1950.                 }
  1951.             },
  1952.  
  1953.             leaveCommand: {
  1954.                 command: 'leave',
  1955.                 rank: 'user',
  1956.                 type: 'exact',
  1957.                 functionality: function (chat, cmd) {
  1958.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1959.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1960.                     else {
  1961.                         var ind = basicBot.room.roulette.participants.indexOf(chat.uid);
  1962.                         if (ind > -1) {
  1963.                             basicBot.room.roulette.participants.splice(ind, 1);
  1964.                             API.sendChat(subChat(basicBot.chat.rouletteleave, {name: chat.un}));
  1965.                         }
  1966.                     }
  1967.                 }
  1968.             },
  1969.  
  1970.             linkCommand: {
  1971.                 command: 'link',
  1972.                 rank: 'user',
  1973.                 type: 'exact',
  1974.                 functionality: function (chat, cmd) {
  1975.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  1976.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  1977.                     else {
  1978.                         var media = API.getMedia();
  1979.                         var from = chat.un;
  1980.                         var user = basicBot.userUtilities.lookupUser(chat.uid);
  1981.                         var perm = basicBot.userUtilities.getPermission(chat.uid);
  1982.                         var dj = API.getDJ().id;
  1983.                         var isDj = false;
  1984.                         if (dj === chat.uid) isDj = true;
  1985.                         if (perm >= 1 || isDj) {
  1986.                             if (media.format === 1) {
  1987.                                 var linkToSong = "https://www.youtube.com/watch?v=" + media.cid;
  1988.                                 API.sendChat(subChat(basicBot.chat.songlink, {name: from, link: linkToSong}));
  1989.                             }
  1990.                             if (media.format === 2) {
  1991.                                 SC.get('/tracks/' + media.cid, function (sound) {
  1992.                                     API.sendChat(subChat(basicBot.chat.songlink, {name: from, link: sound.permalink_url}));
  1993.                                 });
  1994.                             }
  1995.                         }
  1996.                     }
  1997.                 }
  1998.             },
  1999.  
  2000.             lockCommand: {
  2001.                 command: 'lock',
  2002.                 rank: 'mod',
  2003.                 type: 'exact',
  2004.                 functionality: function (chat, cmd) {
  2005.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2006.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2007.                     else {
  2008.                         basicBot.roomUtilities.booth.lockBooth();
  2009.                     }
  2010.                 }
  2011.             },
  2012.  
  2013.             lockdownCommand: {
  2014.                 command: 'lockdown',
  2015.                 rank: 'mod',
  2016.                 type: 'exact',
  2017.                 functionality: function (chat, cmd) {
  2018.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2019.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2020.                     else {
  2021.                         var temp = basicBot.settings.lockdownEnabled;
  2022.                         basicBot.settings.lockdownEnabled = !temp;
  2023.                         if (basicBot.settings.lockdownEnabled) {
  2024.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.lockdown}));
  2025.                         }
  2026.                         else return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockdown}));
  2027.                     }
  2028.                 }
  2029.             },
  2030.  
  2031.             lockguardCommand: {
  2032.                 command: 'lockguard',
  2033.                 rank: 'bouncer',
  2034.                 type: 'exact',
  2035.                 functionality: function (chat, cmd) {
  2036.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2037.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2038.                     else {
  2039.                         if (basicBot.settings.lockGuard) {
  2040.                             basicBot.settings.lockGuard = !basicBot.settings.lockGuard;
  2041.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockdown}));
  2042.                         }
  2043.                         else {
  2044.                             basicBot.settings.lockGuard = !basicBot.settings.lockGuard;
  2045.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.lockguard}));
  2046.                         }
  2047.                     }
  2048.                 }
  2049.             },
  2050.  
  2051.             lockskipCommand: {
  2052.                 command: 'lockskip',
  2053.                 rank: 'bouncer',
  2054.                 type: 'startsWith',
  2055.                 functionality: function (chat, cmd) {
  2056.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2057.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2058.                     else {
  2059.                         if (basicBot.room.skippable) {
  2060.                             var dj = API.getDJ();
  2061.                             var id = dj.id;
  2062.                             var name = dj.username;
  2063.                             var msgSend = '@' + name + ': ';
  2064.                             basicBot.room.queueable = false;
  2065.  
  2066.                             if (chat.message.length === cmd.length) {
  2067.                                 API.sendChat(subChat(basicBot.chat.usedlockskip, {name: chat.un}));
  2068.                                 basicBot.roomUtilities.booth.lockBooth();
  2069.                                 setTimeout(function (id) {
  2070.                                     API.moderateForceSkip();
  2071.                                     basicBot.room.skippable = false;
  2072.                                     setTimeout(function () {
  2073.                                         basicBot.room.skippable = true
  2074.                                     }, 5 * 1000);
  2075.                                     setTimeout(function (id) {
  2076.                                         basicBot.userUtilities.moveUser(id, basicBot.settings.lockskipPosition, false);
  2077.                                         basicBot.room.queueable = true;
  2078.                                         setTimeout(function () {
  2079.                                             basicBot.roomUtilities.booth.unlockBooth();
  2080.                                         }, 1000);
  2081.                                     }, 1500, id);
  2082.                                 }, 1000, id);
  2083.                                 return void (0);
  2084.                             }
  2085.                             var validReason = false;
  2086.                             var msg = chat.message;
  2087.                             var reason = msg.substring(cmd.length + 1);
  2088.                             for (var i = 0; i < basicBot.settings.lockskipReasons.length; i++) {
  2089.                                 var r = basicBot.settings.lockskipReasons[i][0];
  2090.                                 if (reason.indexOf(r) !== -1) {
  2091.                                     validReason = true;
  2092.                                     msgSend += basicBot.settings.lockskipReasons[i][1];
  2093.                                 }
  2094.                             }
  2095.                             if (validReason) {
  2096.                                 API.sendChat(subChat(basicBot.chat.usedlockskip, {name: chat.un}));
  2097.                                 basicBot.roomUtilities.booth.lockBooth();
  2098.                                 setTimeout(function (id) {
  2099.                                     API.moderateForceSkip();
  2100.                                     basicBot.room.skippable = false;
  2101.                                     API.sendChat(msgSend);
  2102.                                     setTimeout(function () {
  2103.                                         basicBot.room.skippable = true
  2104.                                     }, 5 * 1000);
  2105.                                     setTimeout(function (id) {
  2106.                                         basicBot.userUtilities.moveUser(id, basicBot.settings.lockskipPosition, false);
  2107.                                         basicBot.room.queueable = true;
  2108.                                         setTimeout(function () {
  2109.                                             basicBot.roomUtilities.booth.unlockBooth();
  2110.                                         }, 1000);
  2111.                                     }, 1500, id);
  2112.                                 }, 1000, id);
  2113.                                 return void (0);
  2114.                             }
  2115.                         }
  2116.                     }
  2117.                 }
  2118.             },
  2119.  
  2120.             lockskipposCommand: {
  2121.                 command: 'lockskippos',
  2122.                 rank: 'manager',
  2123.                 type: 'startsWith',
  2124.                 functionality: function (chat, cmd) {
  2125.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2126.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2127.                     else {
  2128.                         var msg = chat.message;
  2129.                         var pos = msg.substring(cmd.length + 1);
  2130.                         if (!isNaN(pos)) {
  2131.                             basicBot.settings.lockskipPosition = pos;
  2132.                             return API.sendChat(subChat(basicBot.chat.lockskippos, {name: chat.un, position: basicBot.settings.lockskipPosition}));
  2133.                         }
  2134.                         else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un}));
  2135.                     }
  2136.                 }
  2137.             },
  2138.  
  2139.             locktimerCommand: {
  2140.                 command: 'locktimer',
  2141.                 rank: 'manager',
  2142.                 type: 'startsWith',
  2143.                 functionality: function (chat, cmd) {
  2144.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2145.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2146.                     else {
  2147.                         var msg = chat.message;
  2148.                         var lockTime = msg.substring(cmd.length + 1);
  2149.                         if (!isNaN(lockTime) && lockTime !== "") {
  2150.                             basicBot.settings.maximumLocktime = lockTime;
  2151.                             return API.sendChat(subChat(basicBot.chat.lockguardtime, {name: chat.un, time: basicBot.settings.maximumLocktime}));
  2152.                         }
  2153.                         else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  2154.                     }
  2155.                 }
  2156.             },
  2157.  
  2158.             maxlengthCommand: {
  2159.                 command: 'maxlength',
  2160.                 rank: 'manager',
  2161.                 type: 'startsWith',
  2162.                 functionality: function (chat, cmd) {
  2163.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2164.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2165.                     else {
  2166.                         var msg = chat.message;
  2167.                         var maxTime = msg.substring(cmd.length + 1);
  2168.                         if (!isNaN(maxTime)) {
  2169.                             basicBot.settings.maximumSongLength = maxTime;
  2170.                             return API.sendChat("Sua mĂșsica foi pulada pois tem acima de 8 min/ Your song was skipped because it has over than 8 minutes. You need some permission to play long songs");
  2171.                         }
  2172.                         else return API.sendChat("Sua mĂșsica foi pulada pois tem acima de 8 min/ Your song was skipped because it has over than 8 minutes. You need some permission to play long songs");
  2173.                     }
  2174.                 }
  2175.             },
  2176.  
  2177.             motdCommand: {
  2178.                 command: 'motd',
  2179.                 rank: 'bouncer',
  2180.                 type: 'startsWith',
  2181.                 functionality: function (chat, cmd) {
  2182.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2183.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2184.                     else {
  2185.                         var msg = chat.message;
  2186.                         if (msg.length <= cmd.length + 1) return API.sendChat('/me MotD: ' + basicBot.settings.motd);
  2187.                         var argument = msg.substring(cmd.length + 1);
  2188.                         if (!basicBot.settings.motdEnabled) basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled;
  2189.                         if (isNaN(argument)) {
  2190.                             basicBot.settings.motd = argument;
  2191.                             API.sendChat(subChat(basicBot.chat.motdset, {msg: basicBot.settings.motd}));
  2192.                         }
  2193.                         else {
  2194.                             basicBot.settings.motdInterval = argument;
  2195.                             API.sendChat(subChat(basicBot.chat.motdintervalset, {interval: basicBot.settings.motdInterval}));
  2196.                         }
  2197.                     }
  2198.                 }
  2199.             },
  2200.  
  2201.             moveCommand: {
  2202.                 command: 'move',
  2203.                 rank: 'mod',
  2204.                 type: 'startsWith',
  2205.                 functionality: function (chat, cmd) {
  2206.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2207.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2208.                     else {
  2209.                         var msg = chat.message;
  2210.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  2211.                         var firstSpace = msg.indexOf(' ');
  2212.                         var lastSpace = msg.lastIndexOf(' ');
  2213.                         var pos;
  2214.                         var name;
  2215.                         if (isNaN(parseInt(msg.substring(lastSpace + 1)))) {
  2216.                             pos = 1;
  2217.                             name = msg.substring(cmd.length + 2);
  2218.                         }
  2219.                         else {
  2220.                             pos = parseInt(msg.substring(lastSpace + 1));
  2221.                             name = msg.substring(cmd.length + 2, lastSpace);
  2222.                         }
  2223.                         var user = basicBot.userUtilities.lookupUserName(name);
  2224.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  2225.                         if (user.id === basicBot.loggedInID) return API.sendChat(subChat(basicBot.chat.addbotwaitlist, {name: chat.un}));
  2226.                         if (!isNaN(pos)) {
  2227.                             API.sendChat(subChat(basicBot.chat.move, {name: chat.un}));
  2228.                             basicBot.userUtilities.moveUser(user.id, pos, false);
  2229.                         } else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un}));
  2230.                     }
  2231.                 }
  2232.             },
  2233.  
  2234.             muteCommand: {
  2235.                 command: 'mute',
  2236.                 rank: 'bouncer',
  2237.                 type: 'startsWith',
  2238.                 functionality: function (chat, cmd) {
  2239.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2240.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2241.                     else {
  2242.                         var msg = chat.message;
  2243.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  2244.                         var lastSpace = msg.lastIndexOf(' ');
  2245.                         var time = null;
  2246.                         var name;
  2247.                         if (lastSpace === msg.indexOf(' ')) {
  2248.                             name = msg.substring(cmd.length + 2);
  2249.                             time = 45;
  2250.                         }
  2251.                         else {
  2252.                             time = msg.substring(lastSpace + 1);
  2253.                             if (isNaN(time) || time == "" || time == null || typeof time == "undefined") {
  2254.                                 return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  2255.                             }
  2256.                             name = msg.substring(cmd.length + 2, lastSpace);
  2257.                         }
  2258.                         var from = chat.un;
  2259.                         var user = basicBot.userUtilities.lookupUserName(name);
  2260.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  2261.                         var permFrom = basicBot.userUtilities.getPermission(chat.uid);
  2262.                         var permUser = basicBot.userUtilities.getPermission(user.id);
  2263.                         if (permFrom > permUser) {
  2264.                             /*
  2265.                              basicBot.room.mutedUsers.push(user.id);
  2266.                              if (time === null) API.sendChat(subChat(basicBot.chat.mutednotime, {name: chat.un, username: name}));
  2267.                              else {
  2268.                              API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time}));
  2269.                              setTimeout(function (id) {
  2270.                              var muted = basicBot.room.mutedUsers;
  2271.                              var wasMuted = false;
  2272.                              var indexMuted = -1;
  2273.                              for (var i = 0; i < muted.length; i++) {
  2274.                              if (muted[i] === id) {
  2275.                              indexMuted = i;
  2276.                              wasMuted = true;
  2277.                              }
  2278.                              }
  2279.                              if (indexMuted > -1) {
  2280.                              basicBot.room.mutedUsers.splice(indexMuted);
  2281.                              var u = basicBot.userUtilities.lookupUser(id);
  2282.                              var name = u.username;
  2283.                              API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name}));
  2284.                              }
  2285.                              }, time * 60 * 1000, user.id);
  2286.                              }
  2287.                              */
  2288.                             if (time > 45) {
  2289.                                 API.sendChat(subChat(basicBot.chat.mutedmaxtime, {name: chat.un, time: "45"}));
  2290.                                 API.moderateMuteUser(user.id, 1, API.MUTE.LONG);
  2291.                             }
  2292.                             else if (time === 45) {
  2293.                                 API.moderateMuteUser(user.id, 1, API.MUTE.LONG);
  2294.                                 API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time}));
  2295.  
  2296.                             }
  2297.                             else if (time > 30) {
  2298.                                 API.moderateMuteUser(user.id, 1, API.MUTE.LONG);
  2299.                                 API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time}));
  2300.                                 setTimeout(function (id) {
  2301.                                     API.moderateUnmuteUser(id);
  2302.                                 }, time * 60 * 1000, user.id);
  2303.                             }
  2304.                             else if (time > 15) {
  2305.                                 API.moderateMuteUser(user.id, 1, API.MUTE.MEDIUM);
  2306.                                 API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time}));
  2307.                                 setTimeout(function (id) {
  2308.                                     API.moderateUnmuteUser(id);
  2309.                                 }, time * 60 * 1000, user.id);
  2310.                             }
  2311.                             else {
  2312.                                 API.moderateMuteUser(user.id, 1, API.MUTE.SHORT);
  2313.                                 API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time}));
  2314.                                 setTimeout(function (id) {
  2315.                                     API.moderateUnmuteUser(id);
  2316.                                 }, time * 60 * 1000, user.id);
  2317.                             }
  2318.                         }
  2319.                         else API.sendChat(subChat(basicBot.chat.muterank, {name: chat.un}));
  2320.                     }
  2321.                 }
  2322.             },
  2323.  
  2324.             opCommand: {
  2325.                 command: 'op',
  2326.                 rank: 'user',
  2327.                 type: 'exact',
  2328.                 functionality: function (chat, cmd) {
  2329.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2330.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2331.                     else {
  2332.                         if (typeof basicBot.settings.opLink === "string")
  2333.                             return API.sendChat(subChat(basicBot.chat.oplist, {link: basicBot.settings.opLink}));
  2334.                     }
  2335.                 }
  2336.             },
  2337.  
  2338.             pingCommand: {
  2339.                 command: 'ping',
  2340.                 rank: 'user',
  2341.                 type: 'exact',
  2342.                 functionality: function (chat, cmd) {
  2343.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2344.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2345.                     else {
  2346.                         API.sendChat(basicBot.chat.pong)
  2347.                     }
  2348.                 }
  2349.             },
  2350.  
  2351.             refreshCommand: {
  2352.                 command: 'refresh',
  2353.                 rank: 'manager',
  2354.                 type: 'exact',
  2355.                 functionality: function (chat, cmd) {
  2356.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2357.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2358.                     else {
  2359.                         storeToStorage();
  2360.                         basicBot.disconnectAPI();
  2361.                         setTimeout(function () {
  2362.                             window.location.reload(false);
  2363.                         }, 1000);
  2364.  
  2365.                     }
  2366.                 }
  2367.             },
  2368.  
  2369.             reloadCommand: {
  2370.                 command: 'reload',
  2371.                 rank: 'bouncer',
  2372.                 type: 'exact',
  2373.                 functionality: function (chat, cmd) {
  2374.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2375.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2376.                     else {
  2377.                         API.sendChat(basicBot.chat.reload);
  2378.                         storeToStorage();
  2379.                         basicBot.disconnectAPI();
  2380.                         kill();
  2381.                         setTimeout(function () {
  2382.                             $.getScript(basicBot.scriptLink);
  2383.                         }, 2000);
  2384.                     }
  2385.                 }
  2386.             },
  2387.  
  2388.             removeCommand: {
  2389.                 command: 'remove',
  2390.                 rank: 'mod',
  2391.                 type: 'startsWith',
  2392.                 functionality: function (chat, cmd) {
  2393.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2394.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2395.                     else {
  2396.                         var msg = chat.message;
  2397.                         if (msg.length > cmd.length + 2) {
  2398.                             var name = msg.substr(cmd.length + 2);
  2399.                             var user = basicBot.userUtilities.lookupUserName(name);
  2400.                             if (typeof user !== 'boolean') {
  2401.                                 user.lastDC = {
  2402.                                     time: null,
  2403.                                     position: null,
  2404.                                     songCount: 0
  2405.                                 };
  2406.                                 if (API.getDJ().id === user.id) {
  2407.                                     API.moderateForceSkip();
  2408.                                     setTimeout(function () {
  2409.                                         API.moderateRemoveDJ(user.id);
  2410.                                     }, 1 * 1000, user);
  2411.                                 }
  2412.                                 else API.moderateRemoveDJ(user.id);
  2413.                             } else API.sendChat(subChat(basicBot.chat.removenotinwl, {name: chat.un, username: name}));
  2414.                         } else API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  2415.                     }
  2416.                 }
  2417.             },
  2418.  
  2419.             restrictetaCommand: {
  2420.                 command: 'restricteta',
  2421.                 rank: 'bouncer',
  2422.                 type: 'exact',
  2423.                 functionality: function (chat, cmd) {
  2424.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2425.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2426.                     else {
  2427.                         if (basicBot.settings.etaRestriction) {
  2428.                             basicBot.settings.etaRestriction = !basicBot.settings.etaRestriction;
  2429.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.etarestriction}));
  2430.                         }
  2431.                         else {
  2432.                             basicBot.settings.etaRestriction = !basicBot.settings.etaRestriction;
  2433.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.etarestriction}));
  2434.                         }
  2435.                     }
  2436.                 }
  2437.             },
  2438.  
  2439.             rouletteCommand: {
  2440.                 command: 'roulette',
  2441.                 rank: 'mod',
  2442.                 type: 'exact',
  2443.                 functionality: function (chat, cmd) {
  2444.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2445.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2446.                     else {
  2447.                         if (!basicBot.room.roulette.rouletteStatus) {
  2448.                             basicBot.room.roulette.startRoulette();
  2449.                         }
  2450.                     }
  2451.                 }
  2452.             },
  2453.  
  2454.             rulesCommand: {
  2455.                 command: 'rules',
  2456.                 rank: 'user',
  2457.                 type: 'exact',
  2458.                 functionality: function (chat, cmd) {
  2459.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2460.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2461.                     else {
  2462.                         if (typeof basicBot.settings.rulesLink === "string")
  2463.                             return API.sendChat(subChat(basicBot.chat.roomrules, {link: basicBot.settings.rulesLink}));
  2464.                     }
  2465.                 }
  2466.             },
  2467.  
  2468.             sessionstatsCommand: {
  2469.                 command: 'sessionstats',
  2470.                 rank: 'bouncer',
  2471.                 type: 'exact',
  2472.                 functionality: function (chat, cmd) {
  2473.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2474.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2475.                     else {
  2476.                         var from = chat.un;
  2477.                         var woots = basicBot.room.roomstats.totalWoots;
  2478.                         var mehs = basicBot.room.roomstats.totalMehs;
  2479.                         var grabs = basicBot.room.roomstats.totalCurates;
  2480.                         API.sendChat(subChat(basicBot.chat.sessionstats, {name: from, woots: woots, mehs: mehs, grabs: grabs}));
  2481.                     }
  2482.                 }
  2483.             },
  2484.  
  2485.             skipCommand: {
  2486.                 command: 'skip',
  2487.                 rank: 'bouncer',
  2488.                 type: 'exact',
  2489.                 functionality: function (chat, cmd) {
  2490.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2491.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2492.                     else {
  2493.                         API.sendChat(subChat(basicBot.chat.skip, {name: chat.un}));
  2494.                         API.moderateForceSkip();
  2495.                         basicBot.room.skippable = false;
  2496.                         setTimeout(function () {
  2497.                             basicBot.room.skippable = true
  2498.                         }, 5 * 1000);
  2499.  
  2500.                     }
  2501.                 }
  2502.             },
  2503.  
  2504.             songstatsCommand: {
  2505.                 command: 'songstats',
  2506.                 rank: 'mod',
  2507.                 type: 'exact',
  2508.                 functionality: function (chat, cmd) {
  2509.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2510.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2511.                     else {
  2512.                         if (basicBot.settings.songstats) {
  2513.                             basicBot.settings.songstats = !basicBot.settings.songstats;
  2514.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.songstats}));
  2515.                         }
  2516.                         else {
  2517.                             basicBot.settings.songstats = !basicBot.settings.songstats;
  2518.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.songstats}));
  2519.                         }
  2520.                     }
  2521.                 }
  2522.             },
  2523.  
  2524.             sourceCommand: {
  2525.                 command: 'source',
  2526.                 rank: 'user',
  2527.                 type: 'exact',
  2528.                 functionality: function (chat, cmd) {
  2529.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2530.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2531.                     else {
  2532.                         API.sendChat('/me This bot was made by ' + botCreator + '.');
  2533.                     }
  2534.                 }
  2535.             },
  2536.  
  2537.             statusCommand: {
  2538.                 command: 'status',
  2539.                 rank: 'bouncer',
  2540.                 type: 'exact',
  2541.                 functionality: function (chat, cmd) {
  2542.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2543.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2544.                     else {
  2545.                         var from = chat.un;
  2546.                         var msg = '/me [@' + from + '] ';
  2547.  
  2548.                         msg += basicBot.chat.afkremoval + ': ';
  2549.                         if (basicBot.settings.afkRemoval) msg += 'ON';
  2550.                         else msg += 'OFF';
  2551.                         msg += '. ';
  2552.                         msg += basicBot.chat.afksremoved + ": " + basicBot.room.afkList.length + '. ';
  2553.                         msg += basicBot.chat.afklimit + ': ' + basicBot.settings.maximumAfk + '. ';
  2554.  
  2555.                         msg += 'Bouncer+: ';
  2556.                         if (basicBot.settings.bouncerPlus) msg += 'ON';
  2557.                         else msg += 'OFF';
  2558.                         msg += '. ';
  2559.  
  2560.                         msg += basicBot.chat.lockguard + ': ';
  2561.                         if (basicBot.settings.lockGuard) msg += 'ON';
  2562.                         else msg += 'OFF';
  2563.                         msg += '. ';
  2564.  
  2565.                         msg += basicBot.chat.cycleguard + ': ';
  2566.                         if (basicBot.settings.cycleGuard) msg += 'ON';
  2567.                         else msg += 'OFF';
  2568.                         msg += '. ';
  2569.  
  2570.                         msg += basicBot.chat.timeguard + ': ';
  2571.                         if (basicBot.settings.timeGuard) msg += 'ON';
  2572.                         else msg += 'OFF';
  2573.                         msg += '. ';
  2574.  
  2575.                         msg += basicBot.chat.chatfilter + ': ';
  2576.                         if (basicBot.settings.filterChat) msg += 'ON';
  2577.                         else msg += 'OFF';
  2578.                         msg += '. ';
  2579.  
  2580.                         msg += basicBot.chat.voteskip + ': ';
  2581.                         if (Qbot.settings.voteskip) msg += 'ON';
  2582.                         else msg += 'OFF';
  2583.                         msg += '. ';
  2584.  
  2585.                         var launchT = basicBot.room.roomstats.launchTime;
  2586.                         var durationOnline = Date.now() - launchT;
  2587.                         var since = basicBot.roomUtilities.msToStr(durationOnline);
  2588.                         msg += subChat(basicBot.chat.activefor, {time: since});
  2589.  
  2590.                         return API.sendChat(msg);
  2591.                     }
  2592.                 }
  2593.             },
  2594.  
  2595.             swapCommand: {
  2596.                 command: 'swap',
  2597.                 rank: 'mod',
  2598.                 type: 'startsWith',
  2599.                 functionality: function (chat, cmd) {
  2600.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2601.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2602.                     else {
  2603.                         var msg = chat.message;
  2604.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  2605.                         var firstSpace = msg.indexOf(' ');
  2606.                         var lastSpace = msg.lastIndexOf(' ');
  2607.                         var name1 = msg.substring(cmd.length + 2, lastSpace);
  2608.                         var name2 = msg.substring(lastSpace + 2);
  2609.                         var user1 = basicBot.userUtilities.lookupUserName(name1);
  2610.                         var user2 = basicBot.userUtilities.lookupUserName(name2);
  2611.                         if (typeof user1 === 'boolean' || typeof user2 === 'boolean') return API.sendChat(subChat(basicBot.chat.swapinvalid, {name: chat.un}));
  2612.                         if (user1.id === basicBot.loggedInID || user2.id === basicBot.loggedInID) return API.sendChat(subChat(basicBot.chat.addbottowaitlist, {name: chat.un}));
  2613.                         var p1 = API.getWaitListPosition(user1.id) + 1;
  2614.                         var p2 = API.getWaitListPosition(user2.id) + 1;
  2615.                         if (p1 < 0 || p2 < 0) return API.sendChat(subChat(basicBot.chat.swapwlonly, {name: chat.un}));
  2616.                         API.sendChat(subChat(basicBot.chat.swapping, {'name1': name1, 'name2': name2}));
  2617.                         if (p1 < p2) {
  2618.                             basicBot.userUtilities.moveUser(user2.id, p1, false);
  2619.                             setTimeout(function (user1, p2) {
  2620.                                 basicBot.userUtilities.moveUser(user1.id, p2, false);
  2621.                             }, 2000, user1, p2);
  2622.                         }
  2623.                         else {
  2624.                             basicBot.userUtilities.moveUser(user1.id, p2, false);
  2625.                             setTimeout(function (user2, p1) {
  2626.                                 basicBot.userUtilities.moveUser(user2.id, p1, false);
  2627.                             }, 2000, user2, p1);
  2628.                         }
  2629.                     }
  2630.                 }
  2631.             },
  2632.  
  2633.             themeCommand: {
  2634.                 command: 'theme',
  2635.                 rank: 'user',
  2636.                 type: 'exact',
  2637.                 functionality: function (chat, cmd) {
  2638.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2639.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2640.                     else {
  2641.                         if (typeof basicBot.settings.themeLink === "string")
  2642.                             API.sendChat(subChat(basicBot.chat.genres, {link: basicBot.settings.themeLink}));
  2643.                     }
  2644.                 }
  2645.             },
  2646.  
  2647.             timeguardCommand: {
  2648.                 command: 'timeguard',
  2649.                 rank: 'bouncer',
  2650.                 type: 'exact',
  2651.                 functionality: function (chat, cmd) {
  2652.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2653.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2654.                     else {
  2655.                         if (basicBot.settings.timeGuard) {
  2656.                             basicBot.settings.timeGuard = !basicBot.settings.timeGuard;
  2657.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.timeguard}));
  2658.                         }
  2659.                         else {
  2660.                             basicBot.settings.timeGuard = !basicBot.settings.timeGuard;
  2661.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.timeguard}));
  2662.                         }
  2663.  
  2664.                     }
  2665.                 }
  2666.             },
  2667.  
  2668.             togglemotdCommand: {
  2669.                 command: 'togglemotd',
  2670.                 rank: 'bouncer',
  2671.                 type: 'exact',
  2672.                 functionality: function (chat, cmd) {
  2673.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2674.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2675.                     else {
  2676.                         if (basicBot.settings.motdEnabled) {
  2677.                             basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled;
  2678.                             API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.motd}));
  2679.                         }
  2680.                         else {
  2681.                             basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled;
  2682.                             API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.motd}));
  2683.                         }
  2684.                     }
  2685.                 }
  2686.             },
  2687.  
  2688.             unbanCommand: {
  2689.                 command: 'unban',
  2690.                 rank: 'bouncer',
  2691.                 type: 'startsWith',
  2692.                 functionality: function (chat, cmd) {
  2693.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2694.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2695.                     else {
  2696.                         $(".icon-population").click();
  2697.                         $(".icon-ban").click();
  2698.                         setTimeout(function (chat) {
  2699.                             var msg = chat.message;
  2700.                             if (msg.length === cmd.length) return API.sendChat();
  2701.                             var name = msg.substring(cmd.length + 2);
  2702.                             var bannedUsers = API.getBannedUsers();
  2703.                             var found = false;
  2704.                             var bannedUser = null;
  2705.                             for (var i = 0; i < bannedUsers.length; i++) {
  2706.                                 var user = bannedUsers[i];
  2707.                                 if (user.username === name) {
  2708.                                     bannedUser = user;
  2709.                                     found = true;
  2710.                                 }
  2711.                             }
  2712.                             if (!found) {
  2713.                                 $(".icon-chat").click();
  2714.                                 return API.sendChat(subChat(basicBot.chat.notbanned, {name: chat.un}));
  2715.                             }
  2716.                             API.moderateUnbanUser(bannedUser.id);
  2717.                             console.log("Unbanned " + name);
  2718.                             setTimeout(function () {
  2719.                                 $(".icon-chat").click();
  2720.                             }, 1000);
  2721.                         }, 1000, chat);
  2722.                     }
  2723.                 }
  2724.             },
  2725.  
  2726.             unlockCommand: {
  2727.                 command: 'unlock',
  2728.                 rank: 'mod',
  2729.                 type: 'exact',
  2730.                 functionality: function (chat, cmd) {
  2731.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2732.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2733.                     else {
  2734.                         basicBot.roomUtilities.booth.unlockBooth();
  2735.                     }
  2736.                 }
  2737.             },
  2738.  
  2739.             unmuteCommand: {
  2740.                 command: 'unmute',
  2741.                 rank: 'bouncer',
  2742.                 type: 'startsWith',
  2743.                 functionality: function (chat, cmd) {
  2744.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2745.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2746.                     else {
  2747.                         var msg = chat.message;
  2748.                         var permFrom = basicBot.userUtilities.getPermission(chat.uid);
  2749.                         /**
  2750.                          if (msg.indexOf('@') === -1 && msg.indexOf('all') !== -1) {
  2751.                             if (permFrom > 2) {
  2752.                                 basicBot.room.mutedUsers = [];
  2753.                                 return API.sendChat(subChat(basicBot.chat.unmutedeveryone, {name: chat.un}));
  2754.                             }
  2755.                             else return API.sendChat(subChat(basicBot.chat.unmuteeveryonerank, {name: chat.un}));
  2756.                         }
  2757.                          **/
  2758.                         var from = chat.un;
  2759.                         var name = msg.substr(cmd.length + 2);
  2760.  
  2761.                         var user = basicBot.userUtilities.lookupUserName(name);
  2762.  
  2763.                         if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  2764.  
  2765.                         var permUser = basicBot.userUtilities.getPermission(user.id);
  2766.                         if (permFrom > permUser) {
  2767.                             /*
  2768.                              var muted = basicBot.room.mutedUsers;
  2769.                              var wasMuted = false;
  2770.                              var indexMuted = -1;
  2771.                              for (var i = 0; i < muted.length; i++) {
  2772.                              if (muted[i] === user.id) {
  2773.                              indexMuted = i;
  2774.                              wasMuted = true;
  2775.                              }
  2776.  
  2777.                              }
  2778.                              if (!wasMuted) return API.sendChat(subChat(basicBot.chat.notmuted, {name: chat.un}));
  2779.                              basicBot.room.mutedUsers.splice(indexMuted);
  2780.                              API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name}));
  2781.                              */
  2782.                             try {
  2783.                                 API.moderateUnmuteUser(user.id);
  2784.                                 API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name}));
  2785.                             }
  2786.                             catch (e) {
  2787.                                 API.sendChat(subChat(basicBot.chat.notmuted, {name: chat.un}));
  2788.                             }
  2789.                         }
  2790.                         else API.sendChat(subChat(basicBot.chat.unmuterank, {name: chat.un}));
  2791.                     }
  2792.                 }
  2793.             },
  2794.  
  2795.             usercmdcdCommand: {
  2796.                 command: 'usercmdcd',
  2797.                 rank: 'manager',
  2798.                 type: 'startsWith',
  2799.                 functionality: function (chat, cmd) {
  2800.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2801.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2802.                     else {
  2803.                         var msg = chat.message;
  2804.                         var cd = msg.substring(cmd.length + 1);
  2805.                         if (!isNaN(cd)) {
  2806.                             basicBot.settings.commandCooldown = cd;
  2807.                             return API.sendChat(subChat(basicBot.chat.commandscd, {name: chat.un, time: basicBot.settings.commandCooldown}));
  2808.                         }
  2809.                         else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un}));
  2810.                     }
  2811.                 }
  2812.             },
  2813.  
  2814.             usercommandsCommand: {
  2815.                 command: 'usercommands',
  2816.                 rank: 'manager',
  2817.                 type: 'exact',
  2818.                 functionality: function (chat, cmd) {
  2819.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2820.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2821.                     else {
  2822.                         if (basicBot.settings.usercommandsEnabled) {
  2823.                             API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.usercommands}));
  2824.                             basicBot.settings.usercommandsEnabled = !basicBot.settings.usercommandsEnabled;
  2825.                         }
  2826.                         else {
  2827.                             API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.usercommands}));
  2828.                             basicBot.settings.usercommandsEnabled = !basicBot.settings.usercommandsEnabled;
  2829.                         }
  2830.                     }
  2831.                 }
  2832.             },
  2833.  
  2834.             voteratioCommand: {
  2835.                 command: 'voteratio',
  2836.                 rank: 'bouncer',
  2837.                 type: 'startsWith',
  2838.                 functionality: function (chat, cmd) {
  2839.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2840.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2841.                     else {
  2842.                         var msg = chat.message;
  2843.                         if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un}));
  2844.                         var name = msg.substring(cmd.length + 2);
  2845.                         var user = basicBot.userUtilities.lookupUserName(name);
  2846.                         if (user === false) return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un}));
  2847.                         var vratio = user.votes;
  2848.                         var ratio = vratio.woot / vratio.meh;
  2849.                         API.sendChat(subChat(basicBot.chat.voteratio, {name: chat.un, username: name, woot: vratio.woot, mehs: vratio.meh, ratio: ratio.toFixed(2)}));
  2850.                     }
  2851.                 }
  2852.             },
  2853.  
  2854.             welcomeCommand: {
  2855.                 command: 'welcome',
  2856.                 rank: 'mod',
  2857.                 type: 'exact',
  2858.                 functionality: function (chat, cmd) {
  2859.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2860.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2861.                     else {
  2862.                         if (basicBot.settings.welcome) {
  2863.                             basicBot.settings.welcome = !basicBot.settings.welcome;
  2864.                             return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.welcomemsg}));
  2865.                         }
  2866.                         else {
  2867.                             basicBot.settings.welcome = !basicBot.settings.welcome;
  2868.                             return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.welcomemsg}));
  2869.                         }
  2870.                     }
  2871.                 }
  2872.             },
  2873.  
  2874.             websiteCommand: {
  2875.                 command: 'website',
  2876.                 rank: 'user',
  2877.                 type: 'exact',
  2878.                 functionality: function (chat, cmd) {
  2879.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2880.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2881.                     else {
  2882.                         if (typeof basicBot.settings.website === "string")
  2883.                             API.sendChat(subChat(basicBot.chat.website, {link: basicBot.settings.website}));
  2884.                     }
  2885.                 }
  2886.             },
  2887.  
  2888.             youtubeCommand: {
  2889.                 command: 'youtube',
  2890.                 rank: 'user',
  2891.                 type: 'exact',
  2892.                 functionality: function (chat, cmd) {
  2893.                     if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
  2894.                     if (!basicBot.commands.executable(this.rank, chat)) return void (0);
  2895.                     else {
  2896.                         if (typeof basicBot.settings.youtubeLink === "string")
  2897.                             API.sendChat(subChat(basicBot.chat.youtube, {name: chat.un, link: basicBot.settings.youtubeLink}));
  2898.                     }
  2899.                 }
  2900.             }
  2901.         }
  2902.     };
  2903.  
  2904.     loadChat(basicBot.startup);
  2905. }).call(this);
Add Comment
Please, Sign In to add comment