This commit is contained in:
2026-03-08 23:28:58 +00:00
parent ad00797231
commit ebe291a45d
+22 -17
View File
@@ -1,18 +1,20 @@
# ModReplyBot Reddit Bot # ModReplyBot Reddit Bot
This bot watches a subreddit for moderator reports containing triggers, approves posts, and leaves stickied comments. Triggers and comments are configured via a local YAML file. All other settings are handled via environment variables. ModReplyBot is a Reddit bot for moderators that watches for mod comments containing triggers, approves posts, and leaves stickied comments. It also posts automatic comments based on post tags, and notifies mods when its configuration changes. All configuration is handled via a subreddit wiki page and environment variables.
## Features ## Features
- Watches for moderator reports with triggers - Responds only to moderator comments containing triggers (ignores non-mod comments)
- Approves posts and leaves stickied comments - Approves posts and leaves stickied comments
- Triggers/comments configured via config/config.yaml - Posts automatic comments based on tags in post titles (e.g., [Bedrock], [Java])
- Supports multiple triggers/comments - Triggers, tag comments, and bot config are managed via a subreddit wiki page
- Notifies mods via modmail when the config wiki page changes
- Persistent database for auto-commented posts (survives restarts and container recreations)
- Docker and baremetal support - Docker and baremetal support
## Configuration ## Configuration
### 1. Trigger and Comment Configuration ### 1. Wiki Page Configuration
Edit the file at `config/config.yaml` in your project directory. Example: Edit your subreddit wiki page (name set by `REDDIT_WIKI_PAGE` env variable) with YAML like:
``` ```
triggers: triggers:
@@ -20,14 +22,19 @@ triggers:
comment: | comment: |
Thank you for your report! Thank you for your report!
This post is now approved. This post is now approved.
- trigger: question - trigger: question
comment: | comment: |
This post has been approved. This post has been approved.
Your question will be answered soon. Your question will be answered soon.
post_tags:
- tag: Bedrock, Java
comment: |
__[Click here if your post says "Sorry, this post was removed by Reddits filters"](...)__
``` ```
Each entry under `triggers` defines a trigger and its associated multi-line comment. The bot will automatically create this file with example content if it does not exist. - Triggers: Bot responds to mod comments containing !trigger (e.g., !help) with the configured comment.
- post_tags: Bot posts the comment automatically on new posts with matching tags in the title.
### 2. Environment Variables ### 2. Environment Variables
Create a `.env` file (or set env variables directly) with: Create a `.env` file (or set env variables directly) with:
@@ -39,6 +46,7 @@ REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password REDDIT_PASSWORD=your_password
REDDIT_USER_AGENT=modreplybot by /u/your_username REDDIT_USER_AGENT=modreplybot by /u/your_username
REDDIT_SUBREDDIT=your_subreddit REDDIT_SUBREDDIT=your_subreddit
REDDIT_WIKI_PAGE=modbot-config
``` ```
## Installation ## Installation
@@ -51,12 +59,14 @@ REDDIT_SUBREDDIT=your_subreddit
docker compose up -d docker compose up -d
``` ```
- The DB folder is mounted for persistent database storage.
### Docker Run ### Docker Run
1. Copy `.env.example` to `.env` and fill in your values. 1. Copy `.env.example` to `.env` and fill in your values.
2. Run: 2. Run:
``` ```
docker run --env-file .env slfhstd.uk/slfhstd/modreplybot:latest docker run --env-file .env -v $(pwd)/DB:/app/DB slfhstd.uk/slfhstd/modreplybot:latest
``` ```
### Baremetal (Direct Python) ### Baremetal (Direct Python)
@@ -71,20 +81,15 @@ pip install -r requirements.txt
4. Run: 4. Run:
``` ```
python modbot.py python modreplybot.py
```
## Building the Docker Image
If you want to build your own image:
```
docker build -t modreplybot .
``` ```
## Troubleshooting ## Troubleshooting
- Ensure your Reddit credentials are correct and have moderator permissions. - Ensure your Reddit credentials are correct and have moderator permissions.
- The bot must be able to read the wiki page and approve posts. - The bot must be able to read the wiki page and approve posts.
- Check logs for errors. - Check logs for errors.
- The bot only responds to mod comments for triggers.
- Database is stored in DB/commented_posts.txt and survives container restarts.
## License ## License
MIT MIT