alaingilbert / Turntable-API

Allows you to create bots for turntable.fm
http://alaingilbert.github.com/Turntable-API/
MIT License
318 stars 97 forks source link

Looking for help for a snag bot. #250

Closed TTbots closed 10 years ago

TTbots commented 10 years ago

I have a basic dj bot that uses the autodj.js script. It works great. If I wanted the bot to just snag songs from only me (UID?) so i can load his playlist... how would i go about doing that? Thanks in advance for your help.

bot.on('newsong', function (data) {
  bot.snag();
  bot.playlistAdd(data.room.metadata.current_song._id);
  bot.becomeFan(data.room.metadata.current_dj);
});
gizmotronic commented 10 years ago

@TTbots, if you look at the object provided by the newsong event, you'll notice that the room.metadata.current_dj property tells you the user ID of the current DJ. Compare that to your own user ID and use the playlistAdd method if they match. (The snag method triggers the heart animation, if you want to do that, but it's not required.)

alaingilbert commented 10 years ago

@gizmotronic got it right. Compare the current dj id provided by the newsong event with your own id.

TTbots commented 10 years ago

@gizmotronic @alaingilbert Thanks for the quick response, but I know absolutely nothing about writing the code to do it. :(