Skip to content

Commit d72ffe7

Browse files
Merge branch 'main' into api-docs
2 parents 4d4e4c4 + 6aac669 commit d72ffe7

21 files changed

Lines changed: 188 additions & 38 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Deployment:**
27-
Docker Version:
28-
Deployment Type: Local, Cloud Service (e.g. Render.com), Other Server Deploy
29-
Deployment Details: If not local deploy, detailed description of deployment setup.
27+
<!--- To get the versions via command line `docker version` and `docker-compose version` -->
28+
* Docker Version:
29+
* Docker Compose Version (if applicable):
30+
* Deployment Type: Local, Cloud Service (e.g. Render.com), Other Server Deploy
31+
* Deployment Details: If not local deploy, detailed description of deployment setup.
3032

3133
**Additional context**
3234
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
4+
title: "[FEAT] "
5+
labels: enhancement
66
assignees: ''
77

88
---

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
USE_NGROK: ${USE_NGROK:-True}
1919
PORT: ${PORT:-8000}
2020
TWITCH_WEBHOOK_SECRET: ${TWITCH_WEBHOOK_SECRET}
21+
DEBUG_TWITCH_CALLS: ${DEBUG_TWITCH_CALLS:-False}
2122
depends_on:
2223
- db
2324
- redis

docs/api/connecting.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Connecting To TAU
2+
TAU provides two different APIs-
3+
4+
1. A websocket that broadcasts realtime Twitch events, test events, and replayed events.
5+
2. A REST API the provides access to a passthrough of the Twitch Helix API, as well as endpoints for accessing the data captured and stored by TAU.
6+
7+
## Getting your TAU token.
8+
A TAU token is required for both the realtime websocket API and the REST API. To obtain your token, go to the TAU Dashboard, click the hamburger menu, then click `Show Auth Token`
9+
10+
## Connecting to the realtime websocket.
11+
TAU exposes a websocket endpoint at `ws://localhost:PORT/ws/twitch-events/` for a local deployment or `wss://yourdomain:PORT/ws/twitch-events/` for a served deployment. After connecting your client to the websocket, you must send a message containing the following json object:
12+
```
13+
{
14+
token: 'YOUR TOKEN HERE'
15+
}
16+
```
17+
After receiving your token, TAU will begin to broadcast incoming twitch events to your client.
18+
19+
## Connecting to the REST API
20+
TAU also provides 2 separate REST APIs. A passthrough of the Twitch Helix API at: `/api/twitch/helix`, and access to the data captured and stored by TAU at `/api/v1`. In order to authenticate requests, you must include an Authorization header:
21+
```
22+
Authorization: Token YOUR-TOKEN-HERE
23+
```
24+
The Update Token Scopes page from the dashboard will allow you to add scopes to the Twitch token used by TAU.

docs/deployment/cloud.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TAU Cloud Deployment

