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

Song Stats #172

Closed ghost closed 11 years ago

ghost commented 11 years ago

How do you make the bot do stats at the end of the song.

technobly commented 11 years ago

Add something like this to your bot... notice some of the variables I didn't use, and even more in the endsong data


bot.on('endsong', function (data) { 
  var currentdj = data.room.metadata.current_dj;
  var song = data.room.metadata.current_song.metadata.song;
  var artist = data.room.metadata.current_song.metadata.artist;
  var album = data.room.metadata.current_song.metadata.album;
  var up_votes = data.room.metadata.upvotes;
  var down_votes = data.room.metadata.downvotes;
  var listeners = data.room.metadata.listeners;

  bot.speak(song +" ( "+up_votes+" :+1: "+down_votes+" :-1: "+snagCounter+" <3 "+listeners+" :busts_in_silhouette: )");

});

https://github.com/alaingilbert/Turntable-API/blob/master/turntable_data/endsong.js

ghost commented 11 years ago

ok, thank you so much

technobly commented 11 years ago

You're welcome! Don't forget to close the issue if this answers your question.

SpaceLegends commented 11 years ago

It look like there a error by an snagCounter

technobly commented 11 years ago

Yeah, snagCounter is a global variable that is incremented when bot.on('snagged', function(data) { } ); occurs. It's reset in bot.on('newsong', function(data) { } );