- Limits the number of submissions per user to a subreddit in a given timeframe, by reporting, filtering and removing excess posts.
- Uses a rolling window to count posts in a specified number of hours, with adjustable thresholds.
- Enable, disable and modify parameters live from your subreddit wiki (think old Automoderator).
Uses PRAW and Redis.
- A reddit user and accompanying script app with scopes for reporting and removing posts. See the PRAW documentation for details on this.
- A local Redis server. Support is not provided for password-protected instances.
- Python 3 and Pipenv
- Set up the remote configuration (See 'Remote Configuration' below)
- Copy
localconfig.example.py
tolocalconfig.py
- Fill in all the values.
- Subreddit is just the sub's name (i.e.
AskReddit
, not/r/AskReddit
) - Config wiki page is everything after
/r/subreddit/wiki/
in the URL of your page
- Subreddit is just the sub's name (i.e.
- Create your Remote Configuration
- Run
pipenv install
- Run
pipenv run python -m app.main
The bot is now running. It will track submissions made to /new over time, and action posts that exceed the thresholds set in config.
Core functionality of the bot is managed from your subreddit wiki, using a JSON object with the configurable parameters. The bot loads config from this page on launch, or when messaged with 'reload' as the subject.
- Create a new wiki page on your subreddit. Make sure your bot account has access to read this page.
- Copy the contents of
wiki-config-example.json
to your new wiki page, fill in the contents, and hit save. - Run the bot and check the log for a message confirming the config was loaded.
- Make and save your changes to the wiki page
- Message the bot account with the subject 'reload'.
The bot will reload the config from the wiki page and send a modmail confirming a successful reload.
You can specify custom remove and report messages in your remote configuration. The following parameters can be used to give your messages some context. Surround the parameter name with braces in your message, and it will be substituted for the relevant value.
post_ids
- A list of post IDs from a given user in the period, in the form['abcd', 'wxyz', '1234']
num_posts
- The number of posts from a given user in the periodperiod
- The number of hours in which posts are counted (==PERIOD_HOURS
in config)report_threshold
- The number of posts before new posts are reported (==REPORT_THRESHOLD
)remove_threshold
- The number of posts before new posts are removed (==REMOVE_THRESHOLD
)
For example:
{
"report_message": "User posted {num_posts} times in the last {period} hours | {post_ids}",
"remove_message": "User exceeded limit of {remove_threshold} posts in {period}h"
}
There is a companion userscript that will turn IDs in report reasons into clickable reddit links. Paste the contents of userscript.js
into a new userscript in your manager (e.g. Violentmonkey), replace the bot username constant, then save.