A Reddit bot that posts explanation of the xkcd links posted in the comments. The explanation is extracted from the explain xkcd wiki (http://explainxkcd.com)
- Python 3
- pip for Python 3 (recommended)
- PRAW
- Install using pip3 by running
pip3 install praw
orsudo -H pip3 install praw
if it requires escalated privileges.
- Install using pip3 by running
- Python Requests
- Install using pip3 by running
pip3 install requests
orsudo -H pip3 install requests
if it requires escalated privileges.
- Install using pip3 by running
- Beautiful Soup 4
- Install using pip3 by running
pip3 install beautifulsoup4
orsudo -H pip3 install beautifulsoup4
if it requires escalated privileges.
- Install using pip3 by running
- Create a Reddit account, and while logged in, navigate to preferences > apps
- Click on the are you a developer? create an app... button
- Fill in the details-
- name: Name of your bot/script
- Select the option 'script'
- decription: Put in a description of your bot/script
- redirect uri:
http://localhost:8080
- Click create app
- You will be given a
client_id
and aclient_secret
. Keep them confidential.
- Clone or download (and extract) this repository and navigate to it's directory
- Create a file named praw.ini with it's contents as:
[explainbot] username: reddit username password: reddit password client_id: client_id that you got client_secret: client_secret that you got
- Create a blank text file named commented.txt inside the project directory
- In explainxkcdbot.py, replace the value of
path
with the location of your commented.txt. - At a minimum, three files, namely explainxkcdbot.py, praw.ini and commented.txt are required for the bot to run.
- Type
python3 explainxkcdbot.py
in the Terminal to run the bot. - If the Reddit API returns an error due to too many requests, adjust
val
in the instances oftime.sleep(val)
in explainxkcdbot.py