High-performance Telegram message forwarding system with userbot monitoring and bot control panel.
- π Secure Session Management: Session strings stored in database
- π± Multi-Group Monitoring: Listen to 200+ groups per account
- π Keyword Filtering: Regex and literal keyword matching
- βοΈ Flexible Rules: Create complex forwarding rules with conditions
- π‘οΈ Rate Limiting: Multi-layer token bucket algorithm (Telegram compliant)
- π€ Human-like Behavior: Randomized delays, active hours simulation
- π Deduplication: SHA-256 hash-based message deduplication
- β‘ Async Architecture: Fully async for high throughput
- π³ Docker Ready: Complete Docker Compose setup
- Server: 4 core, 8GB RAM Ubuntu (or similar)
- Python: 3.11+
- Docker: 20.10+ (recommended) or direct Python install
- Telegram:
- API credentials from https://my.telegram.org
- Bot token from @BotFather
# 1. Clone repository
cd /home/grouppulse/apps/GroupPulseApp
# 2. Initial setup
make setup
# 3. Edit .env file with your credentials
nano .env
# Required values:
# - BOT_TOKEN=your_bot_token
# - DATABASE_URL=postgresql+asyncpg://grouppulse:password@postgres:5432/grouppulse
# - REDIS_URL=redis://:password@redis:6379/0
# 4. Run database migrations
make migrate
# 5. Start all services
make start
# 6. View logs
make logs# 1. Install Python dependencies
poetry install
# 2. Setup PostgreSQL and Redis manually
# 3. Edit .env file
# 4. Run migrations
alembic upgrade head
# 5. Start services
python -m src.bot.app # In one terminal
python -m src.main # In another terminalSee .env.example for all available options. Key settings:
Database:
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/db
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20Rate Limiting:
ACCOUNT_RATE_LIMIT=20 # Messages/second per account
DESTINATION_RATE_LIMIT=5 # Messages/second per destination
GLOBAL_RATE_LIMIT=100 # Total messages/secondPerformance:
MAX_WORKERS=10 # Max Telegram accounts
MAX_CONCURRENT_FORWARDS=100 # Max concurrent forwards
MESSAGE_BATCH_SIZE=50 # DB batch sizeFind your bot (use token from @BotFather) and send /start
- Click "π Account" β "β Add Account"
- Enter API ID and API Hash from https://my.telegram.org
- Enter your phone number (with country code, e.g., +1234567890)
- Enter verification code from Telegram
- If 2FA enabled, enter password
Your session will be encrypted and stored securely.
Source Groups (listen to):
- Click "π± Groups" β "β Add Source"
- Enter group ID or invite link
- Bot will verify access
Destination Groups (forward to):
- Click "π± Groups" β "β Add Destination"
- Enter group ID or invite link
- Click "π Keywords" β "β Add Keyword"
- Enter keyword (literal or regex)
- Choose type:
- Literal: Exact match (case-insensitive by default)
- Regex: Regular expression pattern
- Click "βοΈ Rules" β "β Create Rule"
- Select source groups (where to listen)
- Select destination groups (where to forward)
- (Optional) Select keywords to filter
- (Optional) Set conditions:
- Only media
- Only text
- Min/max text length
- Save rule
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AIOGRAM BOT (Control UI) β
β - User management (FSM) β
β - Account setup β
β - Group/keyword/rule management β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
βββββββββββββΌββββββββββββββββββ
β CORE SERVICE LAYER β
β - Rule matching engine β
β - Rate limiter β
β - Forwarding service β
βββββββββββββ¬ββββββββββββββββββ
β
βββββββββββββ΄βββββββββββββ¬ββββββββββββββ
β β β
ββββββββΌβββββββββββ βββββββββββΌββββββββ ββΌβββββββββ
β TELETHON β β POSTGRESQL β β REDIS β
β USERBOT WORKERS β β (Async Pool) β β (Cache) β
β (2-3 accounts) β β - User data β β β
β β β - Groups β β β
β - Listen 200+ β β - Keywords β β β
β groups each β β - Rules β β β
β - Filter msgs β β - Msg log β β β
β - Forward β βββββββββββββββββββ βββββββββββ
βββββββββββββββββββ
- β Session strings stored securely in database
- β PostgreSQL password protected
- β Redis password enabled
- β Docker containers run as non-root
- β Input validation on all user inputs
- β Rate limiting on bot commands
NEVER commit .env file to git!
Expected capacity (4 core, 8GB RAM):
- Accounts: 2-3 initially, up to 10 with optimization
- Groups: 400-600 (200 per account)
- Throughput: 50-100 messages/second
- Database: ~100MB/month (30-day retention)
- Memory: ~6GB used, 2GB free
- CPU: 30-50% average usage
# Check bot logs
make logs
# Restart bot service
docker-compose restart bot# Check userbot worker logs
docker-compose logs userbot-worker
# Verify account is active in database
make shell
SELECT * FROM telegram_accounts WHERE is_active = true;# Check PostgreSQL status
docker-compose ps postgres
# Restart database
docker-compose restart postgres
# Run migrations again
make migrate- Reduce
ACCOUNT_RATE_LIMITin .env - Wait for flood wait to expire (check logs for duration)
- Telegram limits: ~20 msg/sec sustained
| Command | Description |
|---|---|
make setup |
Initial project setup |
make start |
Start all services |
make stop |
Stop all services |
make restart |
Restart services |
make logs |
View logs (follow mode) |
make migrate |
Run database migrations |
make shell |
Open database shell |
make test |
Run tests |
make clean |
Clean temporary files |
grouppulse/
βββ config/ # Configuration (settings.py)
βββ src/
β βββ bot/ # aiogram bot (FSM, handlers, keyboards)
β βββ userbot/ # Telethon userbot (client, worker pool)
β βββ core/ # Business logic (rule matcher, rate limiter)
β βββ database/ # ORM models, repositories
β βββ services/ # Forwarding service
β βββ utils/ # Utilities (crypto, validators)
βββ alembic/ # Database migrations
βββ tests/ # Test suite
βββ docker-compose.yml
βββ Dockerfile
βββ pyproject.toml
# Run all tests
make test
# Run specific test file
pytest tests/unit/test_rule_matcher.py -v
# Run with coverage
pytest --cov=src tests/# Create new migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade head
# Rollback one migration
alembic downgrade -1Private project. All rights reserved.
For issues or questions, contact the development team.
GroupPulse v1.0.0 - High-Performance Telegram Forwarding System