SupportClass / lfg-sublistener

Easy Twitch subscription events for NodeCG
MIT License
8 stars 4 forks source link

lfg-sublistener Build Status

This is a NodeCG bundle.

Listens to one or many Twitch chat channels via IRC for "subscription" events. Upon hearing one, it emits a NodeCG API message that other bundles can listen to and use. Also displays recent subscriptions on the dashboard.

If lfg-twitchapi is present, sublistener will also poll the API every 60 seconds to fill in any gaps left by TwitchNotify.

This bundle integrates with lfg-nucleus.

Installation

Config Example

{
    "tmi.js": {
        "connection": {
            "reconnect": true
        },
        "identity": {
            "username": "YOUR_USERNAME",
            "password": "oauth:YOUR_OAUTH"
        },
        "channels": ["ANY_CHANNEL"]
    }
}

Usage

First, add lfg-sublistener to your bundle's nodecg.bundleDependencies. This will ensure that lfg-sublistener loads before your bundle.

In a graphic or dashboard panel

nodecg.listenFor('subscription', 'lfg-sublistener', subscription => {
    // do work
});

In an extension

module.exports = function (nodecg) {
    var sublistener = nodecg.extensions['lfg-sublistener'];

    sublistener.on('subscription', data => {
        // do work
    });
}

Data Structure

{
    "name": "langeh",
    "channel": "chrishanel",
    "resub": true,
    "months" 3,
    "timestamp": 1456850909701,
    "prime": false
}

License

lfg-sublistener is provided under the MIT license, which is available to read in the LICENSE file.