Skip to content

ArtRuntime/happybot

Repository files navigation

🎵 HappyBot - Advanced Telegram Music Bot

A powerful, feature-rich Telegram bot for streaming music and videos in voice chats. Built with Python, Pyrogram, and PyTgCalls.

Python License Telegram

✨ Features

🎶 Music Streaming

  • 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

🤖 AI-Powered Autoplay

  • 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)

📁 Telegram Files

  • File Support: Play audio/video files uploaded to Telegram
  • Auto-Download: Automatically downloads and streams Telegram files
  • Progress Tracking: Real-time download progress indicators

👥 Multi-Userbot Support

  • 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

🎛️ Advanced Controls

  • 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

🚀 Quick Start

Prerequisites

Installation

  1. Clone the repository:
git clone https://huggingface.co/spaces/alex5402/happybot
cd happybot
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment:
cp sample.env .env
# Edit .env with your credentials
  1. 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
  1. Run the bot:
python -m bot

Docker Deployment

docker build -t happybot .
docker run -d --env-file .env happybot

📖 Usage

Basic Commands

  • /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

Admin/Sudo Commands

  • /addsession <string> - Add userbot session
  • /rmsession <name> - Remove userbot session
  • /sessions - List active sessions

Inline Controls

Every playback includes interactive buttons:

  • ⏯️ Pause/Resume
  • ⏭️ Skip
  • 🔁 Replay
  • ⏹️ Stop

🛠️ Technology Stack

🔧 Advanced Features

Recommendation Engine

  • Uses TF-IDF vectorization on song metadata
  • Trains on user listening history (5+ plays)
  • Fallback to genre-based recommendations
  • Supports multiple languages and genres

Smart Caching

  • Episode data cached per chat
  • Reduced API calls
  • Short callback data (under 64 bytes)
  • Indexed storage system

📊 Configuration

Optional Features

# Autoplay settings
AUTOPLAY_MODE=smart  # smart|random|off

# YouTube settings
YTDLP_VERBOSE=false
PLAYLIST_LIMIT=25

# Queue limits
QUEUE_LIMIT=50

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📧 Support

For support, join our Telegram Support Group or open an issue.


Made with ❤️ by alex5402

About

Advanced Telegram bot for music and video streaming in voice chat in telegram

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages