A Telegram Mini App that runs inside Telegram using the WebApp API, providing a UI to download audio/video via the Doradura bot.
- 🎵 Audio: MP3 with bitrate selection (128k/192k/256k/320k)
- 🎬 Video: MP4 with quality selection (360p/480p/720p/1080p/best)
- 📝 Subtitles: SRT
- Preview: metadata (title, duration, size) before download
- Subscriptions: Free/Premium/VIP with limits; quick plan switching/cancel to Free
- Limits: show current quotas
- Stats: total downloads, success rate, errors, total size
- History & queue: last 50 downloads with statuses; live queue (poll every 5s) with position/progress
- Settings: send as document/media; persist format/quality; supported services list
- UI: responsive, dark theme, tabs, haptics, Telegram popups
- Security: HMAC-SHA256 validation, freshness check (24h), auth via init data
webapp/
├── static/
│ ├── index.html # main page
│ └── app.js # app logic
└── README.md # this doc
src/telegram/webapp.rs # web server
src/main.rs # bot integration
Add to .env:
WEBAPP_PORT=8080 # web server port
WEBAPP_URL=https://your-domain.com # public HTTPS URL
WEBAPP_URL must be HTTPS and reachable.
- Nginx reverse proxy (recommended)
- ngrok for dev (
ngrok http 8080and setWEBAPP_URLto the ngrok URL)
- Open @BotFather
/mybots→ choose bot → "Bot Settings" → "Menu Button" → "Configure menu button"- Button text:
🚀 Mini App - URL: your
WEBAPP_URL
WEBAPP_PORT=8080 cargo run
# or with explicit envs
WEBAPP_PORT=8080 WEBAPP_URL=https://your-domain.com cargo run- User opens Mini App → Telegram loads
index.htmlfrom the web server. - Mini App sends authenticated requests (header
X-Telegram-Init-Data) to the REST API to load user settings, stats, history, queue. - User enters URL, picks format/quality, optionally preview.
- Mini App POSTs
/api/download; rate limiter checks limits; task enqueued by plan priority. - Queue updates: client polls
/api/user/:id/queueevery 5s; shows status/position/progress. - Queue processes: yt-dlp downloads, bot sends file, DB updates status.
- All endpoints require
X-Telegram-Init-Datawith valid WebApp init data. - Server validates HMAC-SHA256 with bot token, freshness (<=24h), extracts
user_id. - Error responses include an
errorfield; typical HTTP codes: 400/401/404/429/500.
- For local dev without real HTTPS, use Telegram Desktop + ngrok.
- index.html uses Telegram CSS vars for theming; app.js handles WebApp SDK init, input/URL validation, and requests.
- Backend:
webapp.rscreates router (create_webapp_router,run_webapp_server), handlesweb_app_datain dispatcher, creates tasks and enqueues them.
- If Mini App won’t open: ensure
WEBAPP_URLis HTTPS and correct in BotFather; server running on the right port; check bot logs. - If data not sent: use browser DevTools → console errors; ensure
Telegram.WebAppis available; validate JSON payloads. - CORS issues:
tower-httpCORS is enabled inwebapp.rs; verify settings/features.
See project docs for deployment and API details.