Twitch Tool repo
Repo to keep my community's twitch gadgetries. Join me at www.twitch.tv/armzi.
Projects:
- 9armbot - custom bot to moderate twitch channel with unique personality.
- webapp - a webapp to display events/gif/messages from 9armbot but it can be a standalone project on its own.
Contribute
- Please open an issue for feature request.
- Open a PR - Please describe the benefit of your PR and run some basic testing. I should not be the one to test and fix your 'feature' or 'enhancement'.
- We do not accept PR for minor typo or 'code cleanup'. Your PR should have some form of enhancement/feature or major refactoring.
π¦ Installation
$ git clone https://github.com/thananon/twitch_tools.git
$ cd twitch_tools
$ npm install
π¨ Usage
Use through docker-compose.yml
Change the configuration to your channel and the database path.
version: "3.9"
services:
9armbot:
build:
context: .
dockerfile: Dockerfile
volumes:
+ - ./9armbot/botstat.json:/twitch_tools/9armbot/botstat.json
+ - ./9armbot/players.json:/twitch_tools/9armbot/players.json
- type: bind
+ source: ./9armbot/oauth_token
target: /twitch_tools/9armbot/oauth_token
read_only: true
environment:
- twitch_api=https://tmi.twitch.tv
+ - tmi_username=9armbot
+ - tmi_channel_name=armzi
+ - admin_username=armzi
$ docker-compose up
Use through NodeJs
Change the configuration to your channel in .env
file and copy oauth token to 9armbot/oauth_token
.
twitch_api="https://tmi.twitch.tv"
+tmi_username="9armbot"
+tmi_channel_name="armzi"
+admin_username="armzi"
$ npm install
$ npm start
More information about
oauth_token
here.
v2.0.0 (work in progress)
Development workflow
- Create Twitch and/or Discord Application, then get OAuth Token
- Open
.env
, modify names and credentials, then save it as.env.local
(This file is Git-ignored) - Initiate database by running
npm run db:migrate
- Start development server
npm run dev-2.0
- Run tests with
npm run test-2.0
- See database with
npm run db:studio
Migrate from JSON database (players.json)
Debug Console
$ npm run console
Prisma Studio (View database on browser)
$ npm run db:studio
Updating Database Schema
- Planning - Update schema.prisma (Docs)
- Generate - Run
npm run db:generate
, name the schema (eg."Add is_admin field"
), SQL migration file will be created. - Inspect - Verify and/or edit
.sql
file at prisma/migrations - Migrate - Run
npm run db:migrate
to apply changes to your database (Note: This action cannot be reversed easily without resetting your schema (Ref).) - Commit - Don't forget to Git-commit the migration files.