🤖 A simple Twitch bot that automatically sends !so @user
in chat after your stream has been live for a preset amount of time.
For use with bots that have !so
commands, essentially acts as an auto shoutout for services that don't have this functionality built in (e.g. StreamElements).
Much of the code (and like 100% of the installation instructions below) was used from Timbot
- Monitors Twitch chat for users in the shout out list and shouts them out when they talk for the first time.
- Programmable delay, so the shout out happens later in your stream rather than at the very beginning.
- Bot commands for mods to add or remove streamers from the shout out list (!addso/!rmso).
This bot is built with Node.js. Install the latest LTS version from the official website.
To set up the bot, clone it using git
:
git clone git@github.com:brofar/Twitch-Shoutout-Bot.git
Once installed, enter the directory and install the dependencies:
cd Twitch-Shoutout-Bot
npm install
To configure the bot, copy the included .env.sample
to .env
and enter or customize the values in the file.
Configuration options explained:
Key | Required? | Description |
---|---|---|
BOT_USERNAME |
☑ | The username of your bot (can be either your own username, or you can create another Twitch account for your bot). |
BOT_OAUTH_TOKEN |
☑ | Your bot token (explained below). |
CHANNEL_NAME |
☑ | The Twitch channel the bot should join (i.e. your channel). |
BOT_CLIENT_ID |
☑ | Client ID for your Twitch app, via developer portal (explained below). |
BOT_CLIENT_SECRET |
☑ | Client Secret for your Twitch app, via developer portal (explained below). |
MIN_TO_WAIT_BEFORE_SHOUTOUT |
☑ | How many minutes your stream should be live before the bot starts monitoring (for immediate shoutouts, enter 0). |
TWITCH_PREFIX |
☑ | Prefix for the bot's commands. |
Note that you will need to set up some external applications:
To connect to the Twitch API, you will need to register a new application in the Twitch Developers Console as the user you've listed in BOT_USERNAME
.
You will need to grab the Client ID (BOT_CLIENT_ID
in .env).
Then, create a new secret and copy that into BOT_CLIENT_SECRET
in .env
To make things more complicated, all requests to the Twitch API need to be authenticated with an OAuth grant generated by your own application.
To begin the authorization flow, you'll need to complete the authorization prompt yourself as the user you've listed in BOT_USERNAME
:
https://id.twitch.tv/oauth2/authorize?client_id=TWITCH_CLIENT_ID&response_type=token&redirect_uri=http://localhost
You can grab the access_token
from the redirect URL in your browser, and store it as BOT_OAUTH_TOKEN
in .env.
Once the application has been configured, start it using node
from the installation directory:
node .