Skip to content

Commit 6a94cc8

Browse files
Adds documentation to IRC bots, moves TWITCH_APP_ID env var to TWITCH_CLIENT_ID, but allows old TWITCH_APP_ID to still work.
1 parent 7df5423 commit 6a94cc8

File tree

15 files changed

+83
-29
lines changed

15 files changed

+83
-29
lines changed

.env_sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# app on this page:
55
# https://dev.twitch.tv/console/apps
66

7-
TWITCH_APP_ID=
7+
TWITCH_CLIENT_ID=
88

99

1010
##########################################################

.env_single_container_sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DJANGO_SECRET_KEY=<RANDOM STRING>
66

77
PORT=80
88

9-
TWITCH_APP_ID=<TWITCH APP ID>
9+
TWITCH_CLIENT_ID=<TWITCH APP ID>
1010
TWITCH_CLIENT_SECRET=<TWITCH CLIENT SECRET>
1111
TWITCH_WEBHOOK_SECRET=<RANDOM STRING>
1212

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ will help TAU become more stable and secure. Use at your own risk._
3737
_Note 2- TAU is written using django/python, however, acting as an
3838
API proxy, you can connect any codebase to its websockets._
3939

40+
_Note 3- If when starting up TAU, you see the error:
41+
```
42+
bash: ./scripts/start.sh: /bin/bash^M: bad interpreter: No such file or directory
43+
```
44+
This is due to windows git changing your line endings from `lf` to `crlf`. Use the command:
45+
```
46+
git config --global core.autocrlf input
47+
```
48+
Turn off autoclrf, and re-clone the repository.
49+
4050
# :star: Features
4151

4252
- Easy to use UI to manage Twitch events
@@ -58,8 +68,7 @@ First thing you'll need to do is to clone or download this repo to a local folde
5868

5969
## Twitch Setup
6070

61-
Because TAU depends heavily on Twitch, it is necessary to obtain a Twitch App ID and
62-
secret. The steps below will help you do this.
71+
Because TAU depends heavily on Twitch, it is necessary to obtain a Twitch Client ID and Client Secret. The steps below will help you do this.
6372

6473
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.
6574
1. Visit the [Twitch Developer Applications Console](https://dev.twitch.tv/console/apps).
@@ -79,7 +88,7 @@ Now that you've obtained your Client ID and Client Secret, it is time to set up
7988

8089
Fill in values for:
8190

82-
- TWITCH_APP_ID (The Twitch Client ID you just generated)
91+
- TWITCH_CLIENT_ID (The Twitch Client ID you just generated)
8392
- TWITCH_CLIENT_SECRET (The Twitch Client Secret you just generated)
8493
- TWITCH_WEBHOOK_SECRET (a random string)
8594
- POSTGRES_PW Root Password

docs/api/connecting.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A TAU token is required for both the realtime websocket API and the REST API. T
1111
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:
1212
```
1313
{
14-
token: 'YOUR TOKEN HERE'
14+
"token": "YOUR TOKEN HERE"
1515
}
1616
```
1717
After receiving your token, TAU will begin to broadcast incoming twitch events to your client.
@@ -22,3 +22,23 @@ TAU also provides 2 separate REST APIs. A passthrough of the Twitch Helix API a
2222
Authorization: Token YOUR-TOKEN-HERE
2323
```
2424
The Update Token Scopes page from the dashboard will allow you to add scopes to the Twitch token used by TAU.
25+
26+
## Connecting to Chat Bot Websockets
27+
TAU also provides websockets for your streamer user chat, and any chat bots you have set up at `ws/chat-bots/<chat-bot-username>/` where `<chat-bot-username>` is the all-lowercase twitch username of your streamer account or any chat-bot accounts you have set up in TAU.
28+
29+
After connecting your client to the websocket, you must send a message containing the following json object:
30+
31+
```
32+
{
33+
"token": "YOUR TOKEN HERE"
34+
}
35+
```
36+
37+
After receiving your token, TAU will begin to broadcast incoming twitch chat events to your client. You can also send outgoing messages to be posted in chat by your bot. Simply send the following payload to the endpoint of the bot you would like to have "speak":
38+
39+
```
40+
{
41+
"irc_channel": "channel_to_send_to",
42+
"message": "message to post in channel."
43+
}
44+
```

docs/deployment/local.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The simplest way to deploy TAU is locally, using Docker. Setting TAU up locally
44
1. [Get a Twitch Client ID and Client Secret](./twitch_dev.md)
55
1. Copy `.env_sample` to `.env`
66
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)
7+
1. `TWITCH_CLIENT_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)
88
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.
99
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.
1010
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.

