Skip to content

cajogos/noots-bot-twitch

Repository files navigation

Official Twitch Bot for the Noot Army

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⡀⡄⣄⡀⣄⣀⡀⣀⠀⠀⢀⣠⣤⣤⣤⣤⣠⣤
⠀⠄⠠⠀⠄⠠⠀⠄⠠⠀⠄⠠⠀⠄⠠⠀⠄⣀⣤⣴⣶⡿⢿⡻⢟⡻⣛⡟⡟⣷⢶⣤⣄⡀⠀⢀⠀⠠⢀⠀⢰⣿⣿⣿⣿⣿⣿
⠠⠈⢀⠐⠀⠂⠐⠀⠂⠐⠀⠂⢀⢂⣤⣶⣿⣿⢿⢯⣷⣹⢧⣻⣭⣳⣝⣾⣱⣏⡾⣭⣟⣿⣷⣤⡀⠂⢀⠠⢸⣿⣿⣿⣿⣿⣿
⠀⡐⠀⠠⠈⠀⠂⠁⠐⠈⠀⢰⣴⣿⣿⣿⣯⣿⣯⣿⣾⣽⣿⣷⣿⣷⣿⣾⣷⣯⣿⣳⣟⣾⣽⣟⣿⣦⠀⠀⣾⣿⣿⣿⣿⣿⣿
⠀⡀⠐⠀⡀⠁⠠⠈⠀⢠⣵⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣯⣿⢿⣿⣿⣷⡀⣿⣿⣿⣿⣿⣿⣿
⠀⢀⠐⠀⠀⠐⠀⠀⣱⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⡀⠀⠁⠀⠀⣱⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠙⢿⣿⣿⣿⣿
⠀⠀⠀⢀⠀⠁⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠁⣀⡉⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠈⠛⠿⣿
⠀⠀⠁⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⠀⠠⣾⣿⣿⣷⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⢾
⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀⠻⠿⠿⠋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⢸
⠀⠀⠀⠀⠀⠸⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⢯⣛⢷⣲⣾
⠀⠀⠀⠀⠀⢰⡏⢠⣍⢿⣿⣿⣿⣿⣿⣿⣿⣿⢿⡿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣞⣷⣯⣿
⠀⠀⠀⠀⠀⠈⢳⣸⣿⡞⣿⣿⣿⣿⡟⢯⠹⡘⠦⡉⢖⡡⢏⡿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣷⣿
⠀⠀⠀⠀⠀⠀⠀⢳⡛⢃⣿⣿⠿⣭⡙⢆⢣⡙⠴⣉⢦⡹⣎⣷⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⢏⡿⣴⡹⣎⢦⣝⣮⣳⢯⣷⣻⢾⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⢯⢾⣵⣻⣽⣻⣞⡷⣯⣟⡾⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢘⣯⢟⣼⣳⣳⢯⢾⣝⣳⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠘⠿⢶⣭⡷⠯⠟⠚⢛⣿⣿⣿⣿⣿⣿⠿⠛⠛⠛⠛⠛⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⢀⣾⣿⣿⣿⣿⡟⠁⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠚⠛⠛⠛⠛⠛⠛⠛⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Getting Started

Before you get started you will need to link the bot to your twitch account. This will enable you to debug the code with your chat.

Twitch Account

Register your app with Twitch

Visit https://dev.twitch.tv/console/apps/create and fill out the fields:

Name: Can be anything, how about NootBotDev

OAuth Redirect Urls: http://localhost

Category: Chat Bot

Obtain your Oauth credentials

Visit your app that you created (either you were already redirected or you can use this url: https://dev.twitch.tv/console and you should see your bot under Applications)

IMPORTANT: Take note of your Client ID and create a New Secret we will need these later (DO NOT SHARE this with anyone)

Add your credentials to the bot

In the repo there are two files config.example.js and credentials.example.js.

Create two files called config.js and credentials.js.

Copy the contents of their respective example files into the two files you created.

config.js

In config.js change 'cajogos' to be your twitch username. This tells the bot to listen to your chat.

You can add multiple twtich users if you want to work with multiple chats by separating their names with a comma: 'cajogos','yeekaycrafts','pudgyycat'

credentials.js

In credentials.js update the two variables to contain the credentials we collected from https://dev.twitch.tv/console/apps

const clientId = 'Your Client ID';
const clientSecret = 'Your Client Secret';

Configure Twurple

tokens.json

We are almost there, create a new file called tokens.json and copy and paste the below JSON:

{
	"accessToken": "",
	"refreshToken": "",
	"expiresIn": 0,
	"obtainmentTimestamp": 0
}

Obtaining our Access Token and Refresh Token

Copy the url below into a text editior like notepad. Edit YOUR_CLIENT_ID and replace it with your client ID. Visit the url in your browser

https://id.twitch.tv/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost&response_type=code&scope=chat:read+chat:edit

Twitch will ask permission to link the bot with your Twitch account. This enables the bot to use your Twitch account to appear as you and interact with chat.

Don't close the browser/tab yet! After clicking Authorize you will be redirected copy the url into a text editor. There should be a query parameter named code we will need this for the next step.

Open Postman and send a POST request to the this url replacing:

CLIENT_ID with your client id CLIENT_SECRET with your client secret CODE_FROM_LAST_REQUEST with the code we obtained in the previous step

https://id.twitch.tv/oauth2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&code=CODE_FROM_LAST_REQUEST&grant_type=authorization_code&redirect_uri=http://localhost

In Postman we will get a response looking like this, grab the access_token and refresh_token:

{
	"access_token": "",
	"refresh_token": "",
	"expires_in": 3600,
	"scope": ["chat:read", "chat:edit"],
	"token_type": "bearer"
}

Paste the access_token and refresh_token into your tokens.json file.

Start up the bot

Open up a terminal and install the node packages:

npm i

Then run the bot by entering

npm run start

About

Official Noots_Bot Twitch Bot repository.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published