An smart RSS Reader for Telegram
Find a file
Pablo Murad 6e34abe084
Some checks failed
CD / Build and Push Docker Image (push) Has been cancelled
CD / Create Release (push) Has been cancelled
CI / Python Lint (push) Has been cancelled
CI / Python Test (push) Has been cancelled
CI / Docker Build (Python) (push) Has been cancelled
Kills1.3
2025-11-01 22:37:39 -03:00
.github fix: add Python setup step to CD workflow release job 2025-11-01 22:19:20 -03:00
.jenkins First commit 2025-10-09 02:28:29 -03:00
app Kills1.3 2025-11-01 22:37:39 -03:00
docker feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
prisma melhorias 2025-10-28 23:03:19 -03:00
scripts minor fix 2025-10-29 19:51:31 -03:00
src changes 2025-11-01 15:37:26 -03:00
.dockerignore feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
.env.example feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
.gitattributes melhorias 2025-10-25 15:21:36 -03:00
.gitignore chore: add Python patterns to .gitignore 2025-11-01 22:19:06 -03:00
biome.json First commit 2025-10-09 02:28:29 -03:00
CHANGELOG.md feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
docker-compose.yml feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
docker-entrypoint.sh feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
Dockerfile feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
Jenkinsfile feat: Prepare for v0.5.0 - Halfway to definitive 2025-10-24 22:13:45 -03:00
LICENSE First commit 2025-10-09 02:28:29 -03:00
MIGRATION_STATUS.md feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
package-lock.json melhorias 2025-10-29 00:43:16 -03:00
package.json major fix 2025-10-29 19:55:50 -03:00
pyproject.toml feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
README.md feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
README_DOCKER.md feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
README_PYTHON.md feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
requirements.txt feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
rssskull.png First commit 2025-10-09 02:28:29 -03:00
run.py feat: migrate to Python and fix Reddit feed notification issues 2025-11-01 22:18:56 -03:00
tsc fixes1 2025-10-29 06:43:22 -03:00
tsconfig.json feat: implement Reddit JSON API and latency optimizations - Add RedditService with JSON API for subreddit feeds - Disable cache for Reddit (TTL=0) to reduce latency - Add timestamps (lastNotifiedAt, lastSeenAt) to Feed model - Create ItemDedupe table with 7-day TTL for duplicate prevention - Implement configurable maxAgeMinutes per feed (90min Reddit, 24h others) - Add jitter (Β±1min) to feed scheduling to avoid thundering herd - Remove all test files and vitest configuration - Update GitHub Actions CI/CD workflows - Update Dockerfile and docker-compose with optimization notes 2025-10-24 12:19:11 -03:00
vitest.config.ts melhorias 2025-10-29 00:43:16 -03:00

RSS Skull Bot

RSS Skull Bot

Modern RSS to Telegram Bot with Reddit Support

A powerful, feature-rich Telegram bot that fetches RSS feeds and delivers content directly to your Telegram channels. Built with Python (FastAPI + aiogram), featuring Reddit RSS support, HTTP caching, performance metrics, HTML sanitization, and intelligent feed processing.

✨ Features

πŸ”— RSS Feed Processing

  • Multi-format Support: RSS 2.0, Atom, JSON Feed 1.1
  • Smart Parsing: Automatic content extraction and normalization
  • Deduplication: Prevents duplicate posts using intelligent ID matching
  • Content Filtering: Advanced filtering based on keywords, domains, and patterns
  • HTML Sanitization: Automatic sanitization for Telegram HTML parse mode
  • Baseline Management: Smart baseline using most recent post date to prevent old post notifications

πŸ”΄ Reddit Integration

  • RSS Feed Support: Automatic Reddit URL to RSS conversion (/r/subreddit β†’ .rss)
  • Timestamp-based Detection: Smart detection of new posts using publication dates
  • Popularity-based Handling: Correctly handles Reddit's non-chronological sorting
  • HTTP Caching: ETag and Last-Modified header support to reduce API calls
  • Rate Limiting: Intelligent request management to respect Reddit's limits

⚑ Performance & Reliability

  • HTTP Caching: ETag and Last-Modified header support
  • Circuit Breaker: Intelligent fault tolerance with exponential backoff
  • Database Persistence: All data persisted across Docker deployments
  • Auto-Migrations: Prisma migrations applied automatically on startup
  • Smart Rate Limiting: Adaptive throttling per domain (6-8 min for Reddit)
  • User-Agent Management: Realistic browser headers to avoid detection

πŸ›‘οΈ Telegram Resilience System

  • Auto-Recovery: Automatic recovery from 502 Bad Gateway errors
  • Message Queue: Offline message queuing during API outages
  • Exponential Backoff: Smart retry with delays from 1s to 60s
  • Health Monitoring: Real-time monitoring with /health endpoint
  • Alert System: Automatic alerts for critical connectivity issues
  • Persistent State: Connection state survives restarts

πŸ€– Telegram Bot Features

  • Interactive Commands: /add, /remove, /list, /help
  • Real-time Notifications: Instant feed updates
  • Channel Management: Support for multiple channels
  • Access Control: Optional user ID whitelist (respond only to owner)
  • Feed Limits: Global limit of 100 feeds across all chats
  • Error Handling: Graceful error recovery and user feedback

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose (recommended)
  • Redis (optional, can be disabled)
  • Telegram Bot Token

Installation

  1. Clone the repository
git clone https://github.com/runawaydevil/rssskull.git
cd rssskull
  1. Install dependencies
pip install -r requirements.txt
  1. Setup environment
cp .env.example .env
# Edit .env with your configuration (BOT_TOKEN is required)
  1. Run the bot
python run.py

Or using Docker (recommended):

docker-compose up -d --build

🐳 Docker Deployment

# Clone and navigate to project
git clone https://github.com/runawaydevil/rssskull.git
cd rssskull

# Configure environment
cp .env.example .env
# Edit .env with your BOT_TOKEN and settings

# Start containers
docker-compose up -d --build

# View logs
docker-compose logs -f rss-skull-bot

# Stop containers (data persists in volumes)
docker-compose down

# For clean deployment (WARNING: deletes all data):
docker-compose down -v
docker-compose up -d --build

Data Persistence:

  • Database: Persisted in app_data Docker volume
  • Backups: Stored in backups_data Docker volume
  • Migrations: Applied automatically on container startup

Docker Volumes

The bot uses Docker volumes for data persistence:

  • app_data: Database storage (/app/data)
  • backups_data: Automated backups (/app/backups)

To backup your data:

docker-compose exec rss-skull-bot node scripts/backup-database.js

Data is automatically persisted across container restarts and updates.

βš™οΈ Configuration

Environment Variables

Required:

Variable Description Default
BOT_TOKEN Telegram bot token Required
DATABASE_URL SQLite database path file:/app/data/production.db
REDIS_HOST Redis host redis
REDIS_PORT Redis port 6379

Optional Settings:

Variable Description Default
ENVIRONMENT Environment production
LOG_LEVEL Log level info
ALLOWED_USER_ID Restrict bot to specific user (optional) undefined
DISABLE_REDIS Disable Redis caching false
PORT HTTP server port 8916
HOST HTTP server host 0.0.0.0

Reddit Feed Setup

Reddit feeds are automatically converted to RSS format:

  • Add Reddit subreddit: /add MySub https://reddit.com/r/subreddit
  • Or directly: /add MySub https://reddit.com/r/subreddit/.rss

The bot automatically converts Reddit URLs to RSS feeds and handles Reddit's popularity-based sorting to correctly detect new posts.

πŸ“± Bot Commands

Command Description
/start Start the bot and show welcome message
/help Show available commands
/add <name> <url> Add RSS feed to monitoring
/discover <url> Auto-discover feeds from a website
/remove <name> Remove RSS feed from monitoring
/list List all monitored feeds
/status Show bot status and statistics
/filters Manage content filters

πŸ—οΈ Architecture

