This script fetches top n submissions per subreddit, and sends them via emails if a submission's score or number of comments exceeds a certain threshold.
-
Clone the repository
-
Go to Reddit and create a developper application for script use.
-
Create a
praw.ini
file in the repository folder following the doc -
Run
reddit_bot.py
with your config options, like below$ python3 reddit_bot.py --reddit_config bot1 --subreddits machinelearning datascience python --from_address [email protected] --from_address_pass password --to_address [email protected] [email protected]
Command line arguments
optional arguments: -h, --help show this help message and exit --reddit_config CONFIG specify config section for Reddit config file, e.g. praw.ini --subreddits [STRING [STRING ...]] A list of subreddits --limit INT maximum num of posts per subreddit --score INT minimun score on a particular submission --num_comments INT minimun num of comments on a particular submission --from_address EMAIL email addr from which to send contents --from_address_pass EMAIL_PASS password for email addr from which to send contents --to_address [EMAIL [EMAIL ...]] email addr to which to send contents
-
Additionally, you can create a
run.sh
script based off the code in step 4, and setup a cron job for automation tasks. For example, to run it daily at 4 p.m., we can put this in ourcrontab
file:0 16 * * * cd /home/jameswong/projects/redditbot/ && /bin/bash run.sh