Giter Club home page Giter Club logo

pil-bot's Introduction

pil-bot

Travis GitHub last commit GitHub package version Known Vulnerabilities license

A simple bot for Discord that announces your Twitch stream

What does it do?

When you turn your Twitch stream, pil-bot will notify in your discord channel with a link to your stream, the game you are playing, and the current number of viewers. The information is updated every minute to provide your followers up to date information on your stream.

How do I set it up?

Check out the code and run it wherever you would like! A hosting solutions like Heroku is great for this (Procfile is ready for you). To run, you need to pass a few environment variables, then run npm start.

$ export DISCORD_BOT_TOKEN='MyDiscordBot'
$ export TWITCH_CLIENT_ID='MyTwitchClientId'
$ export TWITCH_CLIENT_SECRET='MyTwitchClientSecret'
$ export STREAMERS='{"MyStreamerId":"MyDiscordChannelId"}'
$ npm start
> [email protected] start /Users/phan/projects/pil-bot
> node src/clock.js

In Discord, you want to provide following permissions for your bot. At the end, you should use 224256 as your permission value.

  • Read Messages
  • Embed Links
  • Read Message History
  • Send Messages
  • Manage Messages
  • Mention @everyone
  • View Channel

Environment Variables

Name Description Default
DISCORD_BOT_TOKEN Secret token you get from Discord by creating a bot application. discord.js has an awesome guide on how to do this. This variable is required.
TWITCH_CLIENT_ID ID of your Twitch application. It is used to get your stream info. Follow Twitch's own guide on how to get this. This variable is required.
TWITCH_CLIENT_SECRET Secret of your Twitch application. It is used to get your stream info. Follow Twitch's own guide on how to get this. This variable is required.
STREAMERS Refer to the section below. {} (Using this default means pil-bot does nothing)
ROLLBAR_ACCESS_TOKEN An access token for Rollbar error tracking. If this is not set, errors are not logged in Rollbar. No token
ENVIRONMENT A string value to denote the environment this is running. Currently being used as Rollbar environment. development
LOG_LEVEL Minimum level of logs you want to see. Refer to loglevel's documentation on what the levels are. info

Streamer Config

STREAMERS should be a JSON dictionary of Twitch ID to a dictionary of various configuration for that streamer.

Key Description Default
channelId ID of the Discord channel to post when this streamer starts his broadcast. Note: this is Discord channel ID, not its name. This value is required.
color The colour to be added to the side of the embed message. Set the hex RGB value as a string, such as "0xFF0000". 0xFF0000 (Red)
shouldUpdateMessage Whether the message should be updated every minute to provide the latest data to the discord users. true
shouldUpdateImage Whether the screenshot of the broadcast should be updated every minute to provide the latest data to the discord users. However, this means that some users will get a broken image for the image if they see the image too late. true
shouldUseEveryone Whether to prefix the message with @everyone tag. This will send every user of your discord Guild a notification. false
Sample Configuration
{
    "twitchplayspokemon": {
        "channelId": "12345",
        "color": "0x1A1AFF",
        "shouldUpdateMessage": true,
        "shouldUpdateImage": false,
        "shouldUseEveryone": false
    }
}

How do I contribute?

We welcome your contribution! Check out CONTRIBUTING.md.

pil-bot's People

Contributors

hanpeter avatar

Stargazers

XOFF avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

todokku

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.