Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twitch-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitch-toolkit

A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.

  • 0.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-58.33%
Maintainers
1
Weekly downloads
 
Created
Source

twitch-toolkit

License Build Status

A set of tools to integrate with Twitch API, Twitch Chat and Twitch WebHooks.

NPM

To start to use this module, check the project documentation

Installation

Using npm:

$ npm i --save twitch-toolkit

Usage

The library is composed by three modules:

  • api: Provides access to the Helix API.
  • chat: Provides access to the chat events through tmi.js .
  • websub: Provides access to the websubs topics and events.

You can use the toolkit just by creating a new instance with the configuration object:

const twitch = require('twitch-toolkit');

var twitch = new Twitch(config);

The config object is described below:

AttrTypeDescription
loggerobjectThe logger instance.
debugboolA flag to enable the debug mode. Default: false
client_idstringThe Twitch.tv client ID to be used to access the services.
client_secretstringThe Twitch.tv client secret to be used to use the private services.
chatOptionsobjectThe chat configuration object
chatOptions.reconnectboolA flag to enable the auto-reconnect mode. Default: false
chatOptions.ignoreSelfboolA flag to ignore the bots own messages. Default: false
chatOptions.usernamestringThe bot's username.
chatOptions.passwordstringThe bot's OAuth Token. You can get it at http://twitchapps.com/tmi/
chatOptions.channelsarray[string]The list os channels the bot will join and listen.
chatOptions.chatCommandsobjectThe object with the chatCommands, described below
chatOptions.whisperCommandsobjectThe object with the whisperCommands, described below
chatOptions.wordTriggersobjectThe object with the wordTriggers, described below

API

The API module will be created with the toolkit object and can be acessed by its name:

var twitchAPI = twitch.api;

The methods are described in the TwitchApi documentation page

Chat

The chat module will be created with the toolkit new instance but, the user will only join and list to the chat when connect is executed:

var twitchChat = twitch.chat;

twitch.connect();

After that, you'll be able to listen to channel and chat events. You can also disconnect from the chat, if you wish:

twitch.disconnect()

The methods and events are described in the TwitchChatEmitter documentation page

Webhooks

The Twitch Webhooks implementation, as described in https://dev.twitch.tv/docs/api/webhooks-guide/ .

To access the Webhook module:

The API module will be created with the toolkit object and can be acessed by its name:

var twitchWebSub = twitch.websub;

The Webhook/WebSub requires a public endpoint on the running express server/application to receive the data from the hub. Without this, its impossible to make this work.

The methods and events are described in the TwitchWebSub documentation page

Tests

The module uses Mocha with Chai for unit tests and Istanbul for test coverage reports.

To run the mocha tests:

$ npm run test

To run the tests with the coverage report:

$ npm run test:coverage

To properly run the tests, the following Environment Variables must be set:

Var NameValue
TWITCH_CLIENT_IDThe Client-ID to be used to make the API calls.
TWITCH_CLIENT_SECRETThe Client Secret to be used to make the API calls.
TWITCH_CLIENT_USERNAMEThe Username related to the Client-ID
TWITCH_CLIENT_PASSWORDThe OAUTH password. It can be generated here.

License

Licensed under the MIT License.

Keywords

FAQs

Package last updated on 15 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc