mirror of
https://github.com/Farhan291/r-SuouYuki_reddit_modbot.git
synced 2026-05-16 13:11:44 +00:00
No description
- Python 98.1%
- Dockerfile 1.9%
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)
|
||
|---|---|---|
| tests | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| image.png | ||
| main.py | ||
| README.md | ||
| requirements.txt | ||
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_AGENTREDDIT_SUBREDDIT- subreddit to moderate (default: SuouYuki)SAUCENAO_API_KEY- SauceNAO API keyREDIS_URL- Redis URL (e.g., redis://localhost:6379)PORT- HTTP server port (default: 8080)
API Endpoints
GET /- Health checkGET /health- Detailed health statusGET /stats- Bot statisticsPOST /reload- Reload the bot