RedditAutoCrosspostBot
https://www.reddit.com/user/AutoCrosspostBot
This reddit bot listens to comments and looks for ones that match the pattern
/r/target_subreddit
It then saves the link to that comment for later processing. After some waiting period (e.g. 3 months), the bot checks the same comment, and if it has accrued enough upvotes, the bot will crosspost the submission that the comment replied to, to the target subreddit.
This project also shares the code for three additional bots:
sub_doesnt_exist_bot
https://www.reddit.com/user/sub_doesnt_exist_bot
Replies to the same type of comments and informs that the sub they linked does not exist.
same_subreddit_bot
https://www.reddit.com/user/same_subreddit_bot
Replies to comments that link to the same subreddit that comment was posted on.
same_post_bot
https://www.reddit.com/user/same_post_bot
Replies to comments that link to a subreddit that already has a post with the same content as the source submission.
Known problem: Reposts
This bot has two methods for preventing reposts. It first checks whether the source submission link was already posted to the target subreddit, and then it uses repostsleuth.com to check whether anything similar to that link was already posted to the target subreddit.
As far as I know, RepostSleuth doesn't support videos or any other non-image file format, so this method will fail to detect video reposts.
I am looking for a way to solve this problem. Suggestions are welcome.
Requierments
Python 3.X PostgreSQL Heroku (for production)
How to install
pip install -r requirements.txt
How to run
python reddit_auto_crosspost_bot.py
Heroku
I use Heroku to host and run the bots and the Postgres database. I also use Papertrail as the logging platform.
git clone https://github.com/Toldry/RedditAutoCrosspostBot.git
cd reddit_auto_crosspost_bot
heroku login
heroku ps:scale worker=1
PostgreSQL
The data utilized by the AutoCrosspostBot is stored in a PostgreSQL database.
See instantiate_db.sql for the table and stored function definitions.
Environment variables
On dev, the environment variables are stored in the .env file, and on production, they're stored on the Heroku app's config vars.
APP_CLIENT_SECRET - generated by reddit, u/AutoCrosspostBot's app client secret.
APP_CLIENT_SECRET__SUB_DOESNT_EXIST - generated by reddit, u/sub_doesnt_exist_bot's app client secret.
APP_CLIENT_SECRET__SAME_SUBREDDIT - generated by reddit, u/same_subreddit_bot's app client secret.
APP_CLIENT_SECRET__SAME_POST - generated by reddit, u/same_post_bot's app client secret.
COMMENT_SCORE_THRESHOLD - the minimum score needed for a suggestion source comment to trigger a crosspost.
DATABASE_URL - the postgres database url, begins with `postgres://`.
DEBUG - boolean flag, `True` for debug mode.
LISTEN_ONLY - boolean flag, `True` when setting AutoCrosspostBot to only listen to comments without crossposting.
PASSWORD - u/AutoCrosspostBot's password.
PASSWORD__SUB_DOESNT_EXIST - u/sub_doesnt_exist_bot's password.
PASSWORD__SAME_SUBREDDIT - u/same_subreddit_bot's password.
PASSWORD__SAME_POST - u/same_post_bot's password.
PHASE2_WAITING_PERIOD - time interval between a suggestion source comment being saved and it passing through phase 2.
PHASE3_WAITING_PERIOD - time interval between a suggestion source comment being saved and it passing through phase 3.
PAPERTRAIL_API_TOKEN - self explanatory.
Phase 1, 2, 3
AutoCrosspostBot acts in three phases:
Phase 1
Listen to the r/all comment stream and save comments that fit the pattern of a source suggestion comment. It is during this phase that the other three bots (u/sub_doesnt_exist_bot, u/same_subreddit_bot, u/same_post_bot) also act.
Phase 2
Purge saved comments whose score does not pass the threshold, and other filters. The purpose of this phase is to significantly reduce the amount of rows of saved comments that are present in the database at any point. Heroku's free tier limits this number to 10,000 by default.
Phase 3
Re-check all the filters, then finally crosspost.
Donate
If you like the bot, you're welcome to donate to help me maintain and improve it

