Skip to content

Enhancement: Bot DJ commands #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ If this does not work, go to [basicBot.js](https://github.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).
Expand Down
212 changes: 210 additions & 2 deletions basicBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
}
}
},
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,26 @@
| !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. |
| !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. |
| !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. |
Expand Down