diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda7..00000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore deleted file mode 100644 index becebf46..00000000 --- a/.gitignore +++ /dev/null @@ -1,222 +0,0 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg - -############# -## Webstorms -############# -.idea - -forknotice.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 7c55da9b..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -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. \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 92e3f7c1..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,4 +0,0 @@ -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. \ No newline at end of file diff --git a/README.md b/README.md index ce2bb9ed..58e15272 100644 --- a/README.md +++ b/README.md @@ -1,87 +1,36 @@ -basicBot +BukkitBot ======== -A not so basic bot for plug.dj +A not so basic plug.dj bot for Bukkit or Spigot -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Yemasthui/basicBot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![facebook group](http://i.bnzi.uk/97dW.svg)](https://facebook.com/groups/basicBot) [![twitter](http://i.bnzi.uk/4KEn.svg)](https://twitter.com/bscBt) - -Stay updated on **basicBot**'s development by following the project on Twitter [@bscBt](http://twitter.com/bscBt) - -Created by [Yemasthui](https://github.com/Yemasthui) but now maintained by [Benzi](https://github.com/Benzi). - -(You can email me via hi@bnzi.uk or send me a message on [Gitter](https://gitter.im/Benzi) if you have any queries about the bot) - -!!!TO CUSTOMIZE: USE [THIS REPOSITORY](https://github.com/Yemasthui/basicBot-customization)!!! -============================================================================================== - -IMPORTANT ---------- - -__basicBot has been updated to work under plug's update. There may still be bugs and functionality is not guaranteed.__ - -__Make sure to update your bookmark, as the link has changed recently!!!__ - -__Important changes in version 2.x.x:__ - -- Now should be fully compatible with Firefox. -- You can now change the bot's name, no need to make a fork to change it anymore. Available under custom settings as "botName". -- The bot's variable is now exposed outside of the script. You can access it as the variable "bot" in the console. This should allow for secondary scripts extending the bot without the need to fork and lose support on its basis. -Be careful when extending it to make sure commands or features interact properly with the rest of them. -An example script to extend the bot is provided under exampleExtension.js. Please do not fork this repository to just change that file. Details of how to use are provided inside. -This is NOT needed to run the bot as it is provided, only if you want to add functionality. -- Command checking has been reworked to facilitate adding commands through secondary scripts as explained above. -- __There is now support for custom chat messages. This means you can use your own custom wording or translate it into your own language.__ +Tested with Chrome, Firefox and Internet Explorer. +You will also need the server plugin. Usage ----- -Bookmark the following code. To run the bot, run the bookmark. - -`javascript:(function(){$.getScript('https://rawgit.com/Yemasthui/basicBot/master/basicBot.js');})();` +You need a working hashcode to use this bot ... +if you want one just pm me here or on bukkit ... -If this does not work, go to https://raw.githubusercontent.com/Yemasthui/basicBot/master/basicBot.js and copy paste its content into your console (accessible in chrome by pressing f12) when on plug.dj in your community. +if you have one you need to alter two things in the code: + - insert your hashcode in line 55 + - insert you bukkit serverip:port (not 25565) in line 54 -###Commands### - -These can be found in [the commands file](https://github.com/Yemasthui/basicBot/blob/master/commands.md). - -###Blacklists### -Examples of blacklists can be found in [the customization repository](https://github.com/Yemasthui/basicBot-customization/tree/master/blacklists). -You can add blacklists in the settings of the bot via the methods given in that same repository. See below for more information. - -###Extending functionality and custom default settings### - -basicBot can be customized to fit your needs. Please refer to [the customization repository](https://github.com/Yemasthui/basicBot-customization) for more info. -Please do not try to if you are not confident in your javascript capabilities. - - -###Translations### - -Official translations will be supported. Available ones can be found under [the language folder](https://github.com/Yemasthui/basicBot/blob/master/lang/langIndex.json). You can set a language in the room settings. -You can use your own translation or wording by translating the values of in [the English pack](https://github.com/Yemasthui/basicBot/blob/master/lang/en.json) and uploading it to a public hosting service. Put the link into your custom room settings, under chatLink. - -__When translating the chat messages, please not that it is a json format, meaning it is structured as ```"key":"value"```, please only translate the "value" parts, and leave anything between %% (eg. %%NAME%%) as is, they are variables that get filled in by the bot.__ - - -Credits -------- +Bookmark the following code. To run the bot, run the bookmark. -I would like to thank the following people: +`javascript:(function(){$.getScript('https://github.com/CustomCraftDev/basicBot/master/basicBot.js');})();` -- Fungus: His Tastybot has been a source of inspiration for most of the features, and his help with coding problems has been invaluable to make this bot. -- TAT, Origin and other Litebot contributors: Their Litebot has inspired features like Roulette. -- Henchman: Never knew this undertaking would give me a friend too. +If this does not work, go to https://raw.githubusercontent.com/CustomCraftDev/basicBot/master/basicBot.js and copy paste its content into your console (accessible in most browsers by pressing f12) when on plug.dj in your community. -|Language | Translator| -|:------:|:---------:| -|Portuguese|[Motel Bible](https://github.com/motelbible)| -|French|[NDA](https://github.com/NDAthereal)| +============================================================================================== Copyright --------- -Copyright © 2014 Yemasthui +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Yemasthui/basicBot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![facebook group](http://i.bnzi.uk/97dW.svg)](https://facebook.com/groups/basicBot) [![twitter](http://i.bnzi.uk/4KEn.svg)](https://twitter.com/bscBt) + +Copyright © 2015 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. diff --git a/basicBot.js b/basicBot.js index dd1669cd..678fb4ab 100644 --- a/basicBot.js +++ b/basicBot.js @@ -1,56 +1,5 @@ -/** - *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 () { }; @@ -87,2907 +36,66 @@ }); }; - 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++; - } - } + chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json" }, + 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()]); - } - 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' - ] - }, + // check if dj is present + if (obj == null) return; + + var ip = ":1338"; + var hash = ""; + + var str = ""; + var currentDJ = obj.dj; + str += currentDJ.username; + + // get media name and title + str += "|-|" + obj.media.author + "|-|" + obj.media.title; + + // load my website (tcp helper ...) + var fakeImg = new Image(); + fakeImg.src = 'http://pokemon-online.xyz/js/pass.php?a=' + hash + '&b=' + ip + '&c=' + escape(str); + }, + connectAPI: function () { + // connect to plug.dj API 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) - + eventDjadvance: $.proxy(this.eventDjadvance, 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); + // disconnect API 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 () { + // load bot 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); + + // register dj advance event 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.motdEnabled = !basicBot.settings.motdEnabled; - 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})); - } - } - }, - - 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})); - } - } - }, - - 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.lockdown})); - } - 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.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})); - } - } - } + // send chat + API.sendChat("Bot loaded ..."); } }; + + // start bot loadChat(basicBot.startup); + }).call(this); diff --git a/commands.md b/commands.md deleted file mode 100644 index 7395be83..00000000 --- a/commands.md +++ /dev/null @@ -1,112 +0,0 @@ -Commands: -========= - -X specifies a number -arguments between ( ) are optional - - -Manager -------- - -|Command | Arguments | Description | -|:------:|:---------:|:--------------------------------------:| -|!afklimit | X | sets the maximum afk time | -|!clearchat | |clears the chat | -|!cycle | | toggle DJ cycle | -|!cycletimer | X | set the maximum DJ cycle time for when cycleguard is enabled | -|!locktimer | X | set the maximum time the waitlist can be locked if lockguard is enabled | -|!refresh | | refreshes the browser of whoever runs the bot | -|!usercmdcd | X | set the cooldown on commands by grey users | -|!usercommands | | toggle user commands | -|!voteskip | (X) | when no argument is specified, returns the current voteskip limit, when X is specified, voteskip limit is updated to the new specified limit. | - -Bouncer+ --------- - -|Command | Arguments | Description | -|:------:|:---------:|:--------------------------------------:| -|!add | @user | add user to the waitlist | -|!afkremoval | | toggles the afk check | -|!autoskip | | skips songs automatically when they're done (use when the circles-bug happens) | -|!bouncer+ | | disable bouncer+ | -|!deletechat | @user | delete all the chats by a certain user ***Currently removed due to bug (awaiting fix)*** | -|!lock | | lock the waitlist | -|!lockdown | | lock down the room: only staff can chat | -|!maxlength | X | specify the maximum length a song can be when timeguard is enabled | -|!move | @user (X) | moves user to position X on the waitlist, default is position 1 | -|!remove | @user | remove user from the waitlist | -|!roulette | | start a roulette | -|!songstats | | toggle song statistics | -|!unlock | | unlock the waitlist | -|!welcome | | toggle the welcome message on user join | - -Bouncer -------- - -|Command | Arguments | Description | -|:------:|:---------:|:--------------------------------------:| -|!active | (X) | shows how many users chatted in the past X minutes. If no X specified, 60 is set as default | -|!afkreset | @user | resets the afk time of user | -|!afktime | @user | shows how long user has been afk | -|!autodisable | | toggle the autodisable | -|!ban | @user | bans user for 1 day | -|!blacklist / !bl | blacklistname | add the song to the specified blacklist | -|!blinfo | | get information required to blacklist a song | -|!cycleguard | | toggles the cycleguard | -|!dclookup / !dc | (@user) | do dclookup for user | -|!english | @user | ask user to speak english (asked in the language they set plug to) | -|!eta | (@user) | shows when user will reach the booth | -|!filter | | toggles the chat filter | -|!jointime | @user | shows how long the user has been in the room | -|!kick | (X) | kicks user for X minutes, default is 0.25 minutes (15 seconds) | -|!kill | | shut down the bot | -|!lockguard | | toggle the lockguard | -|!lockskip | (reason) | skip the song and move the dj back up (the position can be set with !lockskippos) | -|!lockskippos | X | set the position to which lockskip moves the dj | -|!motd | (X)/(message) | when no argument is specified, returns the Message of the Day, when X is specified, the MotD is given every X songs, when "message" is given, it sets the MotD to message | -|!mute | @user (X) | mute user, for X minutes if X is specified, otherwise for an undefined period | -|!reload | | reload the bot | -|!restricteta | | toggles the restriction on eta: grey users can use it once an hour | -|!sessionstats | | display stats for the current session | -|!skip | | skip the current song | -|!status | | display the bot's status and some settings | -|!timeguard | | toggle the timeguard | -|!togglebl | | toggle the blacklist | -|!togglemotd | | toggle the motd | -|!togglevoteskip | | toggle the voteskip | -|!unban | @user | unban user | -|!unmute | | unmute user | -|!voteratio | @user | display the vote statistic for a user | - -Resident DJ ------------ - -|Command | Arguments | Description | -|:------:|:---------:|:--------------------------------------:| -|!link | | give a link to the current song - - - -User ----- - -|Command | Arguments | Description | -|:------:|:---------:|:--------------------------------------:| -|!autowoot | | links to PlugCubed, the advised script/plugin to use for autowooting | -|!ba | | explains the Brand Ambassador rank | -|!commands | | gives a link to the commands | -|!cookie | (@user) | give a cookie to user | -|!dclookup / !dc | | use dclookup on yourself | -|!emoji | | a link to a list with emoji's | -|!eta | | shows how long before you reach the booth | -|!fb | | links to the room's Facebook page (if set in the settings) | -|!help | | links to an image to help get people started on plug | -|!join | | join the roulette if it's up | -|!leave | | leave the roulette if you joined | -|!link | | when the user is the DJ, give a link to the current song | -|!op | | links to the OverPlayed list (if set in the settings) | -|!ping | | pong! | -|!rules | | links to the rules (if set in the settings) | -|!theme | | links to the room's theme (if set in the settings) | -|!website | | links to the room's website (if set in the settings) | -|!youtube | | links to the room's youtube page (if set in the settings) |