A powerful, feature-rich Telegram bot for streaming music and videos in voice chats. Built with Python, Pyrogram, and PyTgCalls.
- YouTube Integration: Stream music/videos directly from YouTube
- Smart Search: Intelligent search with support for queries and direct URLs
- Playlist Support: Queue entire YouTube playlists
- High Quality: Up to 720p video and high-quality audio streaming
- Live Controls: Play, pause, skip, stop, and replay functionality
- TF-IDF Recommendations: Smart song suggestions based on listening history
- Genre Detection: Automatic genre, artist, and language detection
- Personalized: Learns from your music preferences
- YouTube-Only: Autoplay works only for YouTube sources (search & URLs)
- File Support: Play audio/video files uploaded to Telegram
- Auto-Download: Automatically downloads and streams Telegram files
- Progress Tracking: Real-time download progress indicators
- Dynamic Sessions: Hot-reload userbot sessions without restart
- Session Management: Add/remove userbots on-the-fly
- MongoDB Storage: Sessions stored securely in database
- Auto-Migration: Automatic migration from env-based sessions
- Inline Keyboards: Beautiful interactive controls
- Queue Management: View and manage playback queue
- Seek Support: Jump to specific timestamps
- Autoplay Toggle: Enable/disable autoplay per chat
- Admin Controls: Restrict playback to admins when needed
- Python 3.10 or higher
- MongoDB database
- Telegram Bot Token (BotFather)
- Telegram API ID & Hash (my.telegram.org)
- Clone the repository:
git clone https://huggingface.co/spaces/alex5402/happybot
cd happybot- Install dependencies:
pip install -r requirements.txt- Configure environment:
cp sample.env .env
# Edit .env with your credentials- Required Environment Variables:
BOT_TOKEN=your_bot_token
API_ID=your_api_id
API_HASH=your_api_hash
MONGO_DB_URI=mongodb://localhost:27017
OWNER_ID=your_telegram_user_id- Run the bot:
python -m botdocker build -t happybot .
docker run -d --env-file .env happybot/start- Start the bot/help- Show help menu/play <query>- Play audio from YouTube (search or URL)/vplay <query>- Play video from YouTube (search or URL)/stop- Stop playback and clear queue/pause- Pause playback/resume- Resume playback/skip- Skip to next track/queue- Show queued tracks/seek <seconds>- Seek forward/seekback <seconds>- Seek backward/autoplay- Toggle smart autoplay/ping- Check bot status/stats- Show statistics
/addsession <string>- Add userbot session/rmsession <name>- Remove userbot session/sessions- List active sessions
Every playback includes interactive buttons:
- ⏯️ Pause/Resume
- ⏭️ Skip
- 🔁 Replay
- ⏹️ Stop
- Pyrogram: Telegram MTProto API framework
- PyTgCalls: Voice chat streaming
- yt-dlp: YouTube video extraction
- MongoDB: Database for sessions and cache
- FastAPI: Web server for health checks
- scikit-learn: ML-powered recommendations
- Uses TF-IDF vectorization on song metadata
- Trains on user listening history (5+ plays)
- Fallback to genre-based recommendations
- Supports multiple languages and genres
- Episode data cached per chat
- Reduced API calls
- Short callback data (under 64 bytes)
- Indexed storage system
# Autoplay settings
AUTOPLAY_MODE=smart # smart|random|off
# YouTube settings
YTDLP_VERBOSE=false
PLAYLIST_LIMIT=25
# Queue limits
QUEUE_LIMIT=50Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, join our Telegram Support Group or open an issue.
Made with ❤️ by alex5402