Skip to main content

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

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:

  1. Gather subreddit list: Enter the subreddits you want to moderate
  2. Set up MongoDB: Configure database name and create required collections
    • RedditRules: Stores subreddit rules for violation detection
    • RedditSubmissions: Stores historical posts for similarity detection
    • ProcessedRedditSubmissions: Stores processed moderation results
  3. 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

  1. Go to https://www.reddit.com/prefs/apps
  2. Click "Create App" or "Create Another App"
  3. Choose "script" as the app type
  4. Fill in the required fields:
  5. Click "Create app"
  6. Note your client_id (under the app name) and client_secret

OpenAI API Key

  1. Go to https://platform.openai.com/api-keys
  2. Sign in or create an account
  3. Click "Create new secret key"
  4. 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:

  1. Start Backend Services:

    • Text Summarization API (port 8002)
    • Rule Violation API (port 8003)
    • Post Similarity API (port 8004)
    • Data Processing API (port 8001)
  2. Start Frontend: React development server (port 5173)

  3. 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:

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.json file 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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:

Acknowledgments

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reddit_auto_mod-0.1.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reddit_auto_mod-0.1.0-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

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

Hashes for reddit_auto_mod-0.1.0.tar.gz
Algorithm Hash digest
SHA256 68cb109a4d0fb5b7fc4a0adbbd867a539e33a4bf893a1a4d66bffbcaa6f5812f
MD5 785d29822b795b887133b39f4641d303
BLAKE2b-256 251afea67f0e9c309eca54add6469ec24c4e803841337c775eaf99eebdb43654

See more details on using hashes here.

File details

Details for the file reddit_auto_mod-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reddit_auto_mod-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e93f6f06e704a4997b378c59ef3d2367922eb1d3a219474acbc4d1b772913123
MD5 2d0979dc4870982d794074af4ab0b1a2
BLAKE2b-256 d4860be54330ad5fee33aa3dc5b1e93bf3fe4f146e00a523b565bb18268c5a8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page