Forward tweets to Telegram — no paid API needed.
Uses RSS feeds. Supports AI-powered Persian translation.
Includes a live web dashboard + PWA.
| Feature | Description |
|---|---|
| 🔄 Auto Forward | Tweets delivered to Telegram automatically |
| 🦁 AI Translation | Gemini / Google Translate to Persian |
| 🖼️ Media Support | Photos included with tweets |
| 📊 Live Dashboard | Web UI to view all tweets |
| 🔍 Inline Search | Search tweets from any chat |
| ⌨️ Keyboard Menu | Quick buttons for easy use |
| 🌐 PWA Support | Installable web app |
| ⚡ Parallel Fetching | 8 accounts checked simultaneously |
| 🧠 Smart Caching | Translation cache (500 entries) |
| 🛡️ Auto Recovery | DB reconnect + API fallback |
| 📱 Mobile Friendly | Responsive dark UI |
- Open @BotFather in Telegram
- Send
/newbotand choose a name & username - Copy the token (looks like:
123456:ABC-DEF...)
git clone https://github.com/Misagh95/twitter-telegram-bot.git
cd twitter-telegram-bot
pip install -r requirements.txtCreate a .env file:
TELEGRAM_BOT_TOKEN=your_bot_token_here
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# AI Translation (optional)
TRANSLATE_FA=true
REQUESTY_API_KEY=your_gemini_api_key
REQUESTY_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai
REQUESTY_MODEL=gemini-2.0-flashpython twitter_telegram_bot.pyOpen http://localhost:8080 for the live dashboard.
| Command | Description |
|---|---|
/start |
Welcome message + keyboard |
/add username |
Add Twitter account(s) |
/del username |
Remove account |
/list |
View tracked accounts |
/test |
Test with @ElonMusk |
/search text |
Search saved tweets |
/status |
Bot health check |
| Button | Action |
|---|---|
| ➕ اضافه کردن | Add account |
| 📋 لیست اکانتها | View list |
| 🔍 جستجو | Search tweets |
| 🌐 داشبورد | Open web dashboard |
| 📊 وضعیت | Bot status |
| ℹ️ راهنما | Help |
From any Telegram chat, type:
@your_bot_name elonmusk
Searches saved tweets and shares them inline.
- Push to GitHub
- Go to railway.app
- New Project → Deploy from GitHub Repo
- Select your repo
- Add PostgreSQL database
- Set environment variables:
| Variable | Value |
|---|---|
TELEGRAM_BOT_TOKEN |
Your bot token |
DATABASE_URL |
Auto-set by Railway |
REQUESTY_API_KEY |
Your Gemini key |
REQUESTY_BASE_URL |
https://generativelanguage.googleapis.com/v1beta/openai |
REQUESTY_MODEL |
gemini-2.0-flash |
TRANSLATE_FA |
true |
- Deploy! 🎉
twitter-telegram-bot/
├── twitter_telegram_bot.py # Main bot + web server
├── database.py # PostgreSQL manager
├── templates/
│ └── index.html # Dashboard UI (PWA)
├── sw.js # Service Worker
├── manifest.json # PWA manifest
├── requirements.txt # Dependencies
├── Procfile # Railway config
├── README_FA.md # 🇮🇷 Persian docs
└── README.md # 🇬🇧 English docs
| Variable | Default | Description |
|---|---|---|
CHECK_INTERVAL |
300 |
Check interval (seconds) |
TRANSLATE_FA |
true |
Enable Persian translation |
DASHBOARD_URL |
http://localhost:8080 |
Dashboard URL |
CONCURRENT_LIMIT |
8 |
Parallel fetch limit |
- ❌ Private accounts won't work (RSS limitation)
- ✅ Multiple Nitter instances for reliability
- ✅ Bot auto-switches if one instance is down
- ✅ Captions split when too long for photos
- ✅ Deduplication prevents duplicate messages
- ✅ Old data auto-cleaned (30 days)
- Backend: Python 3.10+, python-telegram-bot v22
- Web: FastAPI + Jinja2 + Tailwind CSS
- Database: PostgreSQL (psycopg2)
- AI: Google Gemini API
- RSS: feedparser + httpx
- PWA: Service Worker + Manifest
Made with ❤️ by Misagh95