docs/deployment/local.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# TAU Local Deployment
2+
Paragraph that says what we're doing..
3+
4+
1. [Get a Twitch Client ID and Client Secret](./twitch_dev.md)
5+
1. Copy `.env_sample` to `.env`
6+
1. Open and edit the newly created `.env` file. Set the following values. Please do not use the `#` character in any of your passwords or secret keys.
7+
1. `TWITCH_APP_ID` Set your twitch app client id. This is the "Client ID" available by clicking the "Manage" button for your app on this page: [https://dev.twitch.tv/console/apps](https://dev.twitch.tv/console/apps)
8+
1. `TWITCH_CLIENT_SECRET` Set your twitch app secret. This is the "Client Secret" available by clicking the "Manage" button for your app on this page: [https://dev.twitch.tv/console/apps](https://dev.twitch.tv/console/apps) If you don't already one (or you no longer have your original one), click "New Secret". You'll only be able to see it when you first make it so put it in your password manager.
9+
1. `TWITCH_WEBHOOK_SECRET` This secret is required for Twitch EventSub. It's one that you generate yourself (i.e. it's not the app client secret from the [dev.twitch.tv](https://dev.twitch.tv) page). The secret must be between 10-100 characters. You can use this one, or genrate one yourself.
10+
1. `POSTGRES_PW` This is the root password which will be set for your Postgres container. You can use the password set here but it is more secure to set your own strong password. You likely wont need to directly use this password at all.
11+
1. `DJANGO_DB_PW` This is the password used for the django database. You can use the random password already set, but it is more secure to set your own. You likely wont need to directly use this password at all.
12+
1. `DJANGO_SECRET_KEY` This is a random key for Django. You can use this one, but it's more secure to generate your own.
13+
1. `PORT` The default port is 8000. If you need to use another port, change it here.
14+
1. `NGROK_TOKEN` It is recommended that you use a free (or paid) ngrok account and token, as non-account tunnels have more limited connection counts. If you have an ngrok token you would like to use, uncomment the `NGROK_TOKEN` line and provide your token.
15+
1. After saving the .env file, in the root TAU directory execute the command: `docker compose up`
16+
1. Open a web browser and navigate to the url: `http://localhost:PORT/`.
17+
1. Enter in a local TAU username, and password then click "Create Account". This does not need to be your twitch username.
18+
1. Enter in your Twitch username, and click Setup Channel.
19+
1. Authorize TAU to the requested scopes.
20+

docs/deployment/twitch_dev.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Twitch Setup
2+
3+
Because TAU depends heavily on Twitch, it is necessary to obtain a Twitch App ID and
4+
secret. The steps below will help you do this.
5+
6+
1. Determine the port you want to run TAU on. By default this is port 8000. Use this value for `PORT` in the following steps.
7+
1. Visit the [Twitch Developer Applications Console](https://dev.twitch.tv/console/apps).
8+
1. Log in to your Twitch account if you are not already logged in.
9+
1. In order to manage applications, you will need to enable 2FA for your account.
10+
1. Click "+ Register Your Application".
11+
1. Fill in a name for TAU. I recommend TAU- YourTwitchName.
12+
1. Add `http://localhost:PORT/twitch-callback/` as an OAuth Redirect URL. (Note the trailing slash, this is required)
13+
1. Select a category for what you'll be using TAU for. Chat Bot is what I've used.
14+
1. Click "Create"
15+
1. Click "Manage" for the TAU app.
16+
1. Here is where you can find your Client ID, and generate a Client Secret. You'll need these two values later. Note- you can only see the client secret when you generate it, so make sure you copy it to put in your .env file later. Dont worry if you lose it, you can always generate a new secret.

docs/index.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
# tau
1+
# TAU
22

3-
[![Build Status](https://travis-ci.org/finitesingularity/tau.svg?branch=master)](https://travis-ci.org/finitesingularity/tau)
4-
[![Built with](https://img.shields.io/badge/Built_with-Cookiecutter_Django_Rest-F7B633.svg)](https://github.com/agconti/cookiecutter-django-rest)
3+
## Introduction
4+
TAU provides a single, locally-managed websocket connection for all of Twitch's realtime APIs. Currently, Twitch's realtime APIs are broken up into EventSub WebHooks and PubSub WebSockets.
55

6-
Twith API Unifier. Check out the project's [documentation](http://finitesingularity.github.io/tau/).
6+
In order for a Twitch bot or overlay to be interractive, it needs to tap into the realtime events sent over the Twitch APIs. This typically requires setting up multiple protocols: a webhook on the server-side and websockets on the client-side. It also requires you to keep track of multiple Twitch access tokens. This is where TAU comes in! TAU takes care of all this for you and also adds the ability to replay past events and generate test events of your own from a user friendly UI. Additionally, all events are stored in a database.
77

8-
# Prerequisites
9-
10-
- [Docker](https://docs.docker.com/docker-for-mac/install/)
11-
12-
# Initialize the project
13-
14-
Start the dev server for local development:
15-
16-
```bash
17-
docker-compose up
18-
```
19-
20-
Create a superuser to login to the admin:
21-
22-
```bash
23-
docker-compose run --rm web ./manage.py createsuperuser
24-
```

mkdocs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ site_name: tau
22
site_description: Twith API Unifier
33
repo_url: https://github.com/Team-TAU/tau
44
site_dir: site
5-
copyright: Copyright &copy; 2020, <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Ffinitesingularity">finitesingularity</a>.
6-
dev_addr: 0.0.0.0:8001
5+
copyright: Copyright &copy; 2021, <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Ffinitesingularity">finitesingularity</a>.
6+
dev_addr: 0.0.0.0:8007
77

88
theme:
99
name: readthedocs
@@ -15,8 +15,12 @@ theme:
1515

1616
nav:
1717
- Home: 'index.md'
18-
- Getting Started:
18+
- Deployment:
19+
- Local: 'deployment/local.md'
20+
- Cloud: 'deployment/cloud.md'
1921
- Enviromental Options: 'env_options.md'
2022
- API:
2123
- Authentication: 'api/authentication.md'
24+
- Connecting: 'api/connecting.md'
2225
- V1: 'api/v1.md'
26+

tau/config/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Common(Configuration): # pylint: disable=no-init
2727
else:
2828
LOCAL_URL = BASE_URL
2929

30+
DEBUG_TWITCH_CALLS = os.environ.get("DEBUG_TWITCH_CALLS", "False").lower() == "true"
31+
3032
INSTALLED_APPS = (
3133
'django.contrib.admin',
3234
'django.contrib.auth',
@@ -70,6 +72,7 @@ class Common(Configuration): # pylint: disable=no-init
7072
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
7173
WSGI_APPLICATION = 'tau.wsgi.application'
7274
ASGI_APPLICATION = 'tau.asgi.application'
75+
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
7376

7477
REDIS_ENDPOINT = os.environ.get('REDIS_ENDPOINT','redis:6379')
7578
REDIS_PW = os.environ.get('REDIS_PW','')
@@ -250,7 +253,7 @@ class Common(Configuration): # pylint: disable=no-init
250253

251254
# Django Rest Framework
252255
REST_FRAMEWORK = {
253-
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
256+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.CursorPagination',
254257
'PAGE_SIZE': int(os.getenv('DJANGO_PAGINATION_LIMIT', '10')),
255258
'DATETIME_FORMAT': '%Y-%m-%dT%H:%M:%S%z',
256259
'DEFAULT_RENDERER_CLASSES': (

0 commit comments

Comments
 (0)