Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A modular script that lets you easily set up a Reddit bot to post submissions on a timely basis.

Notifications You must be signed in to change notification settings

rleonard21/reddit-easy-post

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Reddit Easy Post Bot!

About

There have been a few threads in /r/redditdev regarding an easy way to automatically submit a post at a given time. This is a simple Python script to cover that need!

Setup

Dependencies

This script uses Python 3.6 and has only one dependency: PRAW. This is the API Wrapper used for interfacing with the Reddit API. It can be installed with pip:

$ pip3 install praw 

Configuration

Most of the work is done in the config.txt file. This script uses a configuration file to determine the account credentials. The contents of the config.txt file are as follows:

username=  

A quick note here: Fields such as username and subreddit do not include the common slashes. For example, the username should be username instead of /u/username , and the subreddit should be like redditdev rather than /r/redditdev .

Client ID and Client Secret

In order to make your account access the Reddit API, it must be a developer account. This can be done by going into account preferences, then click apps. This panel should allow you to create a bot for the account and get the ID and Secret. A good guide can be found here: http://progur.com/2016/09/how-to-create-reddit-bot-using-praw4#registering-the-bot

Submission Content!

This script uses the supplied content.txt file for the content of the submission. Edit this file in your favorite text editor. Remember, Reddit's posts use Markdown for formatting! Plenty of information about can be found online. The first line of this file will be the title of the post. Anything after that is the content of the submission! Here's an example content.txt file to help:

Hello world! This is the body of your submission. Anything following the first line of this file will be included in your post. Have fun! 

Here the title will be Hello world! and the body will be This is the body. and everything after that.

Cron Installation

This script is intended to run on a Linux (or Mac) based computer using the crontab service. This can easily be accomplished using a Desktop, Raspberry Pi, or a service such as Amazon AWS. Open a terminal and clone this repository into your working directory:

$ git clone https://github.com/rleonard21/reddit-easy-post.git 
Then edit your crontab by running the following command:
$ crontab -e 
When the crontab file opens in the text editor, enter the following at the bottom:
min hr day mon dow python3 /full/path/post-cron.py 

Where min , hr , day , mon , and dow represent the time at which to run the script. How to set up the time will not be explained here, as it is covered in many other resources: http://www.adminschoice.com/crontab-quick-reference Once this is setup on crontab, the Reddit account will post by itself at the specific intervals!

Cron Alternative

Something that I've found useful a few times is the ability to post only once at a certain time. This can be done using the at tool in Linux. Installation is as such:

$ sudo apt-get install at 
And setting up the one-time post is just as easy:
$ echo "python3 /full/path/post-cron.py" | at 9:00AM 

Modifying the Post Content

If you setup the script and wanted it to post something different, all that needs to be done is to modify the material inside of content.txt . When the bot posts next, it will use the updated content in the file.