Automated moderation assistant for Reddit using AI
Project description
Reddit Auto Mod
Automated moderation assistant for Reddit using AI-powered analysis. This tool helps Reddit moderators by automatically analyzing posts for rule violations, detecting similar content, and generating summaries.
Features
- ๐ค AI-Powered Moderation: Uses OpenAI GPT models to detect rule violations
- ๐ Duplicate Detection: Identifies similar posts using semantic search
- ๐ Auto Summarization: Generates concise summaries of posts
- โ๏ธ Easy Configuration: Simple CLI tool for setting up credentials
- ๐ Secure: Credentials stored locally with restricted permissions
Installation
Prerequisites
- Python 3.8 or higher
- pip package manager
- Reddit API credentials (from https://www.reddit.com/prefs/apps)
- OpenAI API key (from https://platform.openai.com/api-keys)
- MongoDB instance (optional, for storing processed data)
Install from PyPI
pip install reddit-auto-mod
Install from Source
# Clone the repository
git clone https://github.com/yourusername/reddit-auto-mod.git
cd reddit-auto-mod
# Install in development mode
pip install -e .
Quick Start
1. Configure Credentials
Run the configuration wizard to set up your Reddit and OpenAI credentials:
reddit-auto-mod config
The wizard will prompt you for:
- Reddit API credentials: client_id, client_secret, user_agent, username, password
- OpenAI API key: Your API key for GPT models
- MongoDB URI (optional): Connection string for database storage
Your credentials are stored securely in ~/.reddit-auto-mod/config.json with restricted file permissions.
2. Set Up Subreddits and Database
Run the setup wizard to configure your moderation environment:
reddit-auto-mod setup
This interactive wizard will:
- Gather subreddit list: Enter the subreddits you want to moderate
- Set up MongoDB: Configure database name and create required collections
RedditRules: Stores subreddit rules for violation detectionRedditSubmissions: Stores historical posts for similarity detectionProcessedRedditSubmissions: Stores processed moderation results
- Build FAISS indexes: Creates similarity search indexes for duplicate detection
3. View Configuration & Setup Status
To view your current configuration (with sensitive data masked):
reddit-auto-mod config --show
To check setup status:
reddit-auto-mod setup --status
4. Managing Your Setup
Update configuration:
reddit-auto-mod config
Rebuild indexes:
reddit-auto-mod setup --build-indexes
Clear configuration:
reddit-auto-mod config --clear
Getting API Credentials
Reddit API Credentials
- Go to https://www.reddit.com/prefs/apps
- Click "Create App" or "Create Another App"
- Choose "script" as the app type
- Fill in the required fields:
- name: Your app name (e.g., "My Mod Bot")
- redirect uri: http://localhost:8080 (not used but required)
- Click "Create app"
- Note your client_id (under the app name) and client_secret
OpenAI API Key
- Go to https://platform.openai.com/api-keys
- Sign in or create an account
- Click "Create new secret key"
- Copy and save your API key securely
Architecture
The Reddit Auto Mod system consists of several components:
โโโโโโโโโโโโโโโโโโโ
โ CLI Tool โ (Configuration & Control)
โโโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend Services โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Data Plane โ โ Processing Services โ โ
โ โ - Fetch Data โ โ - Post Similarity โ โ
โ โ - Orchestrateโ โ - Summarization โ โ
โ โโโโโโโโโโโโโโโโ โ - Rule Violation โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Database โ (MongoDB)
โโโโโโโโโโโโโโโโโโโ
Usage Examples
Configure New Credentials
$ reddit-auto-mod config
============================================================
Reddit Auto Mod - Configuration Setup
============================================================
This wizard will help you configure your credentials.
All credentials are stored locally in: ~/.reddit-auto-mod/config.json
------------------------------------------------------------
REDDIT API CREDENTIALS
------------------------------------------------------------
You can obtain these from: https://www.reddit.com/prefs/apps
Reddit Client ID: your_client_id_here
Reddit Client Secret: ********
Reddit User Agent (e.g., 'MyBot/1.0'): MyBot/1.0
Reddit Username: your_username
Reddit Password: ********
------------------------------------------------------------
OPENAI API KEY
------------------------------------------------------------
You can obtain this from: https://platform.openai.com/api-keys
OpenAI API Key: ********
------------------------------------------------------------
MONGODB CONNECTION (Optional)
------------------------------------------------------------
Leave blank to skip MongoDB configuration
MongoDB Connection URI: mongodb://localhost:27017/
Saving configuration...
============================================================
โ Configuration saved successfully!
============================================================
Config file location: /home/user/.reddit-auto-mod/config.json
You can now use the reddit-auto-mod commands.
View Current Configuration
$ reddit-auto-mod config --show
============================================================
Current Configuration
============================================================
Reddit Credentials:
Client ID: cF0iy7hJ...
Client Secret: ********...
User Agent: MyBot/1.0
Username: your_username
Password: ********
OpenAI API Key: sk-proj-...xyz
MongoDB URI: mongodb://localhost:27017/
Config file location: /home/user/.reddit-auto-mod/config.json
Running the Application
Start All Services
The easiest way to run Reddit Auto Mod is with the start command:
reddit-auto-mod start
This command will:
-
Start Backend Services:
- Text Summarization API (port 8002)
- Rule Violation API (port 8003)
- Post Similarity API (port 8004)
- Data Processing API (port 8001)
-
Start Frontend: React development server (port 5173)
-
Start Scheduler: Daily cron job that processes moderation queue at midnight
The services will run until you press Ctrl+C.
Check Service Status
To check if all services are running:
reddit-auto-mod start --status
Service URLs
Once started, access the services at:
- Frontend: http://localhost:5173
- Data Processing API: http://localhost:8001
- Summarization API: http://localhost:8002
- Rule Violation API: http://localhost:8003
- Similarity API: http://localhost:8004
Manual Service Start (Advanced)
If you prefer to start services individually:
# Start the summarization service
python BackEnd/DataProcessingPlane/PostSummarization/TextSummarization.py
# Start the rule violation checker
python BackEnd/DataProcessingPlane/RuleViolation/RuleViolation.py
# Start the similarity detection service
python BackEnd/DataProcessingPlane/PostSimilarity/PostSimilarity.py
# Start the main data processing API
python BackEnd/DataProcessingPlane/DataProcessingAPI.py
# Start the frontend
cd FrontEnd && npm run dev
Development
Install Development Dependencies
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
black .
Linting
flake8
Configuration File Location
Configuration is stored in your home directory:
- Linux/Mac:
~/.reddit-auto-mod/config.json - Windows:
C:\Users\<username>\.reddit-auto-mod\config.json
The configuration file has restricted permissions (600 on Unix-like systems) to protect your credentials.
Security Considerations
- Store your
config.jsonfile securely - Never commit credentials to version control
- Use environment variables for production deployments
- Regularly rotate your API keys
- The CLI stores credentials with restricted file permissions
- Consider using a secrets management system for production
Troubleshooting
"No configuration found"
Run reddit-auto-mod config to set up your credentials.
"API request failed"
Ensure your API keys are valid and have sufficient quotas/permissions.
Import errors
Make sure all dependencies are installed: pip install -r requirements.txt
Permission denied on config file
The config file should have restricted permissions. On Unix systems, run:
chmod 600 ~/.reddit-auto-mod/config.json
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues, questions, or contributions, please visit:
- GitHub Issues: https://github.com/Bhavinrathava/reddit-auto-mod/issues
- Documentation:https://github.com/Bhavinrathava/reddit-auto-mod/wiki
Acknowledgments
- Built with PRAW - Python Reddit API Wrapper
- Powered by OpenAI GPT models
- Uses FAISS for similarity search
- Uses Transformers for text summarization
Disclaimer
This tool is provided as-is for educational and moderation assistance purposes. Be sure to review all automated actions and comply with Reddit's API terms of service and your subreddit's moderation policies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reddit_auto_mod-0.1.0.tar.gz.
File metadata
- Download URL: reddit_auto_mod-0.1.0.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68cb109a4d0fb5b7fc4a0adbbd867a539e33a4bf893a1a4d66bffbcaa6f5812f
|
|
| MD5 |
785d29822b795b887133b39f4641d303
|
|
| BLAKE2b-256 |
251afea67f0e9c309eca54add6469ec24c4e803841337c775eaf99eebdb43654
|
File details
Details for the file reddit_auto_mod-0.1.0-py3-none-any.whl.
File metadata
- Download URL: reddit_auto_mod-0.1.0-py3-none-any.whl
- Upload date:
- Size: 42.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e93f6f06e704a4997b378c59ef3d2367922eb1d3a219474acbc4d1b772913123
|
|
| MD5 |
2d0979dc4870982d794074af4ab0b1a2
|
|
| BLAKE2b-256 |
d4860be54330ad5fee33aa3dc5b1e93bf3fe4f146e00a523b565bb18268c5a8a
|