alaingilbert / Turntable-API

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

Some more coding errors on my end, Im sure of it, Little Advice? <3 Thanks! #140

Closed p0sixninja closed 11 years ago

p0sixninja commented 11 years ago

Here is a compilation of issues, if anyone has any support on what i may be doing wrong, it would be greatly appreciated for my set of coding monkeys that are banging their heads on my keyboard... :P

**most of these are snags of code that i have "stolen" from other ttapi javascripts. Most of these, i have looked for variables that i may need to satisfy before i have pulled them into my scripts, with no success... ;/

The first one may be absolutely simple, but here goes.

This one i snagged from : http://code.google.com/p/tt-api-midori/source/browse/trunk/bots/dubcraft.js?r=4

// Server Reminder Message! setInterval(function() { bot.speak('Welcome, Sorry About the Buggy Bot!, It is under construction'); }, 20_60_1000);

This one just does nothing, iv made it the only line of code in the javascript , but nothing happens. Is this formatted wrong? or is this not allowed anymore :P?


The second one i have i see in every bot on turntable, after each song, it just displays how many times it was "upvoted" and "downvoted".............. But, as coded in the same code as the previous issue, it doesnt work..... any advice on where i could get a WORKING one? lol


The third issue may be simpler than i thought, but its up to your interpretation... I want to be able to make my bot DJ every good once and a while, iv seen it done, i just dont know how they would specify when the bot goes on stage, or could i call it from a command... ? OR am i just thinking too hard on this one, i see a code that will do this in the examples of the ttapi, but how do i call this into play?


The Fourth Issue, Probably simple, goes along with my first one,

I know the bot.bop(); thing is against the rules now... But is there any way i can make my bot upvote each song if 2 or three users vote the song up?


Thank you very much for anyone who could help me with even one of these issues,

much appreciated

P0SIXNINJA & PHOENIXSOFTWARE

alaingilbert commented 11 years ago

Hey !

First, you can't put this line alone in a file :

setInterval(function() { bot.speak('Welcome, Sorry About the Buggy Bot!, It is under construction'); }, 20*60*1000);

You need to initiate the bot variable before. Something like this :

var Bot    = require('ttapi');
var AUTH   = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var USERID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx';

var bot = new Bot(AUTH, USERID, ROOMID);

Also, 20*60*1000 this mean that the callback will be called every 20 minutes. So, you have to wait 20 minutes before the script does anything...


it just displays how many times it was "upvoted" and "downvoted"
bot.on('endsong', function(data) {
  ups = data.room.metadata.upvotes;
  downs = data.room.metadata.downvotes;
  bot.speak('Upvotes: ' + ups + ', Downvotes: ' + downs);
});

To make your bot a DJ, you simply have to call the following :

bot.addDj();

But is there any way i can make my bot upvote each song if 2 or three users vote the song up?
bot.on('update_votes', function(data) {
  ups = data.room.metadata.upvotes;
  if (ups == 2) {
    bot.bop();
  }
});

Hope it help :)

p0sixninja commented 11 years ago

Thank you so much, i feel like the basis of this is all making sense now.... I appreciate all of your help, and prompt responses with todays and yesterdays issues...