diff --git a/basicBot.js b/basicBot.js index baac6707..4d7aa1dd 100644 --- a/basicBot.js +++ b/basicBot.js @@ -3,7 +3,7 @@ *Modifications (including forks) of the code to fit personal needs are allowed only for personal use and should refer back to the original source. *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. */ - +/** updated roulette (function () { @@ -179,44 +179,27 @@ var botCreatorIDs = ["3851534", "4105209"]; var basicBot = { - version: "2.2.2", - status: false, - name: "basicBot", - loggedInID: null, - scriptLink: "https://rawgit.com/Yemasthui/basicBot/master/basicBot.js", - cmdLink: "http://git.io/245Ppg", - chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json", - chat: null, - loadChat: loadChat, - retrieveSettings: retrieveSettings, - retrieveFromStorage: retrieveFromStorage, - settings: { - botName: "basicBot", - language: "english", - chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json", - startupCap: 1, // 1-200 - startupVolume: 0, // 0-100 - startupEmoji: false, // true or false - maximumAfk: 120, - afkRemoval: true, - maximumDc: 60, - bouncerPlus: true, - blacklistEnabled: true, - lockdownEnabled: false, - lockGuard: false, - maximumLocktime: 10, - cycleGuard: true, - maximumCycletime: 10, - voteSkip: false, - voteSkipLimit: 10, - historySkip: true, - timeGuard: true, - maximumSongLength: 10, - autodisable: true, - commandCooldown: 30, - usercommandsEnabled: true, - lockskipPosition: 3, - lockskipReasons: [ + botName: "Lietuvos-Botas", + language: "english", + chatLink: "https://rawgit.com/mantas7779/basicBot/master/lang/lt.json", + maximumAfk: 10000000, + afkRemoval: false, + maximumDc: 120, + bouncerPlus: true, + lockdownEnabled: false, + lockGuard: false, + maximumLocktime: 10, + cycleGuard: false, + maximumCycletime: 10, + voteSkip: true, + voteSkipLimit: 15, + timeGuard: true, + maximumSongLength: 6.30, + autodisable: false, + commandCooldown: 30, + usercommandsEnabled: true, + lockskipPosition: 1, + lockskipReasons: [ ["theme", "This song does not fit the room theme. "], ["op", "This song is on the OP list. "], ["history", "This song is in the history. "], @@ -225,8 +208,8 @@ ["nsfw", "The song you contained was NSFW (image or sound). "], ["unavailable", "The song you played was not available for some users. "] ], - afkpositionCheck: 15, - afkRankCheck: "ambassador", + afkpositionCheck: null, + afkRankCheck: "user", motdEnabled: false, motdInterval: 5, motd: "Temporary Message of the Day", @@ -234,9 +217,9 @@ etaRestriction: false, welcome: true, opLink: null, - rulesLink: null, + rulesLink: http://prntscr.com/bb3yr8, themeLink: null, - fbLink: null, + fbLink: https://www.facebook.com/Už-Lietuvą-630256890371211, youtubeLink: null, website: null, intervalMessages: [], @@ -303,7 +286,7 @@ basicBot.room.roulette.rouletteStatus = true; basicBot.room.roulette.countdown = setTimeout(function () { basicBot.room.roulette.endRoulette(); - }, 60 * 1000); + }, 120 * 1000); API.sendChat(basicBot.chat.isopen); }, endRoulette: function () { @@ -317,7 +300,7 @@ API.sendChat(subChat(basicBot.chat.winnerpicked, {name: name, position: pos})); setTimeout(function (winner, pos) { basicBot.userUtilities.moveUser(winner, pos, false); - }, 1 * 1000, winner, pos); + }, 1 * 1, winner, pos); } } }, @@ -1052,10 +1035,10 @@ } else cmd = chat.message.substring(0, space); } - else return false; + else return false; var userPerm = basicBot.userUtilities.getPermission(chat.uid); //console.log("name: " + chat.un + ", perm: " + userPerm); - if (chat.message !== "!join" && chat.message !== "!leave") { + if (chat.message !== basicBot.settings.commandLiteral + 'play' && chat.message !== basicBot.settings.commandLiteral + "leave") { if (userPerm === 0 && !basicBot.room.usercommand) return void (0); if (!basicBot.room.allcommand) return void (0); } diff --git a/lang/en.json b/lang/en.json deleted file mode 100644 index 1c5ede60..00000000 --- a/lang/en.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - - "nodatafound": "No previous data found.", - "retrievingdata": "Retrieving previously stored data.", - "datarestored": "Previously stored data successfully retrieved.", - "greyuser": "Only bouncers and up can run a bot.", - "bouncer": "The bot can't move people when it's run as a bouncer.", - "online": "/me %%BOTNAME%% v%%VERSION%% online!", - - - "welcome": "/me Welcome %%NAME%%", - "welcomeback": "/me Welcome back, %%NAME%%", - "songknown": "/me @%%NAME%%, this song is in the DJ history.", - "timelimit": "/me @%%NAME%%, your song is longer than %%MAXLENGTH%% minutes, you need permission to play longer songs.", - "permissionownsong": "/me :up: @%%NAME%% has permission to play their own production!", - "isblacklisted": "/me This track is on the %%BLACKLIST%% blacklist! Skipping...", - - - "isopen": "/me The roulette is now open! Type !join to participate!", - "winnerpicked": "/me A winner has been picked! @%%NAME%% to position %%POSITION%%.", - - - "alreadyadding": "/me User is already being added! Changed the desired position to %%POSITION%%.", - "adding": "/me Added @%%NAME%% to the queue. Current queue: %%POSITION%%.", - - - "usernotfound": "/me User not found.", - "notdisconnected": "/me @%%NAME%% did not disconnect during my time here.", - "noposition": "/me No last position known. The waitlist needs to update at least once to register a user's last position.", - "toolongago": "/me @%%NAME%%'s last disconnect (DC or leave) was too long ago: %%TIME%%.", - "valid": "/me @%%NAME%% disconnected %%TIME%% ago and should be at position %%POSITION%%.", - - - "warning1": "/me @%%NAME%%, you have been afk for %%TIME%%, please respond within 2 minutes or you will be removed.", - "warning2": "/me @%%NAME%%, you will be removed due to AFK soon if you don't respond.", - "afkremove": "/me @%%NAME%%, you have been removed for being afk for %%TIME%%. You were at position %%POSITION%%. Chat at least once every %%MAXIMUMAFK%% minutes if you want to play a song.", - - - "caps": "/me @%%NAME%%, unglue your capslock button please.", - "askskip": "/me @%%NAME%%, don't ask for skips.", - "spam": "/me @%%NAME%%, please don't spam.", - "roomadvertising": "/me @%%NAME%%, don't post links to other rooms please.", - "adfly": "/me @%%NAME%%, please change your autowoot program. We suggest PlugCubed: http://plugcubed.net/", - - - "invalidtime": "/me [@%%NAME%%] Invalid time specified.", - "nouserspecified": "/me [@%%NAME%%] No user specified.", - "invaliduserspecified": "/me [@%%NAME%%] Invalid user specified.", - "nolistspecified": "/me [@%%NAME%%] No list specified.", - "invalidlistspecified": "/me [@%%NAME%%] Invalid list specified.", - "novaliduserspecified": "/me [@%%NAME%%] No valid user specified.", - "nolimitspecified": "/me [@%%NAME%%] No limit specified.", - "invalidlimitspecified": "/me [@%%NAME%%] Invalid limit.", - "invalidpositionspecified": "/me [@%%NAME%%] Invalid position specified.", - "toggleon": "/me [@%%NAME%%] %%FUNCTION%% enabled.", - "toggleoff": "/me [@%%NAME%%] %%FUNCTION%% disabled.", - "afkremoval": "AFK removal", - "afksremoved": "AFK's removed", - "afklimit": "AFK limit", - "autodisable": "autodisable", - "autoskip": "autoskip", - "newblacklisted": "/me [@%%NAME%%] This track belongs on the %%BLACKLIST%% blacklist! [ %%AUTHOR%% - %%TITLE%% - %%MID%% ]", - "blinfo": "[@%%NAME%%] Blacklist Info - author: %%AUTHOR%%, title: %%TITLE%%, mid: %%SONGID%%", - "blacklist": "blacklist", - "cycleguard": "cycleguard", - "timeguard": "timeguard", - "chatfilter": "chatfilter", - "historyskip": "historyskip", - "lockdown": "lockdown", - "lockguard": "lockguard", - "usercommands": "usercommands", - "motd": "MotD", - "welcomemsg": "welcome message", - "songstats": "song statistics", - "etarestriction": "eta restriction", - "voteskip": "voteskip", - "voteskiplimit": "/me [@%%NAME%%] Voteskip limit is currently set to %%LIMIT%% mehs.", - "voteskipexceededlimit": "/me @%%NAME%%, your song has exceeded the voteskip limit (%%LIMIT%% mehs).", - "voteskipinvalidlimit": "/me [@%%NAME%%] Invalid voteskip limit, please try again using a number to signify the number of mehs.", - "voteskipsetlimit": "/me [@%%NAME%%] Voteskip limit set to %%LIMIT%%.", - "activeusersintime": "/me [@%%NAME%% There have been %%AMOUNT%% users chatting in the past %%TIME%% minutes.", - "maximumafktimeset": "/me [@%%NAME%%] Maximum afk duration set to %%TIME%% minutes.", - "afkstatusreset": "/me [@%%NAME%%] Reset the afk status of @%%USERNAME%%.", - "inactivefor": "/me [@%%NAME%%] @%%USERNAME%% has been inactive for %%TIME%%.", - "autowoot": "/me We recommend PlugCubed for autowooting: http://plugcubed.net/", - "brandambassador": "/me A Brand Ambassador is the voice of the plug.dj users. They promote events, engage the community and share the plug.dj message around the world. For more info: https://plug.dj/ba", - "bouncerplusrank": "/me [@%%NAME%%] You have to be manager or up to enable Bouncer+.", - "chatcleared": "/me [@%%NAME%%] Cleared the chat.", - "deletechat": "/me [@%%NAME%%] Cleared the chat of %%USERNAME%%.", - "commandslink": "/me %%BOTNAME%% commands: %%LINK%%", - "eatcookie": "/me eats a cookie.", - "nousercookie": "/em doesn't see %%NAME%% in room and eats a cookie himself.", - "selfcookie": "/me @%%NAME%%, you're a bit greedy, aren't you? Giving cookies to yourself, bah. Share some with other people!", - "cookie": "/me @%%NAMETO%%, @%%NAMEFROM%% %%COOKIE%%", - "cycleguardtime": "/me [@%%NAME%%] The cycleguard is set to %%TIME%% minute(s).", - "dclookuprank": "/me [@%%NAME%%] Only bouncers and above can do a lookup for others.", - "emojilist": "/me Emoji list: %%LINK%%", - "notinwaitlist": "/me @%%NAME%%, you are not on the waitlist.", - "eta": "/me @%%NAME%% you will reach the booth in approximately %%TIME%%.", - "facebook": "/me Like us on facebook: %%LINK%%", - "starterhelp": "/me This image will get you started on plug: %%LINK%%", - "roulettejoin": "/me @%%NAME%% joined the roulette! (!leave if you regret it.)", - "jointime": "/me [@%%NAMEFROM%%] @%%USERNAME%% has been in the room for %%TIME%%.", - "kickrank": "/me [@%%NAME%%] you can't kick users with an equal or higher rank than you!", - "kick": "/me [@%%NAME%%], @%%USERNAME%% you are being kicked from the community for %%TIME%% minutes.", - "kill": "/me Shutting down.", - "rouletteleave": "/me @%%NAME%% left the roulette!", - "songlink": "/me [@%%NAME%%] Link to current song: %%LINK%%", - "usedlockskip": "/me [%%NAME%% used lockskip.]", - "lockskippos": "/me [@%%NAME%%] Lockskip will now move the dj to position %%POSITION%%.", - "lockguardtime": "/me [@%%NAME%%] The lockguard is set to %%TIME%% minute(s).", - "maxlengthtime": "/me [@%%NAME%%] The maximum song duration is set to %%TIME%% minutes.", - "motdset": "/me MotD set to: %%MSG%%", - "motdintervalset": "/me MotD interval set to %%INTERVAL%%.", - "addbotwaitlist": "/me @%%NAME%%, don't try to add me to the waitlist, please.", - "move": "/me [%%NAME%% used move.]", - "mutednotime": "/me [@%%NAME%%] Muted @%%USERNAME%%.", - "mutedmaxtime": "/me [@%%NAME%%] You can only mute for maximum %%TIME%% minutes.", - "mutedtime": "/me [@%%NAME%%] Muted @%%USERNAME%% for %%TIME%% minutes.", - "unmuted": "/me [@%%NAME%%] Unmuted @%%USERNAME%%.", - "muterank": "/me [@%%NAME%%] You can't mute persons with an equal or higher rank than you.", - "oplist": "/me OP list: %%LINK%%", - "pong": "/me Pong!", - "reload": "/me Be right back.", - "removenotinwl": "/me [@%%NAME%%] Specified user @%%USERNAME%% is not in the waitlist.", - "roomrules": "/me Please find the room rules here: %%LINK%%", - "sessionstats": "/me [@%%NAME%%] Total woots: %%WOOTS%%, total mehs: %%MEHS%%, total grabs: %%GRABS%%.", - "skip": "/me [%%NAME%% used skip.]", - "madeby": "/me This bot was made by %%NAME%%.", - "activefor": "I have been active for %%TIME%%.", - "swapinvalid": "/me [@%%NAME%%] Invalid user specified. (No names with spaces!)", - "swapwlonly": "/me [@%%NAME%%] Please only swap users that are in the waitlist!", - "swapping": "/me Swapping %%NAME1%% with %%NAME2%%.", - "genres": "/me Please find the permissible room genres here: %%LINK%%", - "notbanned": "/me [@%%NAME%%] The user was not banned.", - "unmutedeveryone": "/me [@%%NAME%%] Unmuted everyone.", - "unmuteeveryonerank": "/me [@%%NAME%%] Only managers and up can unmute everyone at once.", - "notmuted": "/me [@%%NAME%%] that user wasn't muted.", - "unmuterank": "/me [@%%NAME%%] You can't unmute persons with an equal or higher rank than you.", - "commandscd": "/me [@%%NAME%%] The cooldown for commands by users is now set to %%TIME%% seconds.", - "voteratio": "/me [@%%NAME%%] @%%USERNAME%% ~ woots: %%WOOT%%, mehs: %%MEHS%%, ratio (w/m): %%RATIO%%.", - "website": "/me Please visit our website: %%LINK%%", - "youtube": "/me [%%NAME%%] Subscribe to us on youtube: %%LINK%%", - "songstatistics": "/me %%ARTIST%% - %%TITLE%%: %%WOOTS%%W/%%GRABS%%G/%%MEHS%%M." -} diff --git a/lang/lt.json b/lang/lt.json new file mode 100644 index 00000000..81e57fa7 --- /dev/null +++ b/lang/lt.json @@ -0,0 +1,145 @@ +{ + + "nodatafound": "Ankstesni nustatymai nerasti.", + "retrievingdata": "Atkuriami ankčiau nustatyti nustatymai.", + "datarestored": "Anksčiau nustatyti nustatymai atkurti sėkmingai.", + "greyuser": "Tik bounceriai ar aukštesni pareigose gali mane įjungti.", + "bouncer": "Botas negali keisti vartotojų pozicijų kai jis paleistas bouncerio.", + "online": "/me %%BOTNAME%% aktyvus!", + + + "welcome": "/me Sveikas atvykęs į LIETUVĄ @%%NAME%% Įsipūsk į save geros nuotaikos, bei įvairių hitų dozės! Nebijok bendrauti su visais, nes čia renkasi tik draugiškiausi žmonės. Gero klausymo!", + "welcomeback": "/me @%%NAME%% Sveiki sugrįžę į Už Lietuvą muzikos kambarį! :)", + "songknown": "/me @%%NAME%%, daina jau yra grojusi.", + "timelimit": "/me @%%NAME%%, Jūsų daina buvo ilgesnė nei %%MAXLENGTH%% minutės.", + "permissionownsong": "/me :up: @%%NAME%% turi teisę groti savo muziką!", + "isblacklisted": "/me Ši daina yra draudžiama %%BLACKLIST%% ! Perjungiama...", + + + "isopen": "/me Ruletė paleista! Rašykite !join kad dalyvautumėte!", + "winnerpicked": "/me :white_check_mark: Laimėtojas išrinktas! @%%NAME%% perkeltas į %%POSITION%% vietą.", + + + "alreadyadding": "/me Vartotjas jau pridėtas! Dabartinė vieta: %%POSITION%%.", + "adding": "/me Pridėjo @%%NAME%% į eilę. Dabartinė vieta: %%POSITION%%.", + + + "usernotfound": "/me Vartotojas nerastas.", + "notdisconnected": "/me @%%NAME%% nebuvote atsijungęs kol aš buvau paleistas.", + "noposition": "/me Paskutinė vieta eilėje nežinoma.", + "toolongago": "/me @%%NAME%%'s Paskutinis atsijungimas buvo per senai: %%TIME%%.", + "valid": "/me @%%NAME%% atsijungė prieš %%TIME%% ir dabar turėtų būti %%POSITION%% vietoje.", + + + "warning1": "/me @%%NAME%%, Jūs buvote neaktyvus %%TIME%%, Prašome atsiliepti per 2 minutes arba būsite pašalinti.", + "warning2": "/me @%%NAME%%, Jūs greitu metu būsite pašalintas dėl neaktyvumo!", + "afkremove": "/me @%%NAME%%, Jūs buvote pašalintas, nes buvo neaktyvus %%TIME%%. Buvote eilėje %%POSITION%%. Rašykite žinutes mažiausiai %%MAXIMUMAFK%% minučių intervalu jei norite paleisti savo dainą.", + + + "caps": "/me @%%NAME%%, išjunkite Caps Lock mygtuką!", + "askskip": "/me @%%NAME%%, Neprašinėk perjungti dainą.", + "spam": "/me @%%NAME%%, Nespamink.", + "roomadvertising": "/me @%%NAME%%, Neplatink kitų kambarių nuorodų!", + "adfly": "/me @%%NAME%%, Pakeiskite autowoot programą.Mes rekomenduojame naudoti RCS: https://rcs.radiant.dj/", + + + "invalidtime": "/me [@%%NAME%%] Nurodytas netinkamas laikas.", + "nouserspecified": "/me [@%%NAME%%] Nenurodytas vartotojas", + "invaliduserspecified": "/me [@%%NAME%%] Nurodytas netinkamas vartotojas.", + "nolistspecified": "/me [@%%NAME%%] Nenurodytas sąrašas.", + "invalidlistspecified": "/me [@%%NAME%%] Blogai nurodytas sąrašas.", + "novaliduserspecified": "/me [@%%NAME%%] Nenurodytas tinkamas vartotojas.", + "nolimitspecified": "/me [@%%NAME%%] Nenurodytas limitas.", + "invalidlimitspecified": "/me [@%%NAME%%] Blogai nurodytas limitas.", + "invalidpositionspecified": "/me [@%%NAME%%] Blogai nurodyta vieta.", + "toggleon": "/me [@%%NAME%%] %%FUNCTION%% įjungta.", + "toggleoff": "/me [@%%NAME%%] %%FUNCTION%% išjungta.", + "afkremoval": "Neaktyvių varototojų šalinimas", + "afksremoved": "Neaktyvūs vartotojai pašalinti", + "afklimit": "Neaktyvumo laiko limitas", + "autodisable": "Automatinio prisijungimo blokavimas", + "autoskip": "Automatinis dainų pakeitimas", + "newblacklisted": "/me [@%%NAME%%] Ši daina yra įtraukta į %%BLACKLIST%% sąrašą! [ %%AUTHOR%% - %%TITLE%% - %%MID%% ]", + "blinfo": "[@%%NAME%%] Juodojo sąrašo informacija - atlikėjas: %%AUTHOR%%, pavadinimas: %%TITLE%%, ID: %%SONGID%%", + "blacklist": "Juodasis sąrašas", + "cycleguard": "Ciklo apsauga", + "timeguard": "Laiko apsauga", + "chatfilter": "Chat`o apsauga", + "historyskip": "Pasikartojančių dainų skipinimas", + "lockdown": "Užrakinimas", + "lockguard": "Užrakinimo apsauga", + "usercommands": "Vartotojų komandos", + "motd": "MotD", + "welcomemsg": "Pasisveikinimo žinutė", + "songstats": "Dainos statistika", + "etarestriction": "eta apribojimas", + "voteskip": "Balsavimas norint praleisti dainą", + "voteskiplimit": "/me [@%%NAME%%] Balsų limitas dabar: %%LIMIT%% meh.", + "voteskipexceededlimit": "/me @%%NAME%%, Jūsų daina peržengė nustatytą meh skaičių (%%LIMIT%% mehs).", + "voteskipinvalidlimit": "/me [@%%NAME%%] Neteisingai nurodytas limitas.", + "voteskipsetlimit": "/me [@%%NAME%%] Balsų limitas nustatytas į %%LIMIT%%.", + "activeusersintime": "/me [@%%NAME%% Užfiksavau %%AMOUNT%% vartotojų kalbėjusiu per paskutinę(s) %%TIME%% minutes.", + "maximumafktimeset": "/me [@%%NAME%%] Maksimalus AFK laikas pakeistas į %%TIME%% minutes.", + "afkstatusreset": "/me [@%%NAME%%] Nustatyti aktyvumo laiką iš naujo @%%USERNAME%%.", + "inactivefor": "/me [@%%NAME%%] @%%USERNAME%% buvo neaktyvus %%TIME%%.", + "autowoot": "/me Mes rekomenduojame RCS autowoot`ą: https://rcs.radiant.dj", + "brandambassador": "/me Ambasadorius yra plug.dj vartotojų balsas.Daugiau informacijos: https://plug.dj/ba", + "bouncerplusrank": "/me [@%%NAME%%] Turite būti manageris ar aukštesnis kad galėtumėte įjungti Bouncer+.", + "chatcleared": "/me [@%%NAME%%] Išvalė chat`ą.", + "deletechat": "/me [@%%NAME%%] Išvalė %%USERNAME%% žinutes.", + "commandslink": "/me %%BOTNAME%% komandos: %%LINK%%", + "eatcookie": "/me valgo sausainį.", + "nousercookie": "/em nerado vartotojo %%NAME%% kambaryje todėl suvalgė sausainį pats.", + "selfcookie": "/me @%%NAME%%, Tu esi per gobšus ar ne? Duodi sausainius tik sau... Pasidalink jais su kitais!", + "cookie": "/me @%%NAMETO%%, @%%NAMEFROM%% %%COOKIE%%", + "cycleguardtime": "/me [@%%NAME%%] Ciklo apsauga nustatyta %%TIME%% minutėms.", + "dclookuprank": "/me [@%%NAME%%] Tik bounceriai ar aukštesni gali naudoti komandą lookup", + "emojilist": "/me Emoji sąrašas: %%LINK%%", + "notinwaitlist": "/me @%%NAME%%, Jūs nesate eilėje.", + "eta": "/me @%%NAME%% Jūs grosite po: %%TIME%%.", + "facebook": "/me Prisijunkite prie mūsų Facebook`e: %%LINK%%", + "starterhelp": "/me Komandos: http://prntscr.com/brmw04", + "roulettejoin": "/me @%%NAME%% Dalyvaujate ruletės žaidime! (rašykite !leave norėdami išeiti.)", + "jointime": "/me [@%%NAMEFROM%%] @%%USERNAME%% vartotojas buvo kambaryje %%TIME%%.", + "kickrank": "/me [@%%NAME%%] Jūs negalite išmesti vartotojų kurie turi aukštesnes pareigas negu Jūs!", + "kick": "/me [@%%NAME%%], @%%USERNAME%% Jūs buvote išspirtas iš kambario %%TIME%% minutėms.", + "kill": "/me Išjungiamos visos sistemos.", + "rouletteleave": "/me @%%NAME%% paliko ruletės žaidimą!", + "songlink": "/me [@%%NAME%%] Dabartinės dainos nuoroda: %%LINK%%", + "usedlockskip": "/me [%%NAME%% aktyvavo lockskip komandą.]", + "lockskippos": "/me [@%%NAME%%] Lockskip dabar perkels Dj į šią poziciją: %%POSITION%%.", + "lockguardtime": "/me [@%%NAME%%] Apsauga nustatyta %%TIME%% minute(s).", + "maxlengthtime": "/me [@%%NAME%%] The maximum song duration is set to %%TIME%% minutes.", + "motdset": "/me MotD Pakeista į: %%MSG%%", + "motdintervalset": "/me MotD intervalas: %%INTERVAL%%.", + "addbotwaitlist": "/me @%%NAME%%, nebandyk pridėti manęs į waitlist`ą.", + "move": "/me [%%NAME%% used move.]", + "mutednotime": "/me [@%%NAME%%] užtildė @%%USERNAME%%.", + "mutedmaxtime": "/me [@%%NAME%%] Jūs galite užmutinti maksimaliai %%TIME%% minutėms.", + "mutedtime": "/me [@%%NAME%%] užtildė @%%USERNAME%% %%TIME%% minutėms.", + "unmuted": "/me [@%%NAME%%] leido rašyti @%%USERNAME%%.", + "muterank": "/me [@%%NAME%%] Negalite užtildyti vartotojų turinčių tokias pat ar aukštesnes pareigas.", + "oplist": "/me OP sąrašas: %%LINK%%", + "pong": "/me Pong!", + "reload": "/me Tuoj būsiu eteryje.", + "removenotinwl": "/me [@%%NAME%%] Nurodytas vartotojas @%%USERNAME%% nėra waitlist`e.", + "roomrules": "/me Kambario taisyklės: %%LINK%%", + "sessionstats": "/me [@%%NAME%%] Statistika woots: %%WOOTS%%, viso meh: %%MEHS%%, viso grabs: %%GRABS%%.", + "skip": "/me [%%NAME%% praleido eilę.]", + "madeby": "/me Šis botas buvo sukurtas %%NAME%%.", + "activefor": "Aš buvau įjungtas %%TIME%%.", + "swapinvalid": "/me [@%%NAME%%] Nurodytas netinkamas vartotojas.", + "swapwlonly": "/me [@%%NAME%%] Keiskite pozicijas tik vartotojų esančių waitlist`e!", + "swapping": "/me %%NAME1%% Keičiasi su %%NAME2%%.", + "genres": "/me Leidžiamus groti žanrus rasite čia:: %%LINK%%", + "notbanned": "/me [@%%NAME%%] Vartotojas nebuvo užblokuotas.", + "unmutedeveryone": "/me [@%%NAME%%] Visi gali rašyti.", + "unmuteeveryonerank": "/me [@%%NAME%%] Tik manageriai ir aukštesni pareigose gali nuimti nutildymą visiems lankytojams iškarto.", + "notmuted": "/me [@%%NAME%%] šis vartotojas nebuvo nutildytas.", + "unmuterank": "/me [@%%NAME%%] Jūs negalite leisti vėl rašyti vartotojams turintiems tokias pat ar aukštesnes pareigas.", + "commandscd": "/me [@%%NAME%%] Komandų naudojimas paprastiems vartotojams apribotas iki: %%TIME%% sekundžių.", + "voteratio": "/me [@%%NAME%%] @%%USERNAME%% ~ woots: %%WOOT%%, mehs: %%MEHS%%, ratingas (w/m): %%RATIO%%.", + "website": "/me Aplankykite mūsų svetainę adresu: %%LINK%%", + "youtube": "/me [%%NAME%%] Prenumeruokite mus youtube: %%LINK%%", + "songstatistics": "/me %%ARTIST%% - %%TITLE%%: %%WOOTS%%W/%%GRABS%%G/%%MEHS%%M." +} diff --git a/main.js b/main.js new file mode 100644 index 00000000..804ef6a7 --- /dev/null +++ b/main.js @@ -0,0 +1,3052 @@ +/** + *Copyright 2014 Yemasthui + *Modifications (including forks) of the code to fit personal needs are allowed only for personal use and should refer back to the original source. + *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. + */ + + +(function () { + + API.getWaitListPosition = function(id){ + if(typeof id === 'undefined' || id === null){ + id = API.getUser().id; + } + var wl = API.getWaitList(); + for(var i = 0; i < wl.length; i++){ + if(wl[i].id === id){ + return i; + } + } + return -1; + }; + + var kill = function () { + clearInterval(basicBot.room.autodisableInterval); + clearInterval(basicBot.room.afkInterval); + basicBot.status = false; + }; + + var storeToStorage = function () { + localStorage.setItem("basicBotsettings", JSON.stringify(basicBot.settings)); + localStorage.setItem("basicBotRoom", JSON.stringify(basicBot.room)); + var basicBotStorageInfo = { + time: Date.now(), + stored: true, + version: basicBot.version + }; + localStorage.setItem("basicBotStorageInfo", JSON.stringify(basicBotStorageInfo)); + + }; + + var subChat = function (chat, obj) { + if (typeof chat === "undefined") { + API.chatLog("There is a chat text missing."); + console.log("There is a chat text missing."); + return "[Error] No text message found."; + } + var lit = '%%'; + for (var prop in obj) { + chat = chat.replace(lit + prop.toUpperCase() + lit, obj[prop]); + } + return chat; + }; + + var loadChat = function (cb) { + if (!cb) cb = function () { + }; + $.get("https://rawgit.com/Yemasthui/basicBot/master/lang/langIndex.json", function (json) { + var link = basicBot.chatLink; + if (json !== null && typeof json !== "undefined") { + langIndex = json; + link = langIndex[basicBot.settings.language.toLowerCase()]; + if (basicBot.settings.chatLink !== basicBot.chatLink) { + link = basicBot.settings.chatLink; + } + else { + if (typeof link === "undefined") { + link = basicBot.chatLink; + } + } + $.get(link, function (json) { + if (json !== null && typeof json !== "undefined") { + if (typeof json === "string") json = JSON.parse(json); + basicBot.chat = json; + cb(); + } + }); + } + else { + $.get(basicBot.chatLink, function (json) { + if (json !== null && typeof json !== "undefined") { + if (typeof json === "string") json = JSON.parse(json); + basicBot.chat = json; + cb(); + } + }); + } + }); + }; + + var retrieveSettings = function () { + var settings = JSON.parse(localStorage.getItem("basicBotsettings")); + if (settings !== null) { + for (var prop in settings) { + basicBot.settings[prop] = settings[prop]; + } + } + }; + + var retrieveFromStorage = function () { + var info = localStorage.getItem("basicBotStorageInfo"); + if (info === null) API.chatLog(basicBot.chat.nodatafound); + else { + var settings = JSON.parse(localStorage.getItem("basicBotsettings")); + var room = JSON.parse(localStorage.getItem("basicBotRoom")); + var elapsed = Date.now() - JSON.parse(info).time; + if ((elapsed < 1 * 60 * 60 * 1000)) { + API.chatLog(basicBot.chat.retrievingdata); + for (var prop in settings) { + basicBot.settings[prop] = settings[prop]; + } + basicBot.room.users = room.users; + basicBot.room.afkList = room.afkList; + basicBot.room.historyList = room.historyList; + basicBot.room.mutedUsers = room.mutedUsers; + basicBot.room.autoskip = room.autoskip; + basicBot.room.roomstats = room.roomstats; + basicBot.room.messages = room.messages; + basicBot.room.queue = room.queue; + basicBot.room.newBlacklisted = room.newBlacklisted; + API.chatLog(basicBot.chat.datarestored); + } + } + /*var json_sett = null; + var roominfo = document.getElementById("room-info"); + info = roominfo.textContent; + var ref_bot = "@basicBot="; + var ind_ref = info.indexOf(ref_bot); + if (ind_ref > 0) { + var link = info.substring(ind_ref + ref_bot.length, info.length); + var ind_space = null; + if (link.indexOf(" ") < link.indexOf("\n")) ind_space = link.indexOf(" "); + else ind_space = link.indexOf("\n"); + link = link.substring(0, ind_space); + $.get(link, function (json) { + if (json !== null && typeof json !== "undefined") { + json_sett = JSON.parse(json); + for (var prop in json_sett) { + basicBot.settings[prop] = json_sett[prop]; + } + } + }); + }*/ + + }; + + String.prototype.splitBetween = function (a, b) { + var self = this; + self = this.split(a); + for (var i = 0; i < self.length; i++) { + self[i] = self[i].split(b); + } + var arr = []; + for (var i = 0; i < self.length; i++) { + if (Array.isArray(self[i])) { + for (var j = 0; j < self[i].length; j++) { + arr.push(self[i][j]); + } + } + else arr.push(self[i]); + } + return arr; + }; + + var linkFixer = function (msg) { + var parts = msg.splitBetween(' -1) return 10; + } + if (u.gRole < 2) return u.role; + else { + switch (u.gRole) { + case 2: + return 7; + case 3: + return 8; + case 4: + return 9; + case 5: + return 10; + } + } + return 0; + }, + moveUser: function (id, pos, priority) { + var user = basicBot.userUtilities.lookupUser(id); + var wlist = API.getWaitList(); + if (API.getWaitListPosition(id) === -1) { + if (wlist.length < 50) { + API.moderateAddDJ(id); + if (pos !== 0) setTimeout(function (id, pos) { + API.moderateMoveDJ(id, pos); + }, 1250, id, pos); + } + else { + var alreadyQueued = -1; + for (var i = 0; i < basicBot.room.queue.id.length; i++) { + if (basicBot.room.queue.id[i] === id) alreadyQueued = i; + } + if (alreadyQueued !== -1) { + basicBot.room.queue.position[alreadyQueued] = pos; + return API.sendChat(subChat(basicBot.chat.alreadyadding, {position: basicBot.room.queue.position[alreadyQueued]})); + } + basicBot.roomUtilities.booth.lockBooth(); + if (priority) { + basicBot.room.queue.id.unshift(id); + basicBot.room.queue.position.unshift(pos); + } + else { + basicBot.room.queue.id.push(id); + basicBot.room.queue.position.push(pos); + } + var name = user.username; + return API.sendChat(subChat(basicBot.chat.adding, {name: name, position: basicBot.room.queue.position.length})); + } + } + else API.moderateMoveDJ(id, pos); + }, + dclookup: function (id) { + var user = basicBot.userUtilities.lookupUser(id); + if (typeof user === 'boolean') return basicBot.chat.usernotfound; + var name = user.username; + if (user.lastDC.time === null) return subChat(basicBot.chat.notdisconnected, {name: name}); + var dc = user.lastDC.time; + var pos = user.lastDC.position; + if (pos === null) return basicBot.chat.noposition; + var timeDc = Date.now() - dc; + var validDC = false; + if (basicBot.settings.maximumDc * 60 * 1000 > timeDc) { + validDC = true; + } + var time = basicBot.roomUtilities.msToStr(timeDc); + if (!validDC) return (subChat(basicBot.chat.toolongago, {name: basicBot.userUtilities.getUser(user).username, time: time})); + var songsPassed = basicBot.room.roomstats.songCount - user.lastDC.songCount; + var afksRemoved = 0; + var afkList = basicBot.room.afkList; + for (var i = 0; i < afkList.length; i++) { + var timeAfk = afkList[i][1]; + var posAfk = afkList[i][2]; + if (dc < timeAfk && posAfk < pos) { + afksRemoved++; + } + } + var newPosition = user.lastDC.position - songsPassed - afksRemoved; + if (newPosition <= 0) newPosition = 1; + var msg = subChat(basicBot.chat.valid, {name: basicBot.userUtilities.getUser(user).username, time: time, position: newPosition}); + basicBot.userUtilities.moveUser(user.id, newPosition, true); + return msg; + } + }, + + roomUtilities: { + rankToNumber: function (rankString) { + var rankInt = null; + switch (rankString) { + case "admin": + rankInt = 10; + break; + case "ambassador": + rankInt = 7; + break; + case "host": + rankInt = 5; + break; + case "cohost": + rankInt = 4; + break; + case "manager": + rankInt = 3; + break; + case "bouncer": + rankInt = 2; + break; + case "residentdj": + rankInt = 1; + break; + case "user": + rankInt = 0; + break; + } + return rankInt; + }, + msToStr: function (msTime) { + var ms, msg, timeAway; + msg = ''; + timeAway = { + 'days': 0, + 'hours': 0, + 'minutes': 0, + 'seconds': 0 + }; + ms = { + 'day': 24 * 60 * 60 * 1000, + 'hour': 60 * 60 * 1000, + 'minute': 60 * 1000, + 'second': 1000 + }; + if (msTime > ms.day) { + timeAway.days = Math.floor(msTime / ms.day); + msTime = msTime % ms.day; + } + if (msTime > ms.hour) { + timeAway.hours = Math.floor(msTime / ms.hour); + msTime = msTime % ms.hour; + } + if (msTime > ms.minute) { + timeAway.minutes = Math.floor(msTime / ms.minute); + msTime = msTime % ms.minute; + } + if (msTime > ms.second) { + timeAway.seconds = Math.floor(msTime / ms.second); + } + if (timeAway.days !== 0) { + msg += timeAway.days.toString() + 'd'; + } + if (timeAway.hours !== 0) { + msg += timeAway.hours.toString() + 'h'; + } + if (timeAway.minutes !== 0) { + msg += timeAway.minutes.toString() + 'm'; + } + if (timeAway.minutes < 1 && timeAway.hours < 1 && timeAway.days < 1) { + msg += timeAway.seconds.toString() + 's'; + } + if (msg !== '') { + return msg; + } else { + return false; + } + }, + booth: { + lockTimer: setTimeout(function () { + }, 1000), + locked: false, + lockBooth: function () { + API.moderateLockWaitList(!basicBot.roomUtilities.booth.locked); + basicBot.roomUtilities.booth.locked = false; + if (basicBot.settings.lockGuard) { + basicBot.roomUtilities.booth.lockTimer = setTimeout(function () { + API.moderateLockWaitList(basicBot.roomUtilities.booth.locked); + }, basicBot.settings.maximumLocktime * 60 * 1000); + } + }, + unlockBooth: function () { + API.moderateLockWaitList(basicBot.roomUtilities.booth.locked); + clearTimeout(basicBot.roomUtilities.booth.lockTimer); + } + }, + afkCheck: function () { + if (!basicBot.status || !basicBot.settings.afkRemoval) return void (0); + var rank = basicBot.roomUtilities.rankToNumber(basicBot.settings.afkRankCheck); + var djlist = API.getWaitList(); + var lastPos = Math.min(djlist.length, basicBot.settings.afkpositionCheck); + if (lastPos - 1 > djlist.length) return void (0); + for (var i = 0; i < lastPos; i++) { + if (typeof djlist[i] !== 'undefined') { + var id = djlist[i].id; + var user = basicBot.userUtilities.lookupUser(id); + if (typeof user !== 'boolean') { + var plugUser = basicBot.userUtilities.getUser(user); + if (rank !== null && basicBot.userUtilities.getPermission(plugUser) <= rank) { + var name = plugUser.username; + var lastActive = basicBot.userUtilities.getLastActivity(user); + var inactivity = Date.now() - lastActive; + var time = basicBot.roomUtilities.msToStr(inactivity); + var warncount = user.afkWarningCount; + if (inactivity > basicBot.settings.maximumAfk * 60 * 1000) { + if (warncount === 0) { + API.sendChat(subChat(basicBot.chat.warning1, {name: name, time: time})); + user.afkWarningCount = 3; + user.afkCountdown = setTimeout(function (userToChange) { + userToChange.afkWarningCount = 1; + }, 90 * 1000, user); + } + else if (warncount === 1) { + API.sendChat(subChat(basicBot.chat.warning2, {name: name})); + user.afkWarningCount = 3; + user.afkCountdown = setTimeout(function (userToChange) { + userToChange.afkWarningCount = 2; + }, 30 * 1000, user); + } + else if (warncount === 2) { + var pos = API.getWaitListPosition(id); + if (pos !== -1) { + pos++; + basicBot.room.afkList.push([id, Date.now(), pos]); + user.lastDC = { + + time: null, + position: null, + songCount: 0 + }; + API.moderateRemoveDJ(id); + API.sendChat(subChat(basicBot.chat.afkremove, {name: name, time: time, position: pos, maximumafk: basicBot.settings.maximumAfk})); + } + user.afkWarningCount = 0; + } + } + } + } + } + } + }, + changeDJCycle: function () { + var toggle = $(".cycle-toggle"); + if (toggle.hasClass("disabled")) { + toggle.click(); + if (basicBot.settings.cycleGuard) { + basicBot.room.cycleTimer = setTimeout(function () { + if (toggle.hasClass("enabled")) toggle.click(); + }, basicBot.settings.cycleMaxTime * 60 * 1000); + } + } + else { + toggle.click(); + clearTimeout(basicBot.room.cycleTimer); + } + }, + intervalMessage: function () { + var interval; + if (basicBot.settings.motdEnabled) interval = basicBot.settings.motdInterval; + else interval = basicBot.settings.messageInterval; + if ((basicBot.room.roomstats.songCount % interval) === 0 && basicBot.status) { + var msg; + if (basicBot.settings.motdEnabled) { + msg = basicBot.settings.motd; + } + else { + if (basicBot.settings.intervalMessages.length === 0) return void (0); + var messageNumber = basicBot.room.roomstats.songCount % basicBot.settings.intervalMessages.length; + msg = basicBot.settings.intervalMessages[messageNumber]; + } + API.sendChat('/me ' + msg); + } + }, + updateBlacklists: function () { + for (var bl in basicBot.settings.blacklists) { + basicBot.room.blacklists[bl] = []; + if (typeof basicBot.settings.blacklists[bl] === 'function') { + basicBot.room.blacklists[bl] = basicBot.settings.blacklists(); + } + else if (typeof basicBot.settings.blacklists[bl] === 'string') { + if (basicBot.settings.blacklists[bl] === '') { + continue; + } + try { + (function (l) { + $.get(basicBot.settings.blacklists[l], function (data) { + if (typeof data === 'string') { + data = JSON.parse(data); + } + var list = []; + for (var prop in data) { + if (typeof data[prop].mid !== 'undefined') { + list.push(data[prop].mid); + } + } + basicBot.room.blacklists[l] = list; + }) + })(bl); + } + catch (e) { + API.chatLog('Error setting' + bl + 'blacklist.'); + console.log('Error setting' + bl + 'blacklist.'); + console.log(e); + } + } + } + }, + logNewBlacklistedSongs: function () { + if (typeof console.table !== 'undefined') { + console.table(basicBot.room.newBlacklisted); + } + else { + console.log(basicBot.room.newBlacklisted); + } + }, + exportNewBlacklistedSongs: function () { + var list = {}; + for (var i = 0; i < basicBot.room.newBlacklisted.length; i++) { + var track = basicBot.room.newBlacklisted[i]; + list[track.list] = []; + list[track.list].push({ + title: track.title, + author: track.author, + mid: track.mid + }); + } + return list; + } + }, + eventChat: function (chat) { + chat.message = linkFixer(chat.message); + chat.message = chat.message.trim(); + for (var i = 0; i < basicBot.room.users.length; i++) { + if (basicBot.room.users[i].id === chat.uid) { + basicBot.userUtilities.setLastActivity(basicBot.room.users[i]); + if (basicBot.room.users[i].username !== chat.un) { + basicBot.room.users[i].username = chat.un; + } + } + } + if (basicBot.chatUtilities.chatFilter(chat)) return void (0); + if (!basicBot.chatUtilities.commandCheck(chat)) + basicBot.chatUtilities.action(chat); + }, + eventUserjoin: function (user) { + var known = false; + var index = null; + for (var i = 0; i < basicBot.room.users.length; i++) { + if (basicBot.room.users[i].id === user.id) { + known = true; + index = i; + } + } + var greet = true; + var welcomeback = null; + if (known) { + basicBot.room.users[index].inRoom = true; + var u = basicBot.userUtilities.lookupUser(user.id); + var jt = u.jointime; + var t = Date.now() - jt; + if (t < 10 * 1000) greet = false; + else welcomeback = true; + } + else { + basicBot.room.users.push(new basicBot.User(user.id, user.username)); + welcomeback = false; + } + for (var j = 0; j < basicBot.room.users.length; j++) { + if (basicBot.userUtilities.getUser(basicBot.room.users[j]).id === user.id) { + basicBot.userUtilities.setLastActivity(basicBot.room.users[j]); + basicBot.room.users[j].jointime = Date.now(); + } + + } + if (basicBot.settings.welcome && greet) { + welcomeback ? + setTimeout(function (user) { + API.sendChat(subChat(basicBot.chat.welcomeback, {name: user.username})); + }, 1 * 1000, user) + : + setTimeout(function (user) { + API.sendChat(subChat(basicBot.chat.welcome, {name: user.username})); + }, 1 * 1000, user); + } + }, + eventUserleave: function (user) { + for (var i = 0; i < basicBot.room.users.length; i++) { + if (basicBot.room.users[i].id === user.id) { + basicBot.userUtilities.updateDC(basicBot.room.users[i]); + basicBot.room.users[i].inRoom = false; + } + } + }, + eventVoteupdate: function (obj) { + for (var i = 0; i < basicBot.room.users.length; i++) { + if (basicBot.room.users[i].id === obj.user.id) { + if (obj.vote === 1) { + basicBot.room.users[i].votes.woot++; + } + else { + basicBot.room.users[i].votes.meh++; + } + } + } + + var mehs = API.getScore().negative; + var woots = API.getScore().positive; + var dj = API.getDJ(); + + if (basicBot.settings.voteSkip) { + if ((mehs - woots) >= (basicBot.settings.voteSkipLimit)) { + API.sendChat(subChat(basicBot.chat.voteskipexceededlimit, {name: dj.username, limit: basicBot.settings.voteSkipLimit})); + API.moderateForceSkip(); + } + } + + }, + eventCurateupdate: function (obj) { + for (var i = 0; i < basicBot.room.users.length; i++) { + if (basicBot.room.users[i].id === obj.user.id) { + basicBot.room.users[i].votes.curate++; + } + } + }, + eventDjadvance: function (obj) { + $("#woot").click(); + var user = basicBot.userUtilities.lookupUser(obj.dj.id) + for(var i = 0; i < basicBot.room.users.length; i++){ + if(basicBot.room.users[i].id === user.id){ + basicBot.room.users[i].lastDC = { + time: null, + position: null, + songCount: 0 + }; + } + } + + var lastplay = obj.lastPlay; + if (typeof lastplay === 'undefined') return; + if (basicBot.settings.songstats) { + if (typeof basicBot.chat.songstatistics === "undefined") { + API.sendChat("/me " + lastplay.media.author + " - " + lastplay.media.title + ": " + lastplay.score.positive + "W/" + lastplay.score.grabs + "G/" + lastplay.score.negative + "M.") + } + else { + 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})) + } + } + basicBot.room.roomstats.totalWoots += lastplay.score.positive; + basicBot.room.roomstats.totalMehs += lastplay.score.negative; + basicBot.room.roomstats.totalCurates += lastplay.score.grabs; + basicBot.room.roomstats.songCount++; + basicBot.roomUtilities.intervalMessage(); + basicBot.room.currentDJID = obj.dj.id; + + var mid = obj.media.format + ':' + obj.media.cid; + for (var bl in basicBot.room.blacklists) { + if (basicBot.settings.blacklistEnabled) { + if (basicBot.room.blacklists[bl].indexOf(mid) > -1) { + API.sendChat(subChat(basicBot.chat.isblacklisted, {blacklist: bl})); + return API.moderateForceSkip(); + } + } + } + + /*var alreadyPlayed = false; + for (var i = 0; i < basicBot.room.historyList.length; i++) { + if (basicBot.room.historyList[i][0] === obj.media.cid) { + var firstPlayed = basicBot.room.historyList[i][1]; + var plays = basicBot.room.historyList[i].length - 1; + var lastPlayed = basicBot.room.historyList[i][plays]; + API.sendChat(subChat(basicBot.chat.songknown, {plays: plays, timetotal: basicBot.roomUtilities.msToStr(Date.now() - firstPlayed), lasttime: basicBot.roomUtilities.msToStr(Date.now() - lastPlayed)})); + basicBot.room.historyList[i].push(+new Date()); + alreadyPlayed = true; + } + } + if (!alreadyPlayed) { + basicBot.room.historyList.push([obj.media.cid, +new Date()]); + }*/ + + if (basicBot.settings.historySkip) { + var alreadyPlayed = false; + var apihistory = API.getHistory(); + var name = obj.dj.username; + for (var i = 0; i < apihistory.length; i++) { + if (apihistory[i].media.cid === obj.media.cid) { + API.sendChat(subChat(basicBot.chat.songknown, {name: name})); + API.moderateForceSkip(); + basicBot.room.historyList[i].push(+new Date()); + alreadyPlayed = true; + } + } + if (!alreadyPlayed) { + basicBot.room.historyList.push([obj.media.cid, +new Date()]); + } + } + var newMedia = obj.media; + if (basicBot.settings.timeGuard && newMedia.duration > basicBot.settings.maximumSongLength * 60 && !basicBot.room.roomevent) { + var name = obj.dj.username; + API.sendChat(subChat(basicBot.chat.timelimit, {name: name, maxlength: basicBot.settings.maximumSongLength})); + API.moderateForceSkip(); + } + if (user.ownSong) { + API.sendChat(subChat(basicBot.chat.permissionownsong, {name: user.username})); + user.ownSong = false; + } + clearTimeout(basicBot.room.autoskipTimer); + if (basicBot.room.autoskip) { + var remaining = obj.media.duration * 1000; + basicBot.room.autoskipTimer = setTimeout(function () { + console.log("Skipping track."); + //API.sendChat('Song stuck, skipping...'); + API.moderateForceSkip(); + }, remaining + 3000); + } + storeToStorage(); + + }, + eventWaitlistupdate: function (users) { + if (users.length < 50) { + if (basicBot.room.queue.id.length > 0 && basicBot.room.queueable) { + basicBot.room.queueable = false; + setTimeout(function () { + basicBot.room.queueable = true; + }, 500); + basicBot.room.queueing++; + var id, pos; + setTimeout( + function () { + id = basicBot.room.queue.id.splice(0, 1)[0]; + pos = basicBot.room.queue.position.splice(0, 1)[0]; + API.moderateAddDJ(id, pos); + setTimeout( + function (id, pos) { + API.moderateMoveDJ(id, pos); + basicBot.room.queueing--; + if (basicBot.room.queue.id.length === 0) setTimeout(function () { + basicBot.roomUtilities.booth.unlockBooth(); + }, 1000); + }, 1000, id, pos); + }, 1000 + basicBot.room.queueing * 2500); + } + } + for (var i = 0; i < users.length; i++) { + var user = basicBot.userUtilities.lookupUser(users[i].id); + basicBot.userUtilities.updatePosition(user, API.getWaitListPosition(users[i].id) + 1); + } + }, + chatcleaner: function (chat) { + if (!basicBot.settings.filterChat) return false; + if (basicBot.userUtilities.getPermission(chat.uid) > 1) return false; + var msg = chat.message; + var containsLetters = false; + for (var i = 0; i < msg.length; i++) { + ch = msg.charAt(i); + if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch === ':' || ch === '^') containsLetters = true; + } + if (msg === '') { + return true; + } + if (!containsLetters && (msg.length === 1 || msg.length > 3)) return true; + msg = msg.replace(/[ ,;.:\/=~+%^*\-\\"'&@#]/g, ''); + var capitals = 0; + var ch; + for (var i = 0; i < msg.length; i++) { + ch = msg.charAt(i); + if (ch >= 'A' && ch <= 'Z') capitals++; + } + if (capitals >= 40) { + API.sendChat(subChat(basicBot.chat.caps, {name: chat.un})); + return true; + } + msg = msg.toLowerCase(); + if (msg === 'skip') { + API.sendChat(subChat(basicBot.chat.askskip, {name: chat.un})); + return true; + } + for (var j = 0; j < basicBot.chatUtilities.spam.length; j++) { + if (msg === basicBot.chatUtilities.spam[j]) { + API.sendChat(subChat(basicBot.chat.spam, {name: chat.un})); + return true; + } + } + return false; + }, + chatUtilities: { + chatFilter: function (chat) { + var msg = chat.message; + var perm = basicBot.userUtilities.getPermission(chat.uid); + var user = basicBot.userUtilities.lookupUser(chat.uid); + var isMuted = false; + for (var i = 0; i < basicBot.room.mutedUsers.length; i++) { + if (basicBot.room.mutedUsers[i] === chat.uid) isMuted = true; + } + if (isMuted) { + API.moderateDeleteChat(chat.cid); + return true; + } + if (basicBot.settings.lockdownEnabled) { + if (perm === 0) { + API.moderateDeleteChat(chat.cid); + return true; + } + } + if (basicBot.chatcleaner(chat)) { + API.moderateDeleteChat(chat.cid); + return true; + } + /** + var plugRoomLinkPatt = /(\bhttps?:\/\/(www.)?plug\.dj[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + if (plugRoomLinkPatt.exec(msg)) { + if (perm === 0) { + API.sendChat(subChat(basicBot.chat.roomadvertising, {name: chat.un})); + API.moderateDeleteChat(chat.cid); + return true; + } + } + **/ + if (msg.indexOf('http://adf.ly/') > -1) { + API.moderateDeleteChat(chat.cid); + API.sendChat(subChat(basicBot.chat.adfly, {name: chat.un})); + return true; + } + 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) { + API.moderateDeleteChat(chat.cid); + return true; + } + + var rlJoinChat = basicBot.chat.roulettejoin; + var rlLeaveChat = basicBot.chat.rouletteleave; + + var joinedroulette = rlJoinChat.split('%%NAME%%'); + if (joinedroulette[1].length > joinedroulette[0].length) joinedroulette = joinedroulette[1]; + else joinedroulette = joinedroulette[0]; + + var leftroulette = rlLeaveChat.split('%%NAME%%'); + if (leftroulette[1].length > leftroulette[0].length) leftroulette = leftroulette[1]; + else leftroulette = leftroulette[0]; + + if ((msg.indexOf(joinedroulette) > -1 || msg.indexOf(leftroulette) > -1) && chat.uid === basicBot.loggedInID) { + setTimeout(function (id) { + API.moderateDeleteChat(id); + }, 2 * 1000, chat.cid); + return true; + } + return false; + }, + commandCheck: function (chat) { + var cmd; + if (chat.message.charAt(0) === '!') { + var space = chat.message.indexOf(' '); + if (space === -1) { + cmd = chat.message; + } + else cmd = chat.message.substring(0, space); + } + else return false; + var userPerm = basicBot.userUtilities.getPermission(chat.uid); + //console.log("name: " + chat.un + ", perm: " + userPerm); + if (chat.message !== "!join" && chat.message !== "!leave") { + if (userPerm === 0 && !basicBot.room.usercommand) return void (0); + if (!basicBot.room.allcommand) return void (0); + } + if (chat.message === '!eta' && basicBot.settings.etaRestriction) { + if (userPerm < 2) { + var u = basicBot.userUtilities.lookupUser(chat.uid); + if (u.lastEta !== null && (Date.now() - u.lastEta) < 1 * 60 * 60 * 1000) { + API.moderateDeleteChat(chat.cid); + return void (0); + } + else u.lastEta = Date.now(); + } + } + var executed = false; + + for (var comm in basicBot.commands) { + var cmdCall = basicBot.commands[comm].command; + if (!Array.isArray(cmdCall)) { + cmdCall = [cmdCall] + } + for (var i = 0; i < cmdCall.length; i++) { + if (basicBot.settings.commandLiteral + cmdCall[i] === cmd) { + basicBot.commands[comm].functionality(chat, basicBot.settings.commandLiteral + cmdCall[i]); + executed = true; + break; + } + } + } + + if (executed && userPerm === 0) { + basicBot.room.usercommand = false; + setTimeout(function () { + basicBot.room.usercommand = true; + }, basicBot.settings.commandCooldown * 1000); + } + if (executed) { + API.moderateDeleteChat(chat.cid); + basicBot.room.allcommand = false; + setTimeout(function () { + basicBot.room.allcommand = true; + }, 5 * 1000); + } + return executed; + }, + action: function (chat) { + var user = basicBot.userUtilities.lookupUser(chat.uid); + if (chat.type === 'message') { + for (var j = 0; j < basicBot.room.users.length; j++) { + if (basicBot.userUtilities.getUser(basicBot.room.users[j]).id === chat.uid) { + basicBot.userUtilities.setLastActivity(basicBot.room.users[j]); + } + + } + } + basicBot.room.roomstats.chatmessages++; + }, + spam: [ + 'hueh', 'hu3', 'brbr', 'heu', 'brbr', 'kkkk', 'spoder', 'mafia', 'zuera', 'zueira', + 'zueria', 'aehoo', 'aheu', 'alguem', 'algum', 'brazil', 'zoeira', 'fuckadmins', 'affff', 'vaisefoder', 'huenaarea', + 'hitler', 'ashua', 'ahsu', 'ashau', 'lulz', 'huehue', 'hue', 'huehuehue', 'merda', 'pqp', 'puta', 'mulher', 'pula', 'retarda', 'caralho', 'filha', 'ppk', + 'gringo', 'fuder', 'foder', 'hua', 'ahue', 'modafuka', 'modafoka', 'mudafuka', 'mudafoka', 'ooooooooooooooo', 'foda' + ], + curses: [ + 'nigger', 'faggot', 'nigga', 'niqqa', 'motherfucker', 'modafocka' + ] + }, + connectAPI: function () { + this.proxy = { + eventChat: $.proxy(this.eventChat, this), + eventUserskip: $.proxy(this.eventUserskip, this), + eventUserjoin: $.proxy(this.eventUserjoin, this), + eventUserleave: $.proxy(this.eventUserleave, this), + eventUserfan: $.proxy(this.eventUserfan, this), + eventFriendjoin: $.proxy(this.eventFriendjoin, this), + eventFanjoin: $.proxy(this.eventFanjoin, this), + eventVoteupdate: $.proxy(this.eventVoteupdate, this), + eventCurateupdate: $.proxy(this.eventCurateupdate, this), + eventRoomscoreupdate: $.proxy(this.eventRoomscoreupdate, this), + eventDjadvance: $.proxy(this.eventDjadvance, this), + eventDjupdate: $.proxy(this.eventDjupdate, this), + eventWaitlistupdate: $.proxy(this.eventWaitlistupdate, this), + eventVoteskip: $.proxy(this.eventVoteskip, this), + eventModskip: $.proxy(this.eventModskip, this), + eventChatcommand: $.proxy(this.eventChatcommand, this), + eventHistoryupdate: $.proxy(this.eventHistoryupdate, this) + + }; + API.on(API.CHAT, this.proxy.eventChat); + API.on(API.USER_SKIP, this.proxy.eventUserskip); + API.on(API.USER_JOIN, this.proxy.eventUserjoin); + API.on(API.USER_LEAVE, this.proxy.eventUserleave); + API.on(API.USER_FAN, this.proxy.eventUserfan); + API.on(API.VOTE_UPDATE, this.proxy.eventVoteupdate); + API.on(API.GRAB_UPDATE, this.proxy.eventCurateupdate); + API.on(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate); + API.on(API.ADVANCE, this.proxy.eventDjadvance); + API.on(API.WAIT_LIST_UPDATE, this.proxy.eventWaitlistupdate); + API.on(API.MOD_SKIP, this.proxy.eventModskip); + API.on(API.CHAT_COMMAND, this.proxy.eventChatcommand); + API.on(API.HISTORY_UPDATE, this.proxy.eventHistoryupdate); + }, + disconnectAPI: function () { + API.off(API.CHAT, this.proxy.eventChat); + API.off(API.USER_SKIP, this.proxy.eventUserskip); + API.off(API.USER_JOIN, this.proxy.eventUserjoin); + API.off(API.USER_LEAVE, this.proxy.eventUserleave); + API.off(API.USER_FAN, this.proxy.eventUserfan); + API.off(API.VOTE_UPDATE, this.proxy.eventVoteupdate); + API.off(API.CURATE_UPDATE, this.proxy.eventCurateupdate); + API.off(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate); + API.off(API.ADVANCE, this.proxy.eventDjadvance); + API.off(API.WAIT_LIST_UPDATE, this.proxy.eventWaitlistupdate); + API.off(API.MOD_SKIP, this.proxy.eventModskip); + API.off(API.CHAT_COMMAND, this.proxy.eventChatcommand); + API.off(API.HISTORY_UPDATE, this.proxy.eventHistoryupdate); + }, + startup: function () { + Function.prototype.toString = function () { + return 'Function.' + }; + var u = API.getUser(); + if (basicBot.userUtilities.getPermission(u) < 2) return API.chatLog(basicBot.chat.greyuser); + if (basicBot.userUtilities.getPermission(u) === 2) API.chatLog(basicBot.chat.bouncer); + basicBot.connectAPI(); + API.moderateDeleteChat = function (cid) { + $.ajax({ + url: "https://plug.dj/_/chat/" + cid, + type: "DELETE" + }) + }; + retrieveSettings(); + retrieveFromStorage(); + window.bot = basicBot; + basicBot.roomUtilities.updateBlacklists(); + setInterval(basicBot.roomUtilities.updateBlacklists, 60 * 60 * 1000); + basicBot.getNewBlacklistedSongs = basicBot.roomUtilities.exportNewBlacklistedSongs; + basicBot.logNewBlacklistedSongs = basicBot.roomUtilities.logNewBlacklistedSongs; + if (basicBot.room.roomstats.launchTime === null) { + basicBot.room.roomstats.launchTime = Date.now(); + } + + for (var j = 0; j < basicBot.room.users.length; j++) { + basicBot.room.users[j].inRoom = false; + } + var userlist = API.getUsers(); + for (var i = 0; i < userlist.length; i++) { + var known = false; + var ind = null; + for (var j = 0; j < basicBot.room.users.length; j++) { + if (basicBot.room.users[j].id === userlist[i].id) { + known = true; + ind = j; + } + } + if (known) { + basicBot.room.users[ind].inRoom = true; + } + else { + basicBot.room.users.push(new basicBot.User(userlist[i].id, userlist[i].username)); + ind = basicBot.room.users.length - 1; + } + var wlIndex = API.getWaitListPosition(basicBot.room.users[ind].id) + 1; + basicBot.userUtilities.updatePosition(basicBot.room.users[ind], wlIndex); + } + basicBot.room.afkInterval = setInterval(function () { + basicBot.roomUtilities.afkCheck() + }, 10 * 1000); + basicBot.room.autodisableInterval = setInterval(function () { + basicBot.room.autodisableFunc(); + }, 60 * 60 * 1000); + basicBot.loggedInID = API.getUser().id; + basicBot.status = true; + API.sendChat('/cap ' + basicBot.settings.startupCap); + API.setVolume(basicBot.settings.startupVolume); + $("#woot").click(); + if (basicBot.settings.startupEmoji) { + var emojibuttonoff = $(".icon-emoji-off"); + if (emojibuttonoff.length > 0) { + emojibuttonoff[0].click(); + } + API.chatLog(':smile: Emojis enabled.'); + } + else { + var emojibuttonon = $(".icon-emoji-on"); + if (emojibuttonon.length > 0) { + emojibuttonon[0].click(); + } + API.chatLog('Emojis disabled.'); + } + API.chatLog('Avatars capped at ' + basicBot.settings.startupCap); + API.chatLog('Volume set to ' + basicBot.settings.startupVolume); + loadChat(API.sendChat(subChat(basicBot.chat.online, {botname: basicBot.settings.botName, version: basicBot.version}))); + }, + commands: { + executable: function (minRank, chat) { + var id = chat.uid; + var perm = basicBot.userUtilities.getPermission(id); + var minPerm; + switch (minRank) { + case 'admin': + minPerm = 10; + break; + case 'ambassador': + minPerm = 7; + break; + case 'host': + minPerm = 5; + break; + case 'cohost': + minPerm = 4; + break; + case 'manager': + minPerm = 3; + break; + case 'mod': + if (basicBot.settings.bouncerPlus) { + minPerm = 2; + } + else { + minPerm = 3; + } + break; + case 'bouncer': + minPerm = 2; + break; + case 'residentdj': + minPerm = 1; + break; + case 'user': + minPerm = 0; + break; + default: + API.chatLog('error assigning minimum permission'); + } + return perm >= minPerm; + + }, + /** + command: { + command: 'cmd', + rank: 'user/bouncer/mod/manager', + type: 'startsWith/exact', + functionality: function(chat, cmd){ + if(this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if( !basicBot.commands.executable(this.rank, chat) ) return void (0); + else{ + + } + } + }, + **/ + + activeCommand: { + command: 'active', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var now = Date.now(); + var chatters = 0; + var time; + if (msg.length === cmd.length) time = 60; + else { + time = msg.substring(cmd.length + 1); + if (isNaN(time)) return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + for (var i = 0; i < basicBot.room.users.length; i++) { + userTime = basicBot.userUtilities.getLastActivity(basicBot.room.users[i]); + if ((now - userTime) <= (time * 60 * 1000)) { + chatters++; + } + } + API.sendChat(subChat(basicBot.chat.activeusersintime, {name: chat.un, amount: chatters, time: time})); + } + } + }, + + addCommand: { + command: 'add', + rank: 'mod', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substr(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (msg.length > cmd.length + 2) { + if (typeof user !== 'undefined') { + if (basicBot.room.roomevent) { + basicBot.room.eventArtists.push(user.id); + } + API.moderateAddDJ(user.id); + } else API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + } + } + } + }, + + afklimitCommand: { + command: 'afklimit', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nolimitspecified, {name: chat.un})); + var limit = msg.substring(cmd.length + 1); + if (!isNaN(limit)) { + basicBot.settings.maximumAfk = parseInt(limit, 10); + API.sendChat(subChat(basicBot.chat.maximumafktimeset, {name: chat.un, time: basicBot.settings.maximumAfk})); + } + else API.sendChat(subChat(basicBot.chat.invalidlimitspecified, {name: chat.un})); + } + } + }, + + afkremovalCommand: { + command: 'afkremoval', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.afkRemoval) { + basicBot.settings.afkRemoval = !basicBot.settings.afkRemoval; + clearInterval(basicBot.room.afkInterval); + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.afkremoval})); + } + else { + basicBot.settings.afkRemoval = !basicBot.settings.afkRemoval; + basicBot.room.afkInterval = setInterval(function () { + basicBot.roomUtilities.afkCheck() + }, 2 * 1000); + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.afkremoval})); + } + } + } + }, + + afkresetCommand: { + command: 'afkreset', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + basicBot.userUtilities.setLastActivity(user); + API.sendChat(subChat(basicBot.chat.afkstatusreset, {name: chat.un, username: name})); + } + } + }, + + afktimeCommand: { + command: 'afktime', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var lastActive = basicBot.userUtilities.getLastActivity(user); + var inactivity = Date.now() - lastActive; + var time = basicBot.roomUtilities.msToStr(inactivity); + API.sendChat(subChat(basicBot.chat.inactivefor, {name: chat.un, username: name, time: time})); + } + } + }, + + autodisableCommand: { + command: 'autodisable', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.autodisable) { + basicBot.settings.autodisable = !basicBot.settings.autodisable; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.autodisable})); + } + else { + basicBot.settings.autodisable = !basicBot.settings.autodisable; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.autodisable})); + } + + } + } + }, + + autoskipCommand: { + command: 'autoskip', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.room.autoskip) { + basicBot.room.autoskip = !basicBot.room.autoskip; + clearTimeout(basicBot.room.autoskipTimer); + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.autoskip})); + } + else { + basicBot.room.autoskip = !basicBot.room.autoskip; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.autoskip})); + } + } + } + }, + + autowootCommand: { + command: 'autowoot', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(basicBot.chat.autowoot); + } + } + }, + + baCommand: { + command: 'ba', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(basicBot.chat.brandambassador); + } + } + }, + + banCommand: { + command: 'ban', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substr(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + API.moderateBanUser(user.id, 1, API.BAN.DAY); + } + } + }, + + blacklistCommand: { + command: ['blacklist', 'bl'], + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nolistspecified, {name: chat.un})); + var list = msg.substr(cmd.length + 1); + if (typeof basicBot.room.blacklists[list] === 'undefined') return API.sendChat(subChat(basicBot.chat.invalidlistspecified, {name: chat.un})); + else { + var media = API.getMedia(); + var track = { + list: list, + author: media.author, + title: media.title, + mid: media.format + ':' + media.cid + }; + basicBot.room.newBlacklisted.push(track); + basicBot.room.blacklists[list].push(media.format + ':' + media.cid); + API.sendChat(subChat(basicBot.chat.newblacklisted, {name: chat.un, blacklist: list, author: media.author, title: media.title, mid: media.format + ':' + media.cid})); + API.moderateForceSkip(); + if (typeof basicBot.room.newBlacklistedSongFunction === 'function') { + basicBot.room.newBlacklistedSongFunction(track); + } + } + } + } + }, + + blinfoCommand: { + command: 'blinfo', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var author = API.getMedia().author; + var title = API.getMedia().title; + var name = chat.un; + var format = API.getMedia().format; + var cid = API.getMedia().cid; + var songid = format + ":" + cid; + + API.sendChat(subChat(basicBot.chat.blinfo, {name: name, author: author, title: title, songid: songid})); + } + } + }, + + bouncerPlusCommand: { + command: 'bouncer+', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (basicBot.settings.bouncerPlus) { + basicBot.settings.bouncerPlus = false; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': 'Bouncer+'})); + } + else { + if (!basicBot.settings.bouncerPlus) { + var id = chat.uid; + var perm = basicBot.userUtilities.getPermission(id); + if (perm > 2) { + basicBot.settings.bouncerPlus = true; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': 'Bouncer+'})); + } + } + else return API.sendChat(subChat(basicBot.chat.bouncerplusrank, {name: chat.un})); + } + } + } + }, + + clearchatCommand: { + command: 'clearchat', + rank: 'manager', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var currentchat = $('#chat-messages').children(); + for (var i = 0; i < currentchat.length; i++) { + API.moderateDeleteChat(currentchat[i].getAttribute("data-cid")); + } + return API.sendChat(subChat(basicBot.chat.chatcleared, {name: chat.un})); + } + } + }, + + commandsCommand: { + command: 'commands', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(subChat(basicBot.chat.commandslink, {botname: basicBot.settings.botName, link: basicBot.cmdLink})); + } + } + }, + + cookieCommand: { + command: 'cookie', + rank: 'user', + type: 'startsWith', + cookies: ['has given you a chocolate chip cookie!', + 'has given you a soft homemade oatmeal cookie!', + 'has given you a plain, dry, old cookie. It was the last one in the bag. Gross.', + 'gives you a sugar cookie. What, no frosting and sprinkles? 0/10 would not touch.', + 'gives you a chocolate chip cookie. Oh wait, those are raisins. Bleck!', + 'gives you an enormous cookie. Poking it gives you more cookies. Weird.', + 'gives you a fortune cookie. It reads "Why aren\'t you working on any projects?"', + 'gives you a fortune cookie. It reads "Give that special someone a compliment"', + 'gives you a fortune cookie. It reads "Take a risk!"', + 'gives you a fortune cookie. It reads "Go outside."', + 'gives you a fortune cookie. It reads "Don\'t forget to eat your veggies!"', + 'gives you a fortune cookie. It reads "Do you even lift?"', + 'gives you a fortune cookie. It reads "m808 pls"', + 'gives you a fortune cookie. It reads "If you move your hips, you\'ll get all the ladies."', + 'gives you a fortune cookie. It reads "I love you."', + 'gives you a Golden Cookie. You can\'t eat it because it is made of gold. Dammit.', + 'gives you an Oreo cookie with a glass of milk!', + 'gives you a rainbow cookie made with love :heart:', + 'gives you an old cookie that was left out in the rain, it\'s moldy.', + 'bakes you fresh cookies, it smells amazing.' + ], + getCookie: function () { + var c = Math.floor(Math.random() * this.cookies.length); + return this.cookies[c]; + }, + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + + var space = msg.indexOf(' '); + if (space === -1) { + API.sendChat(basicBot.chat.eatcookie); + return false; + } + else { + var name = msg.substring(space + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (user === false || !user.inRoom) { + return API.sendChat(subChat(basicBot.chat.nousercookie, {name: name})); + } + else if (user.username === chat.un) { + return API.sendChat(subChat(basicBot.chat.selfcookie, {name: name})); + } + else { + return API.sendChat(subChat(basicBot.chat.cookie, {nameto: user.username, namefrom: chat.un, cookie: this.getCookie()})); + } + } + } + } + }, + + cycleCommand: { + command: 'cycle', + rank: 'manager', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + basicBot.roomUtilities.changeDJCycle(); + } + } + }, + + cycleguardCommand: { + command: 'cycleguard', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.cycleGuard) { + basicBot.settings.cycleGuard = !basicBot.settings.cycleGuard; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.cycleguard})); + } + else { + basicBot.settings.cycleGuard = !basicBot.settings.cycleGuard; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.cycleguard})); + } + + } + } + }, + + cycletimerCommand: { + command: 'cycletimer', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var cycleTime = msg.substring(cmd.length + 1); + if (!isNaN(cycleTime) && cycleTime !== "") { + basicBot.settings.maximumCycletime = cycleTime; + return API.sendChat(subChat(basicBot.chat.cycleguardtime, {name: chat.un, time: basicBot.settings.maximumCycletime})); + } + else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + + } + } + }, + + voteskipCommand: { + command: 'voteskip', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length <= cmd.length + 1) return API.sendChat(subChat(basicBot.chat.voteskiplimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit})); + var argument = msg.substring(cmd.length + 1); + if (!basicBot.settings.voteSkip) basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + if (isNaN(argument)) { + API.sendChat(subChat(basicBot.chat.voteskipinvalidlimit, {name: chat.un})); + } + else { + basicBot.settings.voteSkipLimit = argument; + API.sendChat(subChat(basicBot.chat.voteskipsetlimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit})); + } + } + } + }, + + togglevoteskipCommand: { + command: 'togglevoteskip', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.voteSkip) { + basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.voteskip})); + } + else { + basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.voteskip})); + } + } + } + }, + + dclookupCommand: { + command: ['dclookup', 'dc'], + rank: 'user', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var name; + if (msg.length === cmd.length) name = chat.un; + else { + name = msg.substring(cmd.length + 2); + var perm = basicBot.userUtilities.getPermission(chat.uid); + if (perm < 2) return API.sendChat(subChat(basicBot.chat.dclookuprank, {name: chat.un})); + } + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var toChat = basicBot.userUtilities.dclookup(user.id); + API.sendChat(toChat); + } + } + }, + + /*deletechatCommand: { + command: 'deletechat', + rank: 'mod', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var chats = $('.from'); + for (var i = 0; i < chats.length; i++) { + var n = chats[i].textContent; + if (name.trim() === n.trim()) { + var cid = $(chats[i]).parent()[0].getAttribute('data-cid'); + API.moderateDeleteChat(cid); + } + } + API.sendChat(subChat(basicBot.chat.deletechat, {name: chat.un, username: name})); + } + } + },*/ + + emojiCommand: { + command: 'emoji', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var link = 'http://www.emoji-cheat-sheet.com/'; + API.sendChat(subChat(basicBot.chat.emojilist, {link: link})); + } + } + }, + + englishCommand: { + command: 'english', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if(chat.message.length === cmd.length) return API.sendChat('/me No user specified.'); + var name = chat.message.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if(typeof user === 'boolean') return API.sendChat('/me Invalid user specified.'); + var lang = basicBot.userUtilities.getUser(user).language; + var ch = '/me @' + name + ' '; + switch(lang){ + case 'en': break; + case 'da': ch += 'Vær venlig at tale engelsk.'; break; + case 'de': ch += 'Bitte sprechen Sie Englisch.'; break; + case 'es': ch += 'Por favor, hable Inglés.'; break; + case 'fr': ch += 'Parlez anglais, s\'il vous plaît.'; break; + case 'nl': ch += 'Spreek Engels, alstublieft.'; break; + case 'pl': ch += 'Proszę mówić po angielsku.'; break; + case 'pt': ch += 'Por favor, fale Inglês.'; break; + case 'sk': ch += 'Hovorte po anglicky, prosím.'; break; + case 'cs': ch += 'Mluvte prosím anglicky.'; break; + case 'sr': ch += 'Молим Вас, говорите енглески.'; break; + } + ch += ' English please.'; + API.sendChat(ch); + } + } + }, + + etaCommand: { + command: 'eta', + rank: 'user', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var perm = basicBot.userUtilities.getPermission(chat.uid); + var msg = chat.message; + var name; + if (msg.length > cmd.length) { + if (perm < 2) return void (0); + name = msg.substring(cmd.length + 2); + } else name = chat.un; + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var pos = API.getWaitListPosition(user.id); + if (pos < 0) return API.sendChat(subChat(basicBot.chat.notinwaitlist, {name: name})); + var timeRemaining = API.getTimeRemaining(); + var estimateMS = ((pos + 1) * 4 * 60 + timeRemaining) * 1000; + var estimateString = basicBot.roomUtilities.msToStr(estimateMS); + API.sendChat(subChat(basicBot.chat.eta, {name: name, time: estimateString})); + } + } + }, + + fbCommand: { + command: 'fb', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.fbLink === "string") + API.sendChat(subChat(basicBot.chat.facebook, {link: basicBot.settings.fbLink})); + } + } + }, + + filterCommand: { + command: 'filter', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.filterChat) { + basicBot.settings.filterChat = !basicBot.settings.filterChat; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.chatfilter})); + } + else { + basicBot.settings.filterChat = !basicBot.settings.filterChat; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.chatfilter})); + } + } + } + }, + + helpCommand: { + command: 'help', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var link = "http://i.imgur.com/SBAso1N.jpg"; + API.sendChat(subChat(basicBot.chat.starterhelp, {link: link})); + } + } + }, + + historyskipCommand: { + command: 'historyskip', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.historySkip) { + basicBot.settings.historySkip = !basicBot.settings.historySkip; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.historyskip})); + } + else { + basicBot.settings.historySkip = !basicBot.settings.historySkip; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.historyskip})); + } + } + } + }, + + joinCommand: { + command: 'join', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.room.roulette.rouletteStatus && basicBot.room.roulette.participants.indexOf(chat.uid) < 0) { + basicBot.room.roulette.participants.push(chat.uid); + API.sendChat(subChat(basicBot.chat.roulettejoin, {name: chat.un})); + } + } + } + }, + + jointimeCommand: { + command: 'jointime', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var join = basicBot.userUtilities.getJointime(user); + var time = Date.now() - join; + var timeString = basicBot.roomUtilities.msToStr(time); + API.sendChat(subChat(basicBot.chat.jointime, {namefrom: chat.un, username: name, time: timeString})); + } + } + }, + + kickCommand: { + command: 'kick', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var lastSpace = msg.lastIndexOf(' '); + var time; + var name; + if (lastSpace === msg.indexOf(' ')) { + time = 0.25; + name = msg.substring(cmd.length + 2); + } + else { + time = msg.substring(lastSpace + 1); + name = msg.substring(cmd.length + 2, lastSpace); + } + + var user = basicBot.userUtilities.lookupUserName(name); + var from = chat.un; + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + + var permFrom = basicBot.userUtilities.getPermission(chat.uid); + var permTokick = basicBot.userUtilities.getPermission(user.id); + + if (permFrom <= permTokick) + return API.sendChat(subChat(basicBot.chat.kickrank, {name: chat.un})); + + if (!isNaN(time)) { + API.sendChat(subChat(basicBot.chat.kick, {name: chat.un, username: name, time: time})); + if (time > 24 * 60 * 60) API.moderateBanUser(user.id, 1, API.BAN.PERMA); + else API.moderateBanUser(user.id, 1, API.BAN.DAY); + setTimeout(function (id, name) { + API.moderateUnbanUser(id); + console.log('Unbanned @' + name + '. (' + id + ')'); + }, time * 60 * 1000, user.id, name); + } + else API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + } + }, + + killCommand: { + command: 'kill', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + storeToStorage(); + API.sendChat(basicBot.chat.kill); + basicBot.disconnectAPI(); + setTimeout(function () { + kill(); + }, 1000); + } + } + }, + + leaveCommand: { + command: 'leave', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var ind = basicBot.room.roulette.participants.indexOf(chat.uid); + if (ind > -1) { + basicBot.room.roulette.participants.splice(ind, 1); + API.sendChat(subChat(basicBot.chat.rouletteleave, {name: chat.un})); + } + } + } + }, + + linkCommand: { + command: 'link', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var media = API.getMedia(); + var from = chat.un; + var user = basicBot.userUtilities.lookupUser(chat.uid); + var perm = basicBot.userUtilities.getPermission(chat.uid); + var dj = API.getDJ().id; + var isDj = false; + if (dj === chat.uid) isDj = true; + if (perm >= 1 || isDj) { + if (media.format === 1) { + var linkToSong = "https://www.youtube.com/watch?v=" + media.cid; + API.sendChat(subChat(basicBot.chat.songlink, {name: from, link: linkToSong})); + } + if (media.format === 2) { + SC.get('/tracks/' + media.cid, function (sound) { + API.sendChat(subChat(basicBot.chat.songlink, {name: from, link: sound.permalink_url})); + }); + } + } + } + } + }, + + lockCommand: { + command: 'lock', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + basicBot.roomUtilities.booth.lockBooth(); + } + } + }, + + lockdownCommand: { + command: 'lockdown', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var temp = basicBot.settings.lockdownEnabled; + basicBot.settings.lockdownEnabled = !temp; + if (basicBot.settings.lockdownEnabled) { + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.lockdown})); + } + else return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockdown})); + } + } + }, + + lockguardCommand: { + command: 'lockguard', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.lockGuard) { + basicBot.settings.lockGuard = !basicBot.settings.lockGuard; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockguard})); + } + else { + basicBot.settings.lockGuard = !basicBot.settings.lockGuard; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.lockguard})); + } + } + } + }, + + lockskipCommand: { + command: 'lockskip', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.room.skippable) { + var dj = API.getDJ(); + var id = dj.id; + var name = dj.username; + var msgSend = '@' + name + ': '; + basicBot.room.queueable = false; + + if (chat.message.length === cmd.length) { + API.sendChat(subChat(basicBot.chat.usedlockskip, {name: chat.un})); + basicBot.roomUtilities.booth.lockBooth(); + setTimeout(function (id) { + API.moderateForceSkip(); + basicBot.room.skippable = false; + setTimeout(function () { + basicBot.room.skippable = true + }, 5 * 1000); + setTimeout(function (id) { + basicBot.userUtilities.moveUser(id, basicBot.settings.lockskipPosition, false); + basicBot.room.queueable = true; + setTimeout(function () { + basicBot.roomUtilities.booth.unlockBooth(); + }, 1000); + }, 1500, id); + }, 1000, id); + return void (0); + } + var validReason = false; + var msg = chat.message; + var reason = msg.substring(cmd.length + 1); + for (var i = 0; i < basicBot.settings.lockskipReasons.length; i++) { + var r = basicBot.settings.lockskipReasons[i][0]; + if (reason.indexOf(r) !== -1) { + validReason = true; + msgSend += basicBot.settings.lockskipReasons[i][1]; + } + } + if (validReason) { + API.sendChat(subChat(basicBot.chat.usedlockskip, {name: chat.un})); + basicBot.roomUtilities.booth.lockBooth(); + setTimeout(function (id) { + API.moderateForceSkip(); + basicBot.room.skippable = false; + API.sendChat(msgSend); + setTimeout(function () { + basicBot.room.skippable = true + }, 5 * 1000); + setTimeout(function (id) { + basicBot.userUtilities.moveUser(id, basicBot.settings.lockskipPosition, false); + basicBot.room.queueable = true; + setTimeout(function () { + basicBot.roomUtilities.booth.unlockBooth(); + }, 1000); + }, 1500, id); + }, 1000, id); + return void (0); + } + } + } + } + }, + + lockskipposCommand: { + command: 'lockskippos', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var pos = msg.substring(cmd.length + 1); + if (!isNaN(pos)) { + basicBot.settings.lockskipPosition = pos; + return API.sendChat(subChat(basicBot.chat.lockskippos, {name: chat.un, position: basicBot.settings.lockskipPosition})); + } + else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un})); + } + } + }, + + locktimerCommand: { + command: 'locktimer', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var lockTime = msg.substring(cmd.length + 1); + if (!isNaN(lockTime) && lockTime !== "") { + basicBot.settings.maximumLocktime = lockTime; + return API.sendChat(subChat(basicBot.chat.lockguardtime, {name: chat.un, time: basicBot.settings.maximumLocktime})); + } + else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + } + }, + + maxlengthCommand: { + command: 'maxlength', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var maxTime = msg.substring(cmd.length + 1); + if (!isNaN(maxTime)) { + basicBot.settings.maximumSongLength = maxTime; + return API.sendChat(subChat(basicBot.chat.maxlengthtime, {name: chat.un, time: basicBot.settings.maximumSongLength})); + } + else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + } + }, + + motdCommand: { + command: 'motd', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length <= cmd.length + 1) return API.sendChat('/me MotD: ' + basicBot.settings.motd); + var argument = msg.substring(cmd.length + 1); + if (!basicBot.settings.motdEnabled) basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled; + if (isNaN(argument)) { + basicBot.settings.motd = argument; + API.sendChat(subChat(basicBot.chat.motdset, {msg: basicBot.settings.motd})); + } + else { + basicBot.settings.motdInterval = argument; + API.sendChat(subChat(basicBot.chat.motdintervalset, {interval: basicBot.settings.motdInterval})); + } + } + } + }, + + moveCommand: { + command: 'move', + rank: 'mod', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var firstSpace = msg.indexOf(' '); + var lastSpace = msg.lastIndexOf(' '); + var pos; + var name; + if (isNaN(parseInt(msg.substring(lastSpace + 1)))) { + pos = 1; + name = msg.substring(cmd.length + 2); + } + else { + pos = parseInt(msg.substring(lastSpace + 1)); + name = msg.substring(cmd.length + 2, lastSpace); + } + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + if (user.id === basicBot.loggedInID) return API.sendChat(subChat(basicBot.chat.addbotwaitlist, {name: chat.un})); + if (!isNaN(pos)) { + API.sendChat(subChat(basicBot.chat.move, {name: chat.un})); + basicBot.userUtilities.moveUser(user.id, pos, false); + } else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un})); + } + } + }, + + muteCommand: { + command: 'mute', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var lastSpace = msg.lastIndexOf(' '); + var time = null; + var name; + if (lastSpace === msg.indexOf(' ')) { + name = msg.substring(cmd.length + 2); + time = 45; + } + else { + time = msg.substring(lastSpace + 1); + if (isNaN(time) || time == "" || time == null || typeof time == "undefined") { + return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + name = msg.substring(cmd.length + 2, lastSpace); + } + var from = chat.un; + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var permFrom = basicBot.userUtilities.getPermission(chat.uid); + var permUser = basicBot.userUtilities.getPermission(user.id); + if (permFrom > permUser) { + /* + basicBot.room.mutedUsers.push(user.id); + if (time === null) API.sendChat(subChat(basicBot.chat.mutednotime, {name: chat.un, username: name})); + else { + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + setTimeout(function (id) { + var muted = basicBot.room.mutedUsers; + var wasMuted = false; + var indexMuted = -1; + for (var i = 0; i < muted.length; i++) { + if (muted[i] === id) { + indexMuted = i; + wasMuted = true; + } + } + if (indexMuted > -1) { + basicBot.room.mutedUsers.splice(indexMuted); + var u = basicBot.userUtilities.lookupUser(id); + var name = u.username; + API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name})); + } + }, time * 60 * 1000, user.id); + } + */ + if (time > 45) { + API.sendChat(subChat(basicBot.chat.mutedmaxtime, {name: chat.un, time: "45"})); + API.moderateMuteUser(user.id, 1, API.MUTE.LONG); + } + else if (time === 45) { + API.moderateMuteUser(user.id, 1, API.MUTE.LONG); + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + + } + else if (time > 30) { + API.moderateMuteUser(user.id, 1, API.MUTE.LONG); + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + setTimeout(function (id) { + API.moderateUnmuteUser(id); + }, time * 60 * 1000, user.id); + } + else if (time > 15) { + API.moderateMuteUser(user.id, 1, API.MUTE.MEDIUM); + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + setTimeout(function (id) { + API.moderateUnmuteUser(id); + }, time * 60 * 1000, user.id); + } + else { + API.moderateMuteUser(user.id, 1, API.MUTE.SHORT); + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + setTimeout(function (id) { + API.moderateUnmuteUser(id); + }, time * 60 * 1000, user.id); + } + } + else API.sendChat(subChat(basicBot.chat.muterank, {name: chat.un})); + } + } + }, + + opCommand: { + command: 'op', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.opLink === "string") + return API.sendChat(subChat(basicBot.chat.oplist, {link: basicBot.settings.opLink})); + } + } + }, + + pingCommand: { + command: 'ping', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(basicBot.chat.pong) + } + } + }, + + refreshCommand: { + command: 'refresh', + rank: 'manager', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + storeToStorage(); + basicBot.disconnectAPI(); + setTimeout(function () { + window.location.reload(false); + }, 1000); + + } + } + }, + + reloadCommand: { + command: 'reload', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(basicBot.chat.reload); + storeToStorage(); + basicBot.disconnectAPI(); + kill(); + setTimeout(function () { + $.getScript(basicBot.scriptLink); + }, 2000); + } + } + }, + + removeCommand: { + command: 'remove', + rank: 'mod', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length > cmd.length + 2) { + var name = msg.substr(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (typeof user !== 'boolean') { + user.lastDC = { + time: null, + position: null, + songCount: 0 + }; + if (API.getDJ().id === user.id) { + API.moderateForceSkip(); + setTimeout(function () { + API.moderateRemoveDJ(user.id); + }, 1 * 1000, user); + } + else API.moderateRemoveDJ(user.id); + } else API.sendChat(subChat(basicBot.chat.removenotinwl, {name: chat.un, username: name})); + } else API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + } + } + }, + + restrictetaCommand: { + command: 'restricteta', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.etaRestriction) { + basicBot.settings.etaRestriction = !basicBot.settings.etaRestriction; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.etarestriction})); + } + else { + basicBot.settings.etaRestriction = !basicBot.settings.etaRestriction; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.etarestriction})); + } + } + } + }, + + rouletteCommand: { + command: 'roulette', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (!basicBot.room.roulette.rouletteStatus) { + basicBot.room.roulette.startRoulette(); + } + } + } + }, + + rulesCommand: { + command: 'rules', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.rulesLink === "string") + return API.sendChat(subChat(basicBot.chat.roomrules, {link: basicBot.settings.rulesLink})); + } + } + }, + + sessionstatsCommand: { + command: 'sessionstats', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var from = chat.un; + var woots = basicBot.room.roomstats.totalWoots; + var mehs = basicBot.room.roomstats.totalMehs; + var grabs = basicBot.room.roomstats.totalCurates; + API.sendChat(subChat(basicBot.chat.sessionstats, {name: from, woots: woots, mehs: mehs, grabs: grabs})); + } + } + }, + + skipCommand: { + command: 'skip', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(subChat(basicBot.chat.skip, {name: chat.un})); + API.moderateForceSkip(); + basicBot.room.skippable = false; + setTimeout(function () { + basicBot.room.skippable = true + }, 5 * 1000); + + } + } + }, + + songstatsCommand: { + command: 'songstats', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.songstats) { + basicBot.settings.songstats = !basicBot.settings.songstats; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.songstats})); + } + else { + basicBot.settings.songstats = !basicBot.settings.songstats; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.songstats})); + } + } + } + }, + + sourceCommand: { + command: 'source', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat('/me This bot was created by ' + botCreator + ', but is now maintained by ' + botMaintainer + "."); + } + } + }, + + statusCommand: { + command: 'status', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var from = chat.un; + var msg = '/me [@' + from + '] '; + + msg += basicBot.chat.afkremoval + ': '; + if (basicBot.settings.afkRemoval) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + msg += basicBot.chat.afksremoved + ": " + basicBot.room.afkList.length + '. '; + msg += basicBot.chat.afklimit + ': ' + basicBot.settings.maximumAfk + '. '; + + msg += 'Bouncer+: '; + if (basicBot.settings.bouncerPlus) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.blacklist + ': '; + if (basicBot.settings.blacklistEnabled) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.lockguard + ': '; + if (basicBot.settings.lockGuard) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.cycleguard + ': '; + if (basicBot.settings.cycleGuard) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.timeguard + ': '; + if (basicBot.settings.timeGuard) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.chatfilter + ': '; + if (basicBot.settings.filterChat) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.historyskip + ': '; + if (basicBot.settings.historySkip) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.voteskip + ': '; + if (basicBot.settings.voteSkip) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + var launchT = basicBot.room.roomstats.launchTime; + var durationOnline = Date.now() - launchT; + var since = basicBot.roomUtilities.msToStr(durationOnline); + msg += subChat(basicBot.chat.activefor, {time: since}); + + return API.sendChat(msg); + } + } + }, + + swapCommand: { + command: 'swap', + rank: 'mod', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var firstSpace = msg.indexOf(' '); + var lastSpace = msg.lastIndexOf(' '); + var name1 = msg.substring(cmd.length + 2, lastSpace); + var name2 = msg.substring(lastSpace + 2); + var user1 = basicBot.userUtilities.lookupUserName(name1); + var user2 = basicBot.userUtilities.lookupUserName(name2); + if (typeof user1 === 'boolean' || typeof user2 === 'boolean') return API.sendChat(subChat(basicBot.chat.swapinvalid, {name: chat.un})); + if (user1.id === basicBot.loggedInID || user2.id === basicBot.loggedInID) return API.sendChat(subChat(basicBot.chat.addbottowaitlist, {name: chat.un})); + var p1 = API.getWaitListPosition(user1.id) + 1; + var p2 = API.getWaitListPosition(user2.id) + 1; + if (p1 < 0 || p2 < 0) return API.sendChat(subChat(basicBot.chat.swapwlonly, {name: chat.un})); + API.sendChat(subChat(basicBot.chat.swapping, {'name1': name1, 'name2': name2})); + if (p1 < p2) { + basicBot.userUtilities.moveUser(user2.id, p1, false); + setTimeout(function (user1, p2) { + basicBot.userUtilities.moveUser(user1.id, p2, false); + }, 2000, user1, p2); + } + else { + basicBot.userUtilities.moveUser(user1.id, p2, false); + setTimeout(function (user2, p1) { + basicBot.userUtilities.moveUser(user2.id, p1, false); + }, 2000, user2, p1); + } + } + } + }, + + themeCommand: { + command: 'theme', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.themeLink === "string") + API.sendChat(subChat(basicBot.chat.genres, {link: basicBot.settings.themeLink})); + } + } + }, + + timeguardCommand: { + command: 'timeguard', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.timeGuard) { + basicBot.settings.timeGuard = !basicBot.settings.timeGuard; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.timeguard})); + } + else { + basicBot.settings.timeGuard = !basicBot.settings.timeGuard; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.timeguard})); + } + + } + } + }, + + toggleblCommand: { + command: 'togglebl', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var temp = basicBot.settings.blacklistEnabled; + basicBot.settings.blacklistEnabled = !temp; + if (basicBot.settings.blacklistEnabled) { + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.blacklist})); + } + else return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.blacklist})); + } + } + }, + + togglemotdCommand: { + command: 'togglemotd', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.motdEnabled) { + basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.motd})); + } + else { + basicBot.settings.motdEnabled = !basicBot.settings.motdEnabled; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.motd})); + } + } + } + }, + + unbanCommand: { + command: 'unban', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + $(".icon-population").click(); + $(".icon-ban").click(); + setTimeout(function (chat) { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(); + var name = msg.substring(cmd.length + 2); + var bannedUsers = API.getBannedUsers(); + var found = false; + var bannedUser = null; + for (var i = 0; i < bannedUsers.length; i++) { + var user = bannedUsers[i]; + if (user.username === name) { + bannedUser = user; + found = true; + } + } + if (!found) { + $(".icon-chat").click(); + return API.sendChat(subChat(basicBot.chat.notbanned, {name: chat.un})); + } + API.moderateUnbanUser(bannedUser.id); + console.log("Unbanned " + name); + setTimeout(function () { + $(".icon-chat").click(); + }, 1000); + }, 1000, chat); + } + } + }, + + unlockCommand: { + command: 'unlock', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + basicBot.roomUtilities.booth.unlockBooth(); + } + } + }, + + unmuteCommand: { + command: 'unmute', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var permFrom = basicBot.userUtilities.getPermission(chat.uid); + /** + if (msg.indexOf('@') === -1 && msg.indexOf('all') !== -1) { + if (permFrom > 2) { + basicBot.room.mutedUsers = []; + return API.sendChat(subChat(basicBot.chat.unmutedeveryone, {name: chat.un})); + } + else return API.sendChat(subChat(basicBot.chat.unmuteeveryonerank, {name: chat.un})); + } + **/ + var from = chat.un; + var name = msg.substr(cmd.length + 2); + + var user = basicBot.userUtilities.lookupUserName(name); + + if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + + var permUser = basicBot.userUtilities.getPermission(user.id); + if (permFrom > permUser) { + /* + var muted = basicBot.room.mutedUsers; + var wasMuted = false; + var indexMuted = -1; + for (var i = 0; i < muted.length; i++) { + if (muted[i] === user.id) { + indexMuted = i; + wasMuted = true; + } + + } + if (!wasMuted) return API.sendChat(subChat(basicBot.chat.notmuted, {name: chat.un})); + basicBot.room.mutedUsers.splice(indexMuted); + API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name})); + */ + try { + API.moderateUnmuteUser(user.id); + API.sendChat(subChat(basicBot.chat.unmuted, {name: chat.un, username: name})); + } + catch (e) { + API.sendChat(subChat(basicBot.chat.notmuted, {name: chat.un})); + } + } + else API.sendChat(subChat(basicBot.chat.unmuterank, {name: chat.un})); + } + } + }, + + usercmdcdCommand: { + command: 'usercmdcd', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var cd = msg.substring(cmd.length + 1); + if (!isNaN(cd)) { + basicBot.settings.commandCooldown = cd; + return API.sendChat(subChat(basicBot.chat.commandscd, {name: chat.un, time: basicBot.settings.commandCooldown})); + } + else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + } + } + }, + + usercommandsCommand: { + command: 'usercommands', + rank: 'manager', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.usercommandsEnabled) { + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.usercommands})); + basicBot.settings.usercommandsEnabled = !basicBot.settings.usercommandsEnabled; + } + else { + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.usercommands})); + basicBot.settings.usercommandsEnabled = !basicBot.settings.usercommandsEnabled; + } + } + } + }, + + voteratioCommand: { + command: 'voteratio', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length === cmd.length) return API.sendChat(subChat(basicBot.chat.nouserspecified, {name: chat.un})); + var name = msg.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if (user === false) return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); + var vratio = user.votes; + var ratio = vratio.woot / vratio.meh; + API.sendChat(subChat(basicBot.chat.voteratio, {name: chat.un, username: name, woot: vratio.woot, mehs: vratio.meh, ratio: ratio.toFixed(2)})); + } + } + }, + + welcomeCommand: { + command: 'welcome', + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.welcome) { + basicBot.settings.welcome = !basicBot.settings.welcome; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.welcomemsg})); + } + else { + basicBot.settings.welcome = !basicBot.settings.welcome; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.welcomemsg})); + } + } + } + }, + + websiteCommand: { + command: 'website', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.website === "string") + API.sendChat(subChat(basicBot.chat.website, {link: basicBot.settings.website})); + } + } + }, + + youtubeCommand: { + command: 'youtube', + rank: 'user', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (typeof basicBot.settings.youtubeLink === "string") + API.sendChat(subChat(basicBot.chat.youtube, {name: chat.un, link: basicBot.settings.youtubeLink})); + } + } + } + } + }; + + loadChat(basicBot.startup); +}).call(this);