Closed ghost closed 11 years ago
You might like to do something like this to figure out what the events do (in this case the "registered" event):
bot.on('registered', function (data) {
console.log('saw registered event', data);
});
You could do this for any event type to see what kind of data Turntable sends you.
Instead of asking how to do every minor thing, how about looking at some of the other bots and see how they do it. You'll learn quite a bit from doing that. I know I did.
Most questions I have seen could be answered by saying look at Sparkle or Uglee. I know I used quite a bit of what I learned from Sparkle and a couple others then made it my own. On May 4, 2013 9:52 AM, "Turntablelover" notifications@github.com wrote:
How can I code a room greeting for my bot.
Room Greeting is a a greeting that welcomes listeners to the turntable.fmroom.
— Reply to this email directly or view it on GitHubhttps://github.com/alaingilbert/Turntable-API/issues/189 .
+1
oh, ok. I just wanted help coding it but no, you guys decided to be mean to me and give no help and said that I was wasting your time asking about minor stuff for my bot all the time.
here's simple greeting example to get you started... i added the timeout because i noticed that after the gui change if you try and send the greeting the second they join the room it doesn't show up for the person joining the room. at least it doesn't for me...
bot.on('registered', function (data)
{
setTimeout(function ()
{
bot.speak(data.user[0].name + ', welcome to my room!'); //send it in the chatbox
bot.pm('welcome to my room!', data.user[0].userid); //send it in the pm
}, 3 * 1000); //slow it down 3 seconds
});
thanks samuri51, your the nicest person ever that I met on here.
@Turntablelover stop being so dramatic. You've received more help on here than any other single person I've seen over the last year. Be grateful for that. This community is one of the best. Do yourself a favor and listen to what @MikeWills is saying. You will never learn how to do any of this properly if you just ask for every piece of it to be coded for you. It's not easy, but googling for things like "javascript array" and "javascript splice", etc. will give you lots of simple examples on how to do things with javascript. If you are looking at a bot and don't understand what's going on with some code, just google the parts with the word javascript and start reading. If you don't want to understand it, just install a full featured bot and be done.
To expand on @gizmotronic 's good idea, which I've used a lot myself, try
console.log(JSON.stringify(data, null, ' '));
to make it more readable.
ok, I will stop being dramatic.
@DubbyTT, I had never considered that JSON.stringify() might take additional params - thanks for that tip :)
How can I code a room greeting for my bot.
Room Greeting is a greeting that welcomes listeners to the turntable.fm room.