Giter VIP home page Giter VIP logo

nodecg-tiltify's Introduction

nodecg-tiltify is a NodeCG bundle. It works with NodeCG versions which satisfy this semver range: ^1.1.1

You will need to have an appropriate version of NodeCG installed to use it.

v5 API Changes

Re-complete setup, fields in the configuration have changed!

challenges -> targets replicant renamed to match tiltify.

Data is polled less frequently due to rate limits and webhook option.

If used in tandem with nodecg-tiltify-donation-reader that must ALSO be updated to v5 build

Setup

  1. Add nodecg-tiltify to your nodecg.dependencies in your bundle's package.json
  2. Create an application for your Tiltify account.
  3. Take the client id and secret from your application and add to configuration
  4. Lastly, provide the campaign id in the configuration. It can be found in the tiltify dashboard under Setup -> Information -> Public ID. Do not use Legacy ID
nodecg/cfg/nodecg-tiltify.json
{
	"tiltify_client_id": "KEY_HERE",
	"tiltify_client_secret": "KEY_HERE",
	"tiltify_webhook_id": "ID_HERE",
	"tiltify_webhook_secret": "KEY_HERE",
	"tiltify_campaign_id": "CAMPAIGN_HERE"
}

Setup Webhooks (Recommended)

Webhooks make donations and donation total updates come in realtime, it's recommended!

  1. Create a webhook within your newly created application, the endpoint URL will be the basepath of your nodecg + /nodecg-tiltify/webhook

     It must be on the world wide web, for example: `https://nodecg.example.com/nodecg-tiltify/webhook`
    
  2. Take webhook secret and add to configuration tiltify_webhook_secret, in the same file as in setup

  3. Take webhook ID and add it to configuration tiltify_webhook_id. The ID is the second UUID in the url for the page on tiltify.

Details

This bundle sets up NodeCG.Replicant objects in the nodecg-tiltify namespace.

Available Replicants from the Tiltify API:

  • donations*
  • alldonations**
  • total
  • donationpolls
  • donationmatches: (Coming soon)
  • schedule
  • donations
  • targets
  • rewards
  • campaign: (Coming soon)

The replicants convert results from the Tiltify API into objects, and more information on the exact format of the data from these replicants can be found in the Tiltify API docs.

*donations objects contain the additional properties read and shown which can be used to indicate if something was read in the dashboard or shown in a graphic. donations updates when the webhook posts an incoming donation, if webhooks are diabled donations also only collects donations from the most recent 'page' of the Tiltify API.

**alldonations contains all donations that have been made.

This bundle also has 3 messages that it listens for that can be sent using nodecg.sendMessageToBundle

  • clear-donations - Marks all donations as read
  • mark-donation-as-read - marks a specific donation as read
  • mark-donation-as-shown - marks a specific donation as shown

Note: this should be done in the form of nodecg.sendMessageToBundle('clear-donation', 'nodecg-tiltify') or nodecg.sendMessageToBundle('mark-donation-as-read', 'nodecg-tiltify', donationObject. The donation object sent to shown or read needs to at least have the donation ID so that the back end can find and mark.

nodecg-tiltify's People

Contributors

daniellockard avatar dependabot[bot] avatar forceh91 avatar nt3rp avatar stonemoney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nodecg-tiltify's Issues

Network disconnect results in unhandled promise rejection, causing nodecg to exit

When using the nodecg-tiltify bundle, I have found that when this bundle is correctly configured and running on a nodecg server, if the server is to lose network connection, the next API request made to Tiltify results in an unhandled promise rejection which ends up causing the nodecg server to exit.

Ideally this bundle should be able to gracefully handle network outages and not cause the entire server to crash.

Steps for reproduction:

  • Install nodecg and nodecg-tiltify on local computer
  • Confgure nodecg-tiltify with a Tiltify API key and Campaign id
  • Start nodecg and verify that nodecg-tiltfy is correctly pulling information from Tiltify
  • Disconnect computer from network (in my case turn off laptop wifi)

System info:

  • node version: 13.7.0
  • nodecg version: 1.5.0
  • nodecg-tiltify version: 1a0efcf

Crash log with API token censored:

RequestError: Error: getaddrinfo ENOTFOUND tiltify.com
    at new RequestError (/Users/jai.sharma/src/github.com/jai-x/nodecg/bundles/nodecg-tiltify/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/Users/jai.sharma/src/github.com/jai-x/nodecg/bundles/nodecg-tiltify/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/Users/jai.sharma/src/github.com/jai-x/nodecg/bundles/nodecg-tiltify/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/Users/jai.sharma/src/github.com/jai-x/nodecg/bundles/nodecg-tiltify/node_modules/request/request.js:185:22)
    at Request.emit (events.js:321:20)
    at Request.EventEmitter.emit (domain.js:485:12)
    at Request.onRequestError (/Users/jai.sharma/src/github.com/jai-x/nodecg/bundles/nodecg-tiltify/node_modules/request/request.js:881:8)
    at ClientRequest.emit (events.js:321:20)
    at ClientRequest.EventEmitter.emit (domain.js:485:12)
    at TLSSocket.socketErrorListener (_http_client.js:424:9)
    at TLSSocket.emit (events.js:321:20)
    at TLSSocket.EventEmitter.emit (domain.js:485:12)
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  name: 'RequestError',
  message: 'Error: getaddrinfo ENOTFOUND tiltify.com',
  cause: Error: getaddrinfo ENOTFOUND tiltify.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'tiltify.com'
  },
  error: Error: getaddrinfo ENOTFOUND tiltify.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'tiltify.com'
  },
  options: {
    url: 'https://tiltify.com/api/v3/campaigns/41257/donations',
    headers: {
      Authorization: 'Bearer CENSORED_API_TOKEN'
    },
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    resolveWithFullResponse: false,
    transform2xxOnly: false
  },
  response: undefined
}
UNCAUGHT EXCEPTION! NodeCG will now exit.
abort({"name":"RequestError","message":"Error: getaddrinfo ENOTFOUND tiltify.com","cause":{"errno":-3008,"code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"tiltify.com"},"error":{"errno":-3008,"code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"tiltify.com"},"options":{"url":"https://tiltify.com/api/v3/campaigns/41257/donations","headers":{"Authorization":"Bearer CENSORED_API_TOKEN,"simple":true,"resolveWithFullResponse":false,"transform2xxOnly":false}}). Build with -s ASSERTIONS=1 for more info.

Team total from all members vs team's direct total

I'm working on using this to pull data from a team's campaign. I noticed that in the Tiltify API (and tiltify-api-client), there are two separate total fields: amountRaised for what was given directly to the team, and totalAmountRaised for all donations, including those given to members' supporting campaigns.

Right now this package only surfaces the former. It should also include a new field for the team total. I can open a PR for this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.