An open API service indexing awesome lists of open source software.

https://github.com/supportclass/streen

A centralized WebSocket Twitch Chat interface
https://github.com/supportclass/streen

Last synced: 7 months ago
JSON representation

A centralized WebSocket Twitch Chat interface

Awesome Lists containing this project

README

          

# Streen [![Build Status](https://travis-ci.org/SupportClass/streen.svg?branch=master)](https://travis-ci.org/SupportClass/streen) [![Coverage Status](https://coveralls.io/repos/github/SupportClass/streen/badge.svg?branch=master)](https://coveralls.io/github/SupportClass/streen?branch=master)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Streen is a centralized interface for interacting with Twitch Chat. It is essentially a wrapper for
[tmi.js](https://docs.tmijs.org/), and it operates via Socket.IO websockets.

Streen is useful in situations where multiple processes all need to connect to Twitch Chat,
but the overhead of spinning up multiple and managing multiple chat bots is not acceptable.
Streen operates as a single bot and exposes a websocket API.

## Motivation
I maintain many production [NodeCG](https://github.com/nodecg/nodecg) instances. Most of these NodeCG instances need to connect to Twitch chat for one reason or another. At first, I had each of these NodeCG instances spin up their own [tmi.js](https://docs.tmijs.org/) bot and connect to Twitch chat directly. However, this wound up causing problems whenever a breaking change happened, as I would have to go update tmi.js manually on each of the many deployments. Streen centralizes this external dependency into one place, making it easier to keep up with changes on Twitch's end.

## Installation
- [Deploying to Heroku (recommended)](#deploying-to-heroku)
- [Manual installation](#manual-installation)

### Deploying to Heroku
- Click the "Deploy to Heroku" button at the top of this README.
- Fill out the form. Be sure to provide all required config variables.
- If using a free dyno (the default), you'll need to prevent it from sleeping.
This can be done by periodically pinging the dyno. [Apex Ping](https://ping.apex.sh/) and
[Pingdom](https://www.pingdom.com/) are two options for this, but there are many ways to prevent a free web dyno from
sleeping.

### Manual Installation
- Clone the repository
- From the directory you cloned Streen into, run `npm install --production`
- Create `./config.json` with the desired `twitch.username`, `twitch.password`, and `secretKey`.
The `secretKey` is a pre-shared key that all clients must provide in order to use the websocket API.
- Optionally, add a [`slack.botToken`](https://my.slack.com/services/new/bot) and `slack.statusChannel`
to have Streen post critical status updates and respond to commands.
[(Need an avatar for your bot?)](http://i.imgur.com/7LNvGeK.jpg)
```json
{
"twitch": {
"username": "botname",
"password": "oauth:myOauthToken1234",
"clientId": "abcdefghijk"
},
"slack": {
"botToken": "xoxb-xxxxxxxxxx-yyyyyyyyyy",
"statusChannel": "somechannel"
},
"port": 8232,
"logLevel": "info",
"secretKey": "xxxxx"
}
```
- Run with `node server.js`

## Example
See [lfg-siphon](https://github.com/SupportClass/lfg-siphon) for an example implementation.

## Slack Commands
### !channels
Lists the current Twitch chat channels that Streen is listening to.
![channels command example](https://i.imgur.com/072ECjo.png)

### !online
Lists the online status of each Twitch stream that Streen is listening to.
![online command example](https://i.imgur.com/TMiOISh.png)

### !notifyoffline \
Notifies you when `channel` stops streaming. Useful for planning maintenance or remembering
to speak to someone when they go offline for the day.
![notifyoffline command example](https://i.imgur.com/O7BDy6D.png)

### License
Streen is provided under the MIT license, which is available to read in the [LICENSE](LICENSE) file.