A Goal bot to serve the /r/Gunners subreddit. With simple commands members of the subreddit can rewatch their favorite goals
- Clone the repo
- Create
config.py
,assistComments.txt
, andgoalComments.txt
files - Ask @nicbaughman for information about those 3 files
- Install posgres (recommend using brew) Once Brew is installed run
brew install postgres
- Start postgres server
pg_ctl -D /usr/local/var/postgres start
- Log into that server using automatic user postgres
psql postgres
- Create new database in postgres
CREATE DATABASE arsenal_bot
- Create table in database (ask for proper table name)
CREATE TABLE mens_goals ( date CHAR(10), opposition CHAR(50), result CHAR(10), competition CHAR(50), season CHAR(10), scorer CHAR(50), assist CHAR(50), url CHAR(70), pen BOOLEAN );
- Inspect the table was created correctly
\d+ TABLENAME;
- Import CSV of all goal data
\copy mens_goals FROM '~/Downloads/Arsenal_goals.csv' DELIMITER ',' CSV HEADER;
- Import python packages
pip3 install praw psycopg2 unidecode
- Run script
python3 arsenalGoalBot.py
- Starting Postgres
pg_ctl -D /usr/local/var/postgres start
- Stopping Postgres
pg_ctl -D /usr/local/var/postgres stop
Moving the bot to Heroku was NOT as straight forward as I imagined. I should probably document this for anyone looking to deploy their bot to Heorku. One of the main drivers for me to use Heroku is their free tier. Sure the bot may be down for a few hours a day but that seems like a small price to pay IMO. Also I have never done any dev ops or Continuous Integration before so this seemed like a good opportunity to learn.
- Make an account on Heroku and then in your repo run
heroku login
- I needed a requirements.txt file so I ran
pip freeze > requirements.txt
- Had to create a Procfile to run my script so added
worker: python arsenalGoalBot.py
to run the script - Once I had the requirements and Procfile files I created a server in Heroku by navigating to the project folder and running
heroku create
- From there I setup some config variables in the server settings.
- Then added some Production and Local config variables in my script
- Pushed the code to the heroku server
git push heroku master
- Observe the logs with
heroku logs
to make ssure everything worked okay - Then I had to setup the postgress DB. Which included updating the postgres config to check if we are in Production or Local
- Then looked at the configs for the Postgres DB in Heroku and added them as config variables