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

Crawler Type Bot? I see bots that can access the directory of rooms and randomly join one or another. #148

Open p0sixninja opened 11 years ago

p0sixninja commented 11 years ago

Iv been reviewing, as google has been my best friend along with the node.js handbook lately ;).. But this one, i cannot grasp...

on('roomChanged', function (data) { })

But how do i actually make the bot change rooms, and look through the active room directory...


Also...... Could you tell me why i can't call a IF statement inside of another IF statement? or any other way i could do this?

if (ccb == "enabled")
    {
    cconsole.log("#green[Console Color Setting Is Enabled] " + '#red[*(Beta)*]' + "#green[ Can Cause Unwanted Results]");
    if (alarmmessage == "true") {
    cconsole.log("#pink[This message will display ]" + alarmmessage + " #pink[more times]");
    } else {
    }

    } else {
    console.log("Console Color Setting Is Disabled");

    }

THANK YOU SO MUCH AGAIN Alain!

alaingilbert commented 11 years ago

When you want to change the current room, use bot.roomRegister(roomId);. To know what rooms are available, use bot.listRooms(callback);.

Finally, your code probably doesn't work, because you wrote console with two c. Next time, you should at least include the error message you get. Else nobody can help.

p0sixninja commented 11 years ago

Thanks for your help alain, the cconsole.log(""); is actually a colorize command for node.js..!

Thanks :)

p0sixninja commented 11 years ago

I guess my question would be, how would the bot know what rooms to join?, i see the callback function there, but in the automation side of this, what could i use to have the bot pick a random one?

technobly commented 11 years ago

This should work, I just reformatted it so you can see it better... is that how you wanted it nested?

the console has two c's because he's using the colorize script, and that's how they recommend wrapping the console function.

if you are setting alarmmessage to true like this -> var alarmmessage = true; then you should just make your if statement like this -> if(alarmmessage) and also if(ccb) can be done the same way.

Also if the second if statement is working, and you have a problem with your colorize function, it may barf on that... try a more simple log statement like cconsole.log("#pink[This message will display]");

if (ccb == "enabled")
{
    cconsole.log("#green[Console Color Setting Is Enabled] " + '#red[*(Beta)*]' + 
                         "#green[ Can Cause Unwanted Results]");

    if (alarmmessage == "true") 
    {
          cconsole.log("#pink[This message will display ]" + alarmmessage + " #pink[more times]");
    } 
    else 
    {
          //else stuff
    }
}
else 
{
    console.log("Console Color Setting Is Disabled");
}