app/
β”œβ”€β”€ bot.py                     # Telegram bot implementation (aiogram)
β”œβ”€β”€ commands/                  # Bot command handlers
β”‚   └── feed_commands.py      # Feed management commands
β”œβ”€β”€ jobs/                      # Background job processing
β”‚   └── feed_checker.py       # RSS feed checking job (APScheduler)
β”œβ”€β”€ services/                  # Core business logic
β”‚   β”œβ”€β”€ feed_service.py        # Feed CRUD operations
β”‚   β”œβ”€β”€ rss_service.py        # RSS feed fetching and parsing
β”‚   └── reddit_service.py     # Reddit URL handling
β”œβ”€β”€ models/                    # Database models (SQLModel)
β”‚   └── feed.py               # Feed and Chat models
β”œβ”€β”€ utils/                     # Utility functions
β”‚   β”œβ”€β”€ html_sanitizer.py     # Telegram HTML sanitization
β”‚   β”œβ”€β”€ cache.py              # Redis caching
β”‚   └── logger.py             # Structured logging
β”œβ”€β”€ database.py               # Database initialization
β”œβ”€β”€ config.py                 # Configuration (Pydantic Settings)
└── main.py                   # FastAPI application with health endpoints

πŸ”§ Development

Available Scripts

# Development
python run.py              # Start development server

# Docker
docker-compose up -d --build  # Build and start containers
docker-compose logs -f rss-skull-bot    # View bot logs
docker-compose restart rss-skull-bot    # Restart bot container

# Code Quality
ruff check app/           # Run Ruff linter
black app/                # Format code with Black
mypy app/                 # Type checking with mypy

Database Management

The database is automatically initialized on first startup. Data is persisted in Docker volumes (app_data).

To access the database directly:

docker-compose exec rss-skull-bot sqlite3 /app/data/production.db

πŸ“Š Monitoring & Reliability

The bot includes comprehensive monitoring and fault tolerance:

  • Performance Metrics: Request latency tracking
  • Error Monitoring: Automatic error logging and recovery
  • Circuit Breaker: Exponential backoff on API failures (10min β†’ 4h)
  • Smart Rate Limiting: Adaptive throttling per domain
  • Health Checks: Service availability monitoring
  • Database Persistence: Automatic migrations and backups
  • Graceful Degradation: OAuth β†’ JSON fallback β†’ RSS when needed

πŸ›‘οΈ Telegram Resilience System

The bot includes a robust resilience system specifically designed to handle Telegram API connectivity issues:

  • Automatic Recovery: Handles 502 Bad Gateway errors with exponential backoff (1s β†’ 60s)
  • Message Queuing: Stores up to 1000 messages during API outages with priority handling
  • Circuit Breaker: Prevents cascade failures with adaptive thresholds
  • Health Monitoring: Real-time metrics and alerting via /health, /resilience-stats, /metrics
  • Persistent State: Connection state and queued messages survive restarts
  • Smart Retry: Up to 30 minutes of retry attempts before escalation

Monitoring Endpoints:

  • GET /health - Overall system health including resilience status
  • GET /resilience-stats - Detailed resilience system statistics
  • GET /metrics - Complete metrics for monitoring systems

For detailed information, see RESILIENCE.md.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Convention

We use conventional commits:

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • style: Code style changes
  • refactor: Code refactoring
  • test: Test additions/changes
  • chore: Maintenance tasks

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†• Changelog

See CHANGELOG.md for full version history.

v0.6.0 - "Python Migration & Bug Fixes" (2025-11-02)

  • 🐍 Complete migration from TypeScript/Node.js to Python
  • πŸ”§ Fixed Telegram HTML parse errors (HTML comments, unbalanced tags)
  • βœ… Fixed Reddit feed notification issues
  • πŸ“Š Enhanced logging and debugging capabilities
  • 🎯 Improved baseline management for new feeds
  • 🐳 Docker improvements (multi-stage build, non-root user)
  • πŸ“ HTML sanitization system for Telegram messages
  • 🧹 Code cleanup and optimization

πŸ“ž Support


Made with ❀️ by Pablo Murad