A quick Reddit autoreply bot

Similar to my last *nix style project I wanted to write something in Python that could interact with Reddit and can be ran from a Raspberry Pi. At this stage I only wanted to see what was possible and start early, so I borrowed some code to make a bot that scanned a subreddit for a certain phrases and then replied to those comments. Similar to last time there are basically only 2 steps:

1. Setting up a *nix environment to handle it.

This project is for the Raspberry Pi so I need to make sure it works on Linux. The only things you really need is Python which comes with most *nix systems and the PRAW module which can installed with:

pip install praw

PRAW is the Python Reddit API Wrapper and gives you access the wrapper quite easily.

On Windows you will need to install Python, it should be quite easy and you can follow the instructions on the Python site. As far as I am aware pip is installed in the Windows installation too.

2. Write and run the script

Start a text document with your favorite editor, save it as something like redditreply.py and copy the following script written by /u/shaggorama

You need to change some bits, ‘change me’ is the name of the user agent. The target_text is text in comments that your script will look for and response_text is the reply that your post will respond with. You need to change ‘all’ to the subreddit you wish to run the bot over. I used /r/sandboxtest which is a subreddit for bots.