2.3 KiB
2.3 KiB
Telegram RSS Bridge Architecture
System Components
1. Web Parser (Main Bridge)
- Existing web-based parser for public Telegram content
- Fallback mechanism to Pyro Parser when content not found
2. Pyro Parser (Backup Service)
- Pyrogram-based client for private content
- HTTP API server for post retrieval
- Session management for Telegram auth
3. HTTP API Interface
- Endpoints:
GET /post/{channel}/{post_id}- Get single postGET /channel/{channel}- (Future) Get channel feed
- Response format:
{ "id": 123, "date": "2023-01-01T00:00:00", "text": "post content", "media": [], "views": 100, "reactions": [] // Future extension }
Service Structure
pyro_parser/
├── telegram_client.py # Pyrogram wrapper + session management
├── api_server.py # FastAPI/Falcon server
├── schemas.py # Data models/Pydantic schemas
└── config.py # Environment configuration
Key Features
- Pyrogram Client
- Async Telegram client with session persistence
- Automatic reconnection
- Rate limiting handling
- Error tracking for API calls
- Content Processing
- Raw post transformation
- Media links extraction
- Text cleanup utilities
- (Future) Reactions parser
Environment Configuration
# Core settings
TG_API_ID=123456
TG_API_HASH=abcdef123456
SESSION_PATH=/data/session.file
# Server config
API_HOST=0.0.0.0
API_PORT=8000
REQUEST_TIMEOUT=30
Docker Setup
services:
pyro_parser:
image: ghcr.io/vvzvlad/pyrotg-bridge:latest
environment:
TG_API_ID: ${TG_API_ID}
TG_API_HASH: ${TG_API_HASH}
volumes:
- ./sessions:/data
ports:
- "8000:8000"
CI/CD Integration
# .github/workflows/deploy.yml
name: Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/vvzvlad/pyrotg-bridge:latest
Extension Points
- Post Processing
- Media download hooks
- Link preview generators
- Content filters
- API Features
- Pagination params
- Field selection
- Webhook support
- Monitoring
- /status endpoint
- Basic request metrics
- Error logging