Skip to content
alaingilbert edited this page Apr 14, 2012 · 10 revisions

These are some functions to get you started with a DJ bot. (A bot that you allow to DJ).

if (text.match(/^\*youcandj$/)) {
   if (data.userid != "youruserid") { bot.speak("You ain't my master."); }
   else                             { bot.addDj();                       }
}

*This is the function that adds the DJ to the table using the command youcandj *Inversely, to remove your bot as a DJ, use the nomoredj command:

if (text.match(/^\*nomoredj$/)) {
   if (data.userid != "youruserid") { bot.speak("You ain't my master."); }
   else                             { bot.remDj();                       }
}

*But that's not enough. How are you going to add songs? How about with addsong

if (text.match(/^\*addsong$/)) {
   bot.roomInfo(true, function(data) {
      var newSong = data.room.metadata.current_song._id;
      var newSongName = songName = data.room.metadata.current_song.metadata.song;
      bot.playlistAdd(newSong);
      bot.speak('Added '+newSongName+' to queue.');
   });
}

Special note for this: rather than like adding it to a queue, this song will go to the top, not the bottom. Also, as of now, I know of no way to adjust the queue.

*And you can use skip to skip the song

if (text.match(/^\*skip$/)) {
   if (data.userid != "youruserid") { bot.speak("You ain't my master."); }
   else                             { bot.skip();                        }
}

You may notice the 'youruserid' part floating in there. That is to ensure that only you can control the bot's DJ function.

These scripts are from my bot, #Ringwold.

Clone this wiki locally