This is a NodeCG bundle.
Listens for donations to a given account on Barry's Donation Tracker and emits API events for other bundles to use. Also displays stats on the dashboard and easily allows the user to reset said stats.
- Install to
nodecg/bundles/lfg-doncorleone
- Create
nodecg/cfg/lfg-doncorleone.json
with the username and password of the Barry's Donation Tracker account that you wish to listen to:
{
"username": "myUsername",
"password": "myPassword"
}
If you simply want to see top donations for the day
and month
periods on your dashboard, you are done.
If you would like to use this data in another bundle, add the following code to your view/panel:
nodecg.listenFor('tip', 'lfg-doncorleone', callback);
... where 'callback' is the name of a function with the signature function callback(data)
If you want to use donation events in another bundle's extension,
add lfg-doncorleone
as a bundleDependency
in your bundle's nodecg.json
Then add the following code:
var donCorleone = nodecg.extensions['lfg-doncorleone'];
donCorleone.on('initialized', function initialized(data) {
// do work
// data.Completed = Array of recently completed donations
// data.totals = Object containing stats such as data.totals.day_top and data.totals.month_top
// Other properties exist as well
));
donCorleone.on('gotDonations', function gotDonations(data) {
// do work
// data object is the same as in the 'initialized' event
// However, in this event 'data.Completed' is only newly completed donations.
// Example of iterating over the data.Completed property and processing each new donation
data.Completed.forEach(function(donation) {
console.log(donation);
});
));
lfg-doncorleone is provided under the MIT license, which is available to read in the [LICENSE][] file. [license]: LICENSE