Closed p0sixninja closed 11 years ago
Well... Now i seem to be having the same exact issue with the bot.say on the interval clock now, so every 10 seconds, my chat is spammed like a million times saying "Welcome, Sorry About the Buggy Bot!, It is under construction", Kinda Explains Itself alot by saying its buggy :P
If you would like to take a look at my code, here it is:
Thanks For Your Help
I Figured Out How To Do Some Colorizing, Theres a excellent JS code called colorize, i forked it :P.... Currently working on setting it up..
Thanks, Now if i could fix the spam issue :D
@p0sixninja, I fixed up your code a bit. You had your endsong and update_votes INSIDE the speak handler, so every time the chat got updated, those functions would get called. I added some nice things in there... study it for a bit and ask me any questions you want about it.
@p0sixninja, as for newsong data in the console:
bot.on('newsong', 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 length = data.room.metadata.current_song.metadata.length;
var song_id = data.room.metadata.current_song._id;
//If you are keeping track of the users in your room, you can look up the name
var username = theUsersList[currentdj].name;
Log("[ NEW SONG ] : "+username+" started playing: "+song+" by "+artist+" "+length+" "+song_id);
});
@p0sixninja, I just updated the pastebin link with colorize code... http://pastebin.com/M9Z6QHEd I've tested it in my bot and it works! Thanks for this I was wondering how to do this and just never thought to look.
This is essential the part that does the colorizing:
// https://github.com/mattpat/colorize
// Install with "npm install colorize"
// Example:
// #bold[Welcome to the #green[Green Machine] tool!]
// Currently colorize supports the standard set of 8 ANSI colors
// (black, red, green, yellow, blue, magenta, cyan, white),
// along with bold, italic, underline, blink, and a special "reset" keyword.
global.colorize = require('colorize'); //Add color to the console!
global.cconsole = colorize.console;
function Log (msg) {
cconsole.log(msg);
}
Log('#green[Script Started]');
It still spams the room ;/ as well as the console.... But thanks
@p0sixninja O_O wut... no way man... make sure you are running the right file. I'll actually go test it now myself.
// endsong event function bot.on('endsong', function(data) { ups = data.room.metadata.upvotes; downs = data.room.metadata.downvotes; bot.speak('Up-votes: ' + ups + ', Down-votes: ' + downs); });
This is the one you provided, it still spams the chat box still, im scratching my head at this one...
I'm testing it right now and it's working... there were some other bugs though. Once I know it works completely I'll report back.
THANK YOU!
@p0sixninja ok it's working, please just run the entire file I provide here: http://pastebin.com/M9Z6QHEd
@DubbyTT Thank you for your help, however i would like to figure out why this is doing this, and prevent it from happening in my future scripts, your help is so appreciated..... @alaingilbert do you have any insight as to why this issue is happening, and how i could prevent it?
@p0sixninja I just got done running the file I provided you and it works fine... I'll draw a picture to show you why your code was doing what it was doing.
The spam is happening because you did something like this :
bot.on('speak', function(data) {
bot.on('endsong'...);
});
Basically what is happening is that every time, someone is speaking, you add a new listener for the "endsong" event. So, when the endsong is called, there is like "20" (or more, this number is fictive) callbacks binded to this signal...
@alaingilbert , So to fix this i just need to make sure the endsong is not under a speak function?
Thanks
In your example it should be something like :
bot.on('speak', function(data) {
});
bot.on('endsong'...);
instead
Ohhh! Okay! I see what is going on here!, Thank you @alaingilbert And @DubbyTT !
@p0sixninja I guess it's easier to type that then what I did... here it is anyway :)
THANKS FOR DOING THIS!!! THAT IS A EXCELLENT DRAWING :D
Hello There!
Im having a issue with this script,
bot.on('endsong', function(data) { ups = data.room.metadata.upvotes; downs = data.room.metadata.downvotes; bot.speak('Up-votes: ' + ups + ', Down-votes: ' + downs); });
It runs just fine, but for some reason it just spams the chatroom with the data received from the function, until it seems the bot is disabled from talking for a short period of time... Is there any way to fix this??
Is there any way i could display the songs name on the console when the song starts playing? I understand the 'newsong' command, but im a little confused on how/what variable it would be to recall the variable set from the newsong command into a console.log(NEWSONGNAMEHERE)
Third And Last Question :P,
Is there any way i can add color to my node.js console? Iv seen sparklebot do it, but im just curious as how i could incorperate it into my console....
THANK YOU SO MUCH ONCE AGAIN! :D