No description
  • Python 98.1%
  • Dockerfile 1.9%
Find a file
Light 9d6570c2d7 fix: eliminate false flagging by replacing gunicorn with single-process architecture
Root cause: gunicorn -w 2 forked 2 workers, each independently streaming
Reddit submissions. Both processed the same post — one posted 'welcome',
the other removed it. Python Lock() does not work across forked processes.

Changes:
- Remove gunicorn entirely; run bot directly via python main.py
- Bot stream runs in main thread, Flask health server in daemon thread
- Replace non-atomic EXISTS+SETEX AI rate limit with atomic SETNX+EXPIRE
- Replace set-based dedup with per-submission SETNX (processed:{id}, 24h TTL)
- Add MAX_SUBMISSION_AGE_SECONDS guard to skip old posts from PRAW reconnects
- Remove dead code: /reload endpoint, _start_bot(), conftest.py TESTING flag
- Remove unused gunicorn dependency from requirements.txt
- Update tests to match new architecture (31 tests, all passing)
2026-03-13 19:39:41 +05:30
tests fix: eliminate false flagging by replacing gunicorn with single-process architecture 2026-03-13 19:39:41 +05:30
.env.example fix: Gunicorn ran 2 workers changed dockerfile 2026-03-13 19:24:51 +05:30
.gitignore Add Docker support and simplify bot 2026-03-02 15:06:45 +05:30
docker-compose.yml fix: Gunicorn ran 2 workers changed dockerfile 2026-03-13 19:24:51 +05:30
Dockerfile fix: eliminate false flagging by replacing gunicorn with single-process architecture 2026-03-13 19:39:41 +05:30
image.png added readme 2025-08-27 21:35:24 +05:30
main.py fix: eliminate false flagging by replacing gunicorn with single-process architecture 2026-03-13 19:39:41 +05:30
README.md Add Docker support and simplify bot 2026-03-02 15:06:45 +05:30
requirements.txt fix: eliminate false flagging by replacing gunicorn with single-process architecture 2026-03-13 19:39:41 +05:30

Reddit Mod Bot

A simple Reddit moderation bot for r/SuouYuki.

What It Does

  • Image source lookup: Uses SauceNAO API to find sources for image posts
  • AI post limit: Limits AI-flaired posts to 1 per week
  • Health/stats API: HTTP endpoints for monitoring

Setup

# Install dependencies
pip install -r requirements.txt

# Create .env file (copy from .env.example)
cp .env.example .env

# Run the bot
python main.py

Or with Docker:

docker compose up --build -d

Environment Variables

  • REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, REDDIT_USERNAME, REDDIT_PASSWORD, REDDIT_USER_AGENT
  • REDDIT_SUBREDDIT - subreddit to moderate (default: SuouYuki)
  • SAUCENAO_API_KEY - SauceNAO API key
  • REDIS_URL - Redis URL (e.g., redis://localhost:6379)
  • PORT - HTTP server port (default: 8080)

API Endpoints

  • GET / - Health check
  • GET /health - Detailed health status
  • GET /stats - Bot statistics
  • POST /reload - Reload the bot