Skip to content

Commit

Permalink
Support for simple-donation-ticker, fixed triggers disapearing
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxfoo committed May 1, 2021
1 parent c76676e commit 6bc034d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

This nodecg bundle listens for LBC tips from odysee hyperchat's and renders an alert using the simple-alerts bundle.

I will create a portable version containing node.js, nodecg and the 2 bundles for an easy setup some time this week.
In future releases, this bundle may make use of other bundles such as:
* donation ticker
* chat overlay
* tip history
* top tipper

In releases, you can find a portable version containing nodecg and simple-alerts for Windows and Linux that is ready to go, just extract it and run it.
8 changes: 5 additions & 3 deletions dashboard/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
testInput.setAttribute('id', 'testInput');

var testBtn = document.createElement('button');
testBtn.setAttribute('type', 'submit');
//testBtn.setAttribute('type', 'submit');
testBtn.setAttribute('id', 'testBtn');
var testBtnLabel = document.createTextNode("TEST");
testBtn.appendChild(testBtnLabel);
Expand All @@ -83,10 +83,12 @@
form.appendChild(document.createElement("br"));
div.appendChild(form);

NodeCG.waitForReplicants(triggers, claim_id, defaultTrigger, test).then(() => {
NodeCG.waitForReplicants(triggers, claim_id, defaultTrigger).then(() => {
document.getElementById('defaultInput').value = defaultTrigger.value;
document.getElementById('claimidInput').value = claim_id.value;
triggers.value.forEach(showPanels);
if (triggers.value) {
triggers.value.forEach(showPanels);
}
});

function showPanels(value, index, array) {
Expand Down
17 changes: 15 additions & 2 deletions extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ module.exports = function (nodecg) {
});
}

function addToTicker(username, amount) {
var myJSONObject = {"name": username, "amount": amount};
request({
url: 'http://localhost:9090/simple-donation-ticker/ticker',
method: "POST",
json: true,
body: myJSONObject
}, function (error, response, body){
console.log("Done");
});
}

function checkTriggers(amount, alertName) {
equals.forEach(isEquals);
// Check if alert is equal too a trigger
Expand All @@ -37,8 +49,8 @@ module.exports = function (nodecg) {
}
if ( alertName == defaultTrigger.value ) {
// Check greater than starting from largest number.
var sorted = triggers.value;
sorted.sort(function(a, b){return b.amount - a.amount});
var sorted = [...triggers.value];
sorted.sort( function (a, b) { return b.amount - a.amount } );
for (const value of sorted) {
if ( value.type != "equals" && parseFloat(amount) >= parseFloat(value.amount) ) {
alertName = value.name;
Expand Down Expand Up @@ -83,6 +95,7 @@ module.exports = function (nodecg) {
var alertName = defaultTrigger.value;
var amount = comment.data.comment.support_amount

addToTicker(userName, amount);
alertName = checkTriggers(amount, alertName);
activateAlert(alertName, userName, amount);
}
Expand Down

0 comments on commit 6bc034d

Please sign in to comment.