Tlapbot/README.md

2.9 KiB

Tlapbot

Tlapbot is an Owncast bot, aiming to add the feature of channel points and channel point redeems to Owncast.

This bot is currently in-development. The goal is to have a feature set on par with Twitch channel points, while making use of Owncast webhooks and especially External actions.

Features

Currently, the bot gives points to everyone in chat -- the interval can be configured in the config, as well as the amount of points given.

The users in chat can then use their points on redeems. The bot currently only has one hardcoded redeem, but I'd like to make this configurable, so that every Owncast streamer can set up their own redeems that best fit their stream.

The redeems then show on a "Redeems dashboard" that everyone can view at the flask server's URL, which can be included in Owncast as an External action, a single button that displays information about recent redeems.

Setup

The Python prerequisites for running tlapbot are the libraries flask, requests and apscheduler.

First time setup

Install prerequisites:

pip install flask
pip install requests
pip install apscheduler

(Or install them in your virtual environment if you prefer to use one)

Initialize db:

python -m flask init-db

Create a tlapbot/config.py file and fill it in as needed. Default values are included in tlapbot/default_config, and values in config.py overwrite them.

Some recommendations:

SECRET_KEY # get one from running `python -c 'import secrets; print(secrets.token_hex())'`
OWNCAST_ACCESS_TOKEN # get one from owncast instance
OWNCAST_INSTANCE_URL

Owncast setup

In Owncast, navigate to the admin interface at /admin, and then go to Integrations.

Access Token

In Access Tokens, generate an Access Token to put in tlapbot/config.py. At the moment, the only permission the Access Token needs is sending messages, the bot doesn't perform any administrative actions.

Webhook

In webhooks, you create a Webhook, and point it at your bot's URL with /owncastWebhook added.

In debug, this will be something like localhost:5000/owncastWebhook, or, if you're not running the debug Owncast instance and bot on the same machine, you can use a tool like ngrok to redirect the Owncast traffic to your localhost.

External Action

In External Actions, you point the external action to your bot's URL with /dashboard added.

In debug, this might be something like localhost:5000/dashboard, or you can use a tool like ngrok again.

Example:

URL: MyTlapbotServer.com/dashboard

Action Title: Redeems Dashboard

Running in debug:

Set the FLASK_APP variable:

export FLASK_APP=tlapbot

or in Powershell on Windows:

$Env:FLASK_APP = "tlapbot"

Run the app (in debug mode):

python -m flask --debug run 

Running in prod:

To be added when I actually run a prod version of the bot.