r/Tekken Bot
Python bot to -
- update the livestream widget for r/Tekken
delete shitposts posted on days other than Shitpost Sunday- implement the dojo system for r/Tekken
Based on r/DotA2's sidebar-bot. Many thanks to u/coronaria for pointing me to the source.
-
Clone this repository using the commands below and
cd
into itgit clone https://github.com/AbhijeetKrishnan/r-tekken-bot.git cd r-tekken-bot
-
Create an account with Heroku
-
Create a new app. You can use any name you want.
-
Install the Heroku CLI and setup your SSH keys
-
Provision a Postgres database using -
heroku addons:create heroku-postgresql:hobby-dev
-
Login to the Heroku db
heroku pg:psql
-
Create the required database schema and
create table [table-name] (id varchar, created_utc timestamp, author varchar); \q
-
Create environment variables containing values for the following keys -
BOT_USERNAME=tekken-bot CLIENT_ID=[reddit-client-id] CLIENT_SECRET=[reddit-client-secret] PASSWORD=[bot-account-password] TWITCH_CLIENT_ID=[twitch-client-id] TWITCH_SECRET_ID=[twitch-client-secret] tekken=461067
You will need to obtain these by registering your application with Reddit and Twitch.
-
Commit and push the repository to Heroku using git
git add . git commit -am "make it better" git push heroku master
-
Install Postgresql-12
-
Install the Heroku CLI
-
Start the database service
sudo service postgresql start
-
Create a
.env
file containing the following -BOT_USERNAME=tekken-bot CLIENT_ID=[reddit-client-id] CLIENT_SECRET=[reddit-client-secret] PASSWORD=[bot-account-password] TWITCH_CLIENT_ID=[twitch-client-id] TWITCH_SECRET_ID=[twitch-client-secret] tekken=461067 DATABASE_URL=postgres://postgresql?host=/var/run/postgresql&port=5432
-
Use the Heroku CLI to execute the application locally
heroku local
The code consists of the following files -
Procfile
: used by Heroku to start the apprequirements.txt
: used by Heroku to initialize the environmentruntime.txt
: used by Heroku to initialize the runtime (i.e. Python version)task_runner.py
: the driver code that uses theschedule
module to schedule all the necessary tasksdojo.py
: implements the dojo workflows of ingestion, award, and clean-upredesign.py
: updates the Livestream widget in the Reddit redesignsmash.py
: updates the list of upcoming Tekken tournaments by pulling from smash.gg (TODO)tasks.py
: implements tasks which don't require a separate moduletwitch.py
: connects to the Twitch API and returns the list of live Tekken streamers