docs/deployment/railway.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Railway](https://railway.app/) is a cost effective way to run TAU 24/7 in the cloud. The following steps should get you started! These instructions assume you have cloned the TAU repo to your local drive, and that you have npm installed (the railway CLI app requires npm).
44

5-
<!-- [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2FTeam-TAU%2Ftau%2Ftree%2Fdocumentation-railway-docs&plugins=postgresql%2Credis&envs=TWITCH_APP_ID%2CTWITCH_CLIENT_SECRET%2CTWITCH_WEBHOOK_SECRET%2CDJANGO_DB_PW%2CDJANGO_SECRET_KEY%2CDJANGO_CONFIGURATION%2CPORT&TWITCH_APP_IDDesc=Your+Twitch+TAU+app+id.&TWITCH_CLIENT_SECRETDesc=Your+Twitch+TAU+client+secret.&TWITCH_WEBHOOK_SECRETDesc=Random+string+of+10-100+characters.&DJANGO_DB_PWDesc=A+password+you+would+like+to+use+for+your+TAU+postgres+database.&DJANGO_SECRET_KEYDesc=Random+string+of+10-100+characters.&DJANGO_CONFIGURATIONDesc=DO+NOT+CHANGE&PORTDesc=DO+NOT+CHANGE&DJANGO_CONFIGURATIONDefault=Railway&PORTDefault=443&referralCode=TAU) -->
5+
<!-- [![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https%3A%2F%2Fgithub.com%2FTeam-TAU%2Ftau%2Ftree%2Fdocumentation-railway-docs&plugins=postgresql%2Credis&envs=TWITCH_CLIENT_ID%2CTWITCH_CLIENT_SECRET%2CTWITCH_WEBHOOK_SECRET%2CDJANGO_DB_PW%2CDJANGO_SECRET_KEY%2CDJANGO_CONFIGURATION%2CPORT&TWITCH_CLIENT_IDDesc=Your+Twitch+TAU+app+id.&TWITCH_CLIENT_SECRETDesc=Your+Twitch+TAU+client+secret.&TWITCH_WEBHOOK_SECRETDesc=Random+string+of+10-100+characters.&DJANGO_DB_PWDesc=A+password+you+would+like+to+use+for+your+TAU+postgres+database.&DJANGO_SECRET_KEYDesc=Random+string+of+10-100+characters.&DJANGO_CONFIGURATIONDesc=DO+NOT+CHANGE&PORTDesc=DO+NOT+CHANGE&DJANGO_CONFIGURATIONDefault=Railway&PORTDefault=443&referralCode=TAU) -->
66

77
1. [Create a railway account/login](https://railway.app/login)
88
1. [Go to your railway dashboard](https://railway.app/dashboard)
@@ -24,10 +24,10 @@
2424

2525
## Sample .env data.
2626

27-
All `.env` data should come from your local install of TAU (see your existing `.env`). The first 6 values must be set. `TWITCH_APP_ID` and `TWITCH_CLIENT_SECRET` come from the Twitch developer settings above, `TWITCH_WEBHOOK_SECRET` should be a random string of characters 10-100 characters long. `DJANGO_DB_PW` can be any password you want to set for the Django databse user, `DJANGO_SECRET_KEY` should be a different random string of characters 10-100 characters long, and `PUBLIC_URL` should be the deployment domain, e.g.- `tau-twitchname.up.railway.app`. The last two values (`DJANGO_CONFIGURATION` and `PORT`) should use the provided values below.
27+
All `.env` data should come from your local install of TAU (see your existing `.env`). The first 6 values must be set. `TWITCH_CLIENT_ID` and `TWITCH_CLIENT_SECRET` come from the Twitch developer settings above, `TWITCH_WEBHOOK_SECRET` should be a random string of characters 10-100 characters long. `DJANGO_DB_PW` can be any password you want to set for the Django databse user, `DJANGO_SECRET_KEY` should be a different random string of characters 10-100 characters long, and `PUBLIC_URL` should be the deployment domain, e.g.- `tau-twitchname.up.railway.app`. The last two values (`DJANGO_CONFIGURATION` and `PORT`) should use the provided values below.
2828

2929
```
30-
TWITCH_APP_ID=
30+
TWITCH_CLIENT_ID=
3131
TWITCH_CLIENT_SECRET=
3232
TWITCH_WEBHOOK_SECRET=
3333
DJANGO_DB_PW=

docs/env_options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ The following environment variables can be used to manipulate your Tau install.
1919
| DJANGO_DB_PW | Password for the `DJANGO_DB_USER` | '' |
2020
| DJANGO_CONFIGURATION | Configuration django uses | Local |
2121
| DJANGO_SECRET_KEY | Key used by Django for keeping your data stored securely | None |
22-
| TWITCH_APP_ID | Application ID for connecting to twitch | '' |
22+
| TWITCH_CLIENT_ID | Application ID for connecting to twitch | '' |
2323
| TWITCH_CLIENT_SECRET | Used for communicating with the twitch API | '' |
2424
| TWITCH_WEBHOOK_SECRET | Used for signing the webhooks from twitch to validate they are legitimate | '' |

docs/irc_bot_setup.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# IRC Chatbot Setup
2+
3+
TAU automatically connects your streamer user to chat if you have the User IRC option enabled in the Config panel.
4+
5+
If you would like to enable IRC Bots with different accounts (e.g.- YourBotName) you can do so by following the instructions below.
6+
7+
Once your bot accounts are set up, you can subscribe to their websocket connection following the instructions here [link to instructions]
8+
9+
## IRC Bot Setup
10+
11+
1. Go to ChatBots tab in the dashboard.
12+
1. Click the [+] button in the upper right corner of the Chat Bot Status card.
13+
1. Click "Copy URL" in the resulting modal.
14+
1. Open a new browser instance (preferably private/incognito mode) and paste the url in the address bar.
15+
1. Log in as the bot account you want to enable, and click "Authorize"
16+
1. Close this browser window when instructed to do so, and refresh the TAU dashboard.
17+
1. You should now see your bot listed.
18+
1. Click add next to your bot's name to add a channel for the bot to join. In the resulting modal, enter the Twitch User's channel for the bot.
19+
1. Your bot should now be ready to do all of its bot things.
20+
1. Go to [link to instructions] to link up your bot code to TAU.

tau/chatbots/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from django.db import models
88
from django.utils import timezone
9+
from django.conf import settings
910

1011

1112
# Create your models here.
@@ -29,7 +30,7 @@ def is_token_expired(self):
2930

3031
def renew_token(self):
3132
refresh_token = self.refresh_token
32-
client_id = os.environ.get('TWITCH_APP_ID', None)
33+
client_id = settings.TWITCH_CLIENT_ID
3334
client_secret = os.environ.get('TWITCH_CLIENT_SECRET', None)
3435
req = requests.post('https://id.twitch.tv/oauth2/token', data={
3536
'client_id': client_id,

tau/chatbots/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def status_keep_alive(self, request):
4343
def twitch_auth_link(self, request):
4444
state = uuid4()
4545
config.TWITCH_AUTH_STATE = str(state)
46-
client_id = os.environ.get('TWITCH_APP_ID', None)
46+
client_id = settings.TWITCH_CLIENT_ID
4747
scope = 'chat:read chat:edit channel:moderate'
4848
url = f'https://id.twitch.tv/oauth2/authorize?' \
4949
f'client_id={client_id}&' \
@@ -69,7 +69,7 @@ def twitch_callback(self, request):
6969
print(f'stored: {config.TWITCH_AUTH_STATE}')
7070
if state != config.TWITCH_AUTH_STATE:
7171
return HttpResponseForbidden()
72-
client_id = os.environ.get('TWITCH_APP_ID', None)
72+
client_id = settings.TWITCH_CLIENT_ID
7373
client_secret = os.environ.get('TWITCH_CLIENT_SECRET', None)
7474
auth_r = requests.post('https://id.twitch.tv/oauth2/token', data={
7575
'client_id': client_id,

0 commit comments

Comments
 (0)