Hello,
I am working on a Twitch Bot with Philips Hue intergration.
I have gotten the core futures to work. (Sub change color) But when i try to add “Cheer” system the bot recognise it but dosnt send it to the “hue” script.
so if there is anyone out there that have done this with NodeJS i would love your help!
This is what the bot has:
Bot.js
////Listen chat messages for cheers client.on("cheer", function (channel, userstate, message) { console.log(chalk.blue(" Cheers Accepted " + userstate.bits)); if(userstate.bits >= config.cheerLimit){ //If users bit amount is not bigger that Hue trigger amount dont go in. You can change this in config.js hue.hueLamp(userstate.bits); } });
And this is the hue part of the script:
function hueLamp(alertType){
if(status === 1){ // If there is an alert happening put the new alert to queue
jobQueue.push(alertType);
console.log("New job request (" + alertType + ") has been added to queue as there is an ongoing process");
}
else {
status = 1; // Lock alert to this one
console.log("Active job: " + alertType);
var alertName = ""; // Used later
// If you want lower or higher bits to trigger alerts modify cheerOptions in config.js
if(alertType >= config.cheerOptions.cheerTier1 && alertType < config.cheerOptions.cheerTier2){
alertName = "bit_t1";
}
else if(alertType >= config.cheerOptions.cheerTier2 && alertType < config.cheerOptions.cheerTier3){
alertName = "bit_t2";
}
else if(alertType >= config.cheerOptions.cheerTier3 && alertType < config.cheerOptions.cheerTier4){
alertName = "bit_t3";
}
else if(alertType >= config.cheerOptions.cheerTier4){
alertName = "bit_t4";
}
else{
alertName = alertType;
}
var intervalID = setInterval(function () { // Loops until there is no jobs in queue
config.hueLamps.map(function(lampID) { changeColor(lampID, alertName); });
if (++lampTimer >= colorEffects[alertName].blinkTime) {
clearInterval(intervalID);
config.hueLamps.map(function(lampID) { changeColor(lampID, "normal"); });
status = 0;
console.log("Jobs Done! Checking queue for more jobs.");
if(jobQueue.length > 0) {
console.log("New Job!");
var newAlertType = jobQueue[0];
jobQueue.shift();
// Change timeBetweenAlerts in config to extend or shorten time between each job
setTimeout(function(){ hueLamp(newAlertType);}, config.timeBetweenAlerts);
}
}
}, colorEffects[alertName].blinkMS);
}
lampTimer = 0;
};
what the different cheerTires is.
var cheerOptions = {
cheerTier1: 100,
cheerTier2: 1000,
cheerTier3: 5000,
cheerTier4: 10000
}
If someone can help me with this and find a soluiton it would be greate.
Each "alertName " is in another file where i store the colors! (example = alertName = “bit_t4”; )
Greetings,
Broccoli