Joel Purra: Developer and more


botten-nappet

A Twitch bot and streaming tool.

Usage

To be done.

Configuration

The server code expects these environment variables to be set. See steps below for manual/developer steps to set/retrieve the values.

export TWITCH_APP_CLIENT_ID='configure me'
export TWITCH_APP_CLIENT_SECRET='configure me'
export TWITCH_APP_OAUTH_REDIRECT_URL='configure me'
export TWITCH_USER_NAME='configure me'
export BOTTEN_NAPPET_LOG_FILE="${TMPDIR}.botten-nappet.log"
export BOTTEN_NAPPET_DATABASE_URI="nedb://.../path/to/botten-nappet/database-directory"

Installation

npm install

npm run --silent build

Running the server

npm run --silent start

Development

Follow git-flow and use git-flow-avh.

# Make sure git-flow is initialized.
git flow init -d

# Clean, test, build, watch javascript code for changes.
npm run --silent clean
npm run --silent build
npm run --silent test
npm run --silent watch

# Set logging parameters.
export BOTTEN_NAPPET_LOGGING_LEVEL='trace'
export BOTTEN_NAPPET_LOG_FILE="${TMPDIR}.botten-nappet.log"

# Start debugger. Connect to it using Google Chrome, see chrome://inspect/
# https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
# Run "debug" for normal debugging, or "debug:break" to break on the first statement.
# NOTE: pipes log output to a file, which is pretty-printed separately.
npm run --silent debug

# New terminal window: watch log file and pretty print.
tail -f "$BOTTEN_NAPPET_LOG_FILE" | ./node_modules/.bin/pino

Developer environment setup

The below steps assume a bash shell.

Prepare variables

# Create a Twitch application, get your client id/secret from there.
open 'https://dev.twitch.tv/dashboard/apps/create'

# Your application details.
export TWITCH_APP_CLIENT_ID='your twitch client id here'
export TWITCH_APP_CLIENT_SECRET='your twitch client secret here'

# Set OAuth landing page for authorized users.
# NOTE: use the same address here as in the applcation registration.
# NOTE: this should be one of your own domains/websites.
# TODO: build a page which accepts the authorized user's code automatically.
export TWITCH_APP_OAUTH_REDIRECT_URL='https://example.com/'

# Set username to gain access to.
export TWITCH_USER_NAME='your-twitch-username'

Shutting down the development environment

Best practice includes revoking the above temporary development tokens.

# Revoke user access token.
# TODO: curl local development revoke url.
# Unset all of the exported variables.
export -n TWITCH_APP_CLIENT_ID
export -n TWITCH_APP_CLIENT_SECRET
export -n TWITCH_APP_OAUTH_REDIRECT_URL
export -n TWITCH_USER_NAME

Acknowledgements

  • thor10768765 on Twitch for inspiration and pushing me to start this project.

botten-nappet Copyright © 2018 Joel Purra. Released under GNU Affero General Public License version 3.0 (AGPL-3.0). Your donations are appreciated!