diff --git a/README.md b/README.md index 246ed549..a8cfca06 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,21 @@ If this does not work, go to [basicBot.js](https://raw.githubusercontent.com/bas These can be found in [the commands list](commands.md). +### Bot DJ + +Bots can now join the wait list and dj along with you. See the noted commands in the commands section. +Anyone with a role of Bouncer or higher can run the bot's dj commands. + +Expected usage: +1. Ensure the account running the bot has at least one playlist and a playlist set to active and start the bot as usual. +2. Others can then type !listjoin, !jumpup, or !dj into the room chat to have your bot join the waitlist. +3. When done, type !listleave, !jumpdown, or !dj to have your bot leave the waitlist. + +Grab - Adding to the bot playlist: +Run the !grab command to tell the bot to grab the current song. The song will be added to the bot's current active playlist. + +Users can also use !showplaylists or !botpls to list the bot's available playlists and !switchplaylist or !botpl to switch the bot's current playlist. + ### Blacklists Examples of blacklists can be found in [the customization repository](https://github.com/basicBot/custom/tree/master/blacklists). diff --git a/basicBot.js b/basicBot.js index e78e0c66..2f8db1b5 100644 --- a/basicBot.js +++ b/basicBot.js @@ -576,7 +576,120 @@ return msg; } }, + botInterfaceUtilities: { + grab: function() { + $('#grab').click(); + setTimeout(function (){ + $('.pop-menu.grab > .menu > ul > li > i.icon-check-purple').parent().mousedown(); + }, 500); + }, + listJoin: function() { + el = $('#dj-button'); + // Check that bot is not already djing or waiting. + if(el.hasClass('is-join') || el.hasClass('is-wait')){ + el.click(); + } + }, + listLeave: function() { + el = $('#dj-button'); + // Check that the bot is djing or waiting. + if(el.hasClass('is-quit') || el.hasClass('is-leave')){ + el.click(); + setTimeout(function (){ + $('#dialog-confirm > .dialog-frame .submit').click(); + }, 500); + } + }, + listToggle: function() { + el = $('#dj-button'); + el.click(); + // If we are quitting or leaving, handle the confirmation popup. + if(el.hasClass('is-quit') || el.hasClass('is-leave')){ + setTimeout(function (){ + $('#dialog-confirm > .dialog-frame .submit').click(); + }, 500); + } + }, + meh: function() { + $('#meh').click(); + }, + togglePlaylistDrawer: function(wait){ + if ($.isNumeric(wait)) { + // If we were passed a wait time, wait. + setTimeout(function(){ + $('#playlist-button').click(); + }, wait); + }else{ + // no wait time, do it now. + $('#playlist-button').click(); + } + }, + showPlaylists: function() { + basicBot.botInterfaceUtilities.togglePlaylistDrawer(); + setTimeout(function(){ + var playlists = $('#playlist-menu .row').map(function( index ){ + var lead = '--- '; + var trail = ' ---'; + if($(this).hasClass('selected') === true) { + lead = '==> '; + var trail = ' ==='; + } + var id = index+1; + + var msg = lead + id + ": " + $( this ).children('.name').text() + trail; + return msg; + }).get(); + var len = playlists.length; + var msg = ''; + var waittime = 250; + for(var i = 0; i < len; i++) { + waittime += 250; + setTimeout(function(msg){ + API.sendChat(msg); + }, waittime, playlists[i]); + } + basicBot.botInterfaceUtilities.togglePlaylistDrawer(1500); + + }, 500); + }, + shufflePlaylist: function() { + basicBot.botInterfaceUtilities.togglePlaylistDrawer(); + setTimeout(function(){ + $('#playlist-shuffle-button').click(); + basicBot.botInterfaceUtilities.togglePlaylistDrawer(500); + }, 250); + }, + switchPlaylist: function(listname) { + basicBot.botInterfaceUtilities.togglePlaylistDrawer(); + if($.isNumeric(listname)) { + setTimeout(function(){ + $('#playlist-menu .container .row:nth-child('+listname+')').mouseup(); + setTimeout(function(){ + $('#playlist-menu .container .row:nth-child('+listname+')').children('.activate-button').click(); + }, 500); + }, 250); + }else{ + setTimeout(function(){ + el = $('#playlist-menu span:contains("'+listname+'")'); + if(el.length > 0){ + $('#playlist-menu span:contains("'+listname+'")').parent().mouseup(); + setTimeout(function(){ + $('#playlist-menu span:contains("'+listname+'")').siblings('.activate-button').click(); + }, 500); + } + }, 500); + } + basicBot.botInterfaceUtilities.togglePlaylistDrawer(500); + + setTimeout(function(){ + basicBot.botInterfaceUtilities.showPlaylists(); + }, 1000) + }, + woot: function() { + $('#woot').click(); + } + }, roomUtilities: { rankToNumber: function(rankString) { var rankInt = null; @@ -2571,6 +2684,19 @@ } }, + grabCommand: { + command: 'grab', + 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 { + basicBot.botInterfaceUtilities.grab(); + } + } + }, + helpCommand: { command: 'help', rank: 'user', @@ -2819,6 +2945,45 @@ } }, + listjoinCommand: { + command: ['listjoin', 'jumpup'], + 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 { + basicBot.botInterfaceUtilities.listJoin(); + } + } + }, + + listleaveCommand: { + command: ['listleave', 'jumpdown'], + 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 { + basicBot.botInterfaceUtilities.listLeave(); + } + } + }, + + listtoggleCommand: { + command: ['listtoggle', 'botdj', 'dj'], + 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 { + basicBot.botInterfaceUtilities.listToggle(); + } + } + }, + lockCommand: { command: 'lock', rank: 'mod', @@ -3026,7 +3191,7 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void(0); if (!basicBot.commands.executable(this.rank, chat)) return void(0); else { - $('#meh').click(); + basicBot.botInterfaceUtilities.meh(); } } }, @@ -3357,6 +3522,32 @@ } }, + showplaylistsCommand: { + command: ['showplaylists', 'botpls'], + 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 { + basicBot.botInterfaceUtilities.showPlaylists(); + } + } + }, + + shuffleCommand: { + command: 'shuffle', + 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.botInterfaceUtilities.shufflePlaylist(); + } + } + }, + skipCommand: { command: ['skip', 'smartskip'], rank: 'bouncer', @@ -3640,6 +3831,23 @@ } }, + switchPlaylistCommand: { + command: ['switchplaylist', 'botpl'], + 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; + + var listname = msg.substring(cmd.length + 1); + basicBot.botInterfaceUtilities.switchPlaylist(listname); + } + } + }, + themeCommand: { command: 'theme', rank: 'user', @@ -4203,7 +4411,7 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void(0); if (!basicBot.commands.executable(this.rank, chat)) return void(0); else { - $('#woot').click(); + basicBot.botInterfaceUtilities.woot(); } } }, diff --git a/commands.md b/commands.md index 7eb358fd..107703b0 100644 --- a/commands.md +++ b/commands.md @@ -62,10 +62,14 @@ | !eta | (@user) | shows when user will reach the booth. | | !filter | — | toggles the chat filter. | | !forceskip / !fs | — | forceskips the current song. | +| !grab | - | Tells the bot to grab the current song and add to their current playlist. (See Bot DJ section of README.md) | | !historyskip | — | toggles the history skip. | | !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. | +| !listjoin / !jumpup | - | Tell the bot to start djing or join the wait list. (See Bot DJ section of README.md) | +| !listleave / !jumpdown | - | Tell the bot to stop djing or leave the wait list. (See Bot DJ section of README.md) | +| !listtoggle / !botdj / !dj | - | Shortcut to do !listjoin or !listleave as appropriate. (See Bot DJ section of README.md) | | !lockguard | — | toggle the lockguard. | | !lockskip | (reason) | skips, locks and moves the dj back up (the position can be set with `!skippos)`. | | !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. | @@ -73,8 +77,11 @@ | !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. | +| !showplaylists / !botpls | - | makes the bot list its playlists. (See Bot DJ section of README.md) | +| !shuffle | - | Tell the bot to shuffle their playlist, useful after !grab if the bot is djing. (See Bot DJ section of README.md) | | !skip / !smartskip | (reason) | skips the dj using smartskip. actions such as locking and moving user depends on various factors (the position the dj is moved to can be set with `!skippos`). | | !status | — | display the bot's status and some settings. | +| !switchplaylist / !botpl | @playlistID | playlistID can be either the full playlist name, or the id of the playlist in the list displayed by !showplaylists (See Bot DJ section of README.md) | | !timeguard | — | toggle the timeguard. | | !togglebl | — | toggle the blacklist. | | !togglemotd | — | toggle the motd. |