Skip to content
bisnurayPublic

About

Telecast — a Telegram voice-chat music & video bot. Stream YouTube tracks, playlists, live streams and audio/video files into group voice chats with inline controls, audio effects and rankings.

Topics

Resources

Stars

45 stars

Watchers

0 watching

Forks

Repository files navigation

Telecast

A Telegram voice-chat music & video bot.

Stream YouTube tracks (or your own audio/video files) straight into a group voice chat — with a rich inline player, playlists, audio effects, live-call title updates, and per-group rankings.

GitHub stars GitHub forks GitHub issues GitHub pull requests
Python 3.11 MongoDB py-tgcalls MIT License


Jump to


Features

  • Music & video streaming — play YouTube audio or video into a voice chat.
  • Inline player — pause / resume / skip / stop / seek / rewind / replay / volume, all from buttons.
  • Audio effects — Bass Boost, Nightcore, Slowed, Lofi, 8D.
  • Playback speed — from 0.5x to 2.0x.
  • Loop modes — off / repeat-track / repeat-queue.
  • Playlists — load a whole YouTube playlist (lazy-fetched 10 tracks at a time), plus save / load / delete named playlists.
  • Rankings — daily, weekly and global top-listeners, rendered as banner images.
  • Telegram files — reply to an audio/video file to queue it directly.
  • Live streams — plays YouTube live streams.
  • Inline search — type @YourBot song name in any chat to search YouTube.
  • Live call title — updates the group call title to the currently playing track.
  • Voice-chat welcome — greets listeners inside the voice chat when they join.
  • Multi-chat — serves many groups at once.
  • Permissions — group-admins plus a per-group "VC admin" system.
  • Broadcast — owner-only message broadcast to all users/groups.

Requirements

With Docker you only need Docker and a MongoDB (or Atlas). The table below is for running without Docker.

Runtime (not installable via pip):

Dependency Why Install
Python 3.11 runtime python.org
ffmpeg audio effects + re-encoding apt install ffmpeg (or ffmpeg.org)
yt-dlp CLI live-stream URL extraction installed automatically by run.sh
MongoDB all persistence mongodb.com or Atlas
Deno YouTube JS-challenge solving for yt-dlp installed automatically by run.sh

Note on Deno: it is required for solving YouTube's JS challenges. run.sh installs it automatically if missing.

Python packages are listed in requirements.txt and installed automatically by run.sh.


Quick start

The easiest way to run Telecast is with Docker. The image already includes Python 3.11, ffmpeg, the yt-dlp CLI and Deno, so the host only needs Docker.

git clone https://github.com/bisnuray/Telecast.git
cd Telecast

# 1. Fill in your credentials
cp .env.example .env
nano .env

# 2. Add your YouTube cookies (see "YouTube cookies" below)
mkdir -p cookies
# place your Netscape-format cookies at cookies/yt.txt

# 3. Build and start
docker compose up -d --build

Docker

docker compose up -d --build           # build and start
docker compose logs -f telecast        # follow logs
docker compose down                    # stop
  • cookies/ is mounted read-only, logs/ is mounted so logs/bot.log stays on the host.
  • The bot's .session file is kept in the telecast-data volume, so it survives rebuilds.
  • After changing code, run docker compose up -d --build again.

Local MongoDB (optional): if you don't use Atlas, start the bundled MongoDB too and set MONGODB_URI=mongodb://mongo:27017/vcbot in .env:

docker compose --profile mongo up -d --build

Without Docker

Install the requirements yourself, or let run.sh do it. It installs/upgrades the Python dependencies, yt-dlp, Deno and ffmpeg if missing, then starts the bot:

./run.sh

Or manually:

pip install -r requirements.txt
python3.11 bot.py

Don't run the Docker container and the bot without Docker at the same time — both would use the same bot token.


Setup in detail

1. Get your API credentials

  1. Go to my.telegram.org and log in.
  2. Create an app to get API_ID and API_HASH.
  3. Create your bot with @BotFather to get BOT_TOKEN.

2. Get a user SESSION_STRING

The bot uses two accounts:

  • telecast — your bot (runs on BOT_TOKEN).
  • user_client — a user account (runs on SESSION_STRING). This is the account that actually joins the voice chat and streams, because Telegram requires a user (not a bot) to stream audio in a voice chat.

Generate the session string using @TgDevToolBot:

  1. Open Telegram and start @TgDevToolBot.
  2. Select 🔐 Pyrogram Session from the menu.
  3. Enter your API_ID and API_HASH when prompted.
  4. Log in with the user account's phone number and the OTP code.
  5. Copy the resulting string into .env as SESSION_STRING.

3. MongoDB

Use a local MongoDB (mongodb://localhost:27017/vcbot) or a free MongoDB Atlas cluster. Put the URI in .env.

4. YouTube cookies

YouTube may block downloads from datacenter IPs ("Sign in to confirm you're not a bot"). To avoid this, export your browser's YouTube cookies in Netscape format and save them to cookies/yt.txt.

  • Easiest method: a browser extension such as Get cookies.txt LOCALLY.
  • The file must be Netscape/HTTP-cookie format (# Netscape HTTP Cookie File header followed by tab-separated rows).

Configuration

All configuration lives in .env (see .env.example).

Variable Required Default Description
API_ID Yes — Telegram app ID
API_HASH Yes — Telegram app hash
BOT_TOKEN Yes — Bot token from BotFather
SESSION_STRING Yes — User-account string session
MONGODB_URI Yes mongodb://localhost:27017/vcbot MongoDB connection URI
LOG_LEVEL — INFO Logging level
LOG_CHAT_ID — 0 Chat ID to receive log notifications
MAX_QUEUE_SIZE — 100 Max tracks per queue
MAX_CONCURRENT_CHATS — 50 Max simultaneous voice chats
MAX_PLAYLIST_TRACKS — 50 Max tracks loaded from a playlist
MAX_TRACK_DURATION — 7200 Max track length (seconds)
AUTOPLAY_BATCH_SIZE — 5 Related tracks queued when autoplay is allowed
AUTOPLAY_PROMPT_TIMEOUT — 90 Seconds to wait for an answer to the autoplay prompt
CACHE_CHAT_ID — 0 Channel used to cache uploaded audio by file_id
PREFETCH_ENABLED — true Pre-download the next track while the current one plays
YOUTUBE_PROXY — — Proxy for yt-dlp, search and live streams (http://user:pass@host:port)
SESSION_DIR — . Folder for the bot's .session file (/app/data in Docker)

Note: BOT_OWNER_ID (used for /restart, /broadcast, and /logs) is hardcoded in telecast/core/config.py. Change it to your own Telegram user ID before deploying.


Commands

Commands work with both / and . prefixes (e.g. /play or .play). Most work only in groups where the bot is present.

Command Description
/start Show the welcome message
/help Show help
/play <query|url|playlist> Play a song / video / playlist from YouTube
/pause Pause playback
/resume Resume playback
/skip Skip to the next track
/stop / /end Stop and leave the voice chat
/seek <seconds> Seek forward (+) or backward (−)
/rewind Rewind 10 seconds
/vcmute Mute the voice chat
/vcunmute Unmute the voice chat
/playlist Show the current queue
/clearplaylist Clear upcoming tracks
/settings Open the settings menu (admin)
/vcadmin Grant voice-chat control to a user (admin)
/vcunadmin Revoke voice-chat control (admin)
/rank / /ranking View group rankings
/status Show bot statistics
/restart Restart the bot (owner)
/broadcast Broadcast a replied-to message (owner)
/logs View and clear the bot log file (owner)

Player inline buttons

The now-playing message includes a full control bar:

  • ⏯ Pause / Resume, ⏭ Skip, ⏹ Stop
  • 🔁 Loop (off / track / queue)
  • ⏪ Rewind, ⏩ Seek, 🔃 Replay
  • 🔊 Volume, 🔇/🔊 Mute / Unmute
  • 🎚 Effects & ⏩ Speed menus
  • 📜 Queue pager, 🔀 Shuffle, 🗑 Clear queue

Audio effects & speed

Effect Button
Normal 🎵 Normal
Bass Boost 🔊 Bass Boost
Nightcore ⚡ Nightcore
Slowed 🐢 Slowed
Lofi 📻 Lofi
8D 🎧 8D

Playback speed presets: 0.5x, 0.75x, 1.0x, 1.25x, 1.5x, 2.0x.


Settings

Open with /settings (admin). Available toggles:

  • Mode — audio or video
  • Quality — 360p / 480p / 720p / 1080p
  • Audio quality — low / medium / high
  • Autoplay — when the queue drains, ask whether to keep playing related songs
  • Title update — update the live call title to the current track
  • Admin-only mode — restrict playback to admins/VC-admins
  • Shuffle
  • Mention requester
  • Playlist permission — who may load playlists (everyone / admins)
  • Autoplay permission — who may answer the autoplay prompt (everyone / admins)
  • VC Welcome — greet listeners when they join the voice chat

Autoplay

With Autoplay on, the bot never starts related songs on its own — it asks first. When the last queued track ends, it posts the track it just played with two buttons:

Button Result
Play Related Songs Queues AUTOPLAY_BATCH_SIZE related tracks (from YouTube's own related list) and keeps playing
No Thanks Stops playback and leaves the voice chat

If nobody answers within AUTOPLAY_PROMPT_TIMEOUT seconds, playback stops. When the related batch drains, the bot asks again — so it behaves like a radio while still giving the group a decision point. Related songs are only offered when the last track was a YouTube one; tracks longer than MAX_TRACK_DURATION are skipped.

Autoplay permission decides who may press those buttons:

  • Everyone (default) — any member of the group can answer
  • Admins — only group admins and VC admins can answer; others get an alert

Voice-chat welcome

When someone joins the voice chat while music is playing, the assistant posts a short greeting inside the call — the text bubble that appears over the voice chat:

👋 Welcome, Alex! Enjoy the music 🎶

Each listener is greeted once per call. If they leave and rejoin the same voice chat, nothing is sent; when the call ends and a new one starts, they are greeted again. The assistant never greets itself.

Turn it off per group with 👋 VC Welcome in /settings (on by default).

Two things to know:

  • Greetings use Telegram's in-call messages, which only exist while the assistant is in the call — so they appear during playback, not in the group's message history.
  • The voice chat must have messages enabled (an admin setting in Telegram). If they are off, Telegram rejects the message; the bot logs why and posts nothing to the group instead of falling back to a normal chat message.

Rankings

/rank renders a banner image of top listeners.

  • Daily and Weekly — per-group.
  • Global — across all groups.

Switch between them using the inline buttons on the ranking message.


Troubleshooting

Problem Fix
"Sign in to confirm you're not a bot" YouTube is bot-checking your IP. Add/refresh cookies/yt.txt, or route through a proxy/residential IP.
"Network is unreachable" to googlevideo.com YouTube CDN is unreachable from your server. Try a different region or a proxy.
Download fails for some tracks Make sure yt-dlp is up to date (pip install -U yt-dlp).
User account won't join the call The user account must be in the group and the bot must be admin.
Title doesn't update The user account needs the "Manage Voice Chats" admin permission.
SESSION_STRING invalid Regenerate the string session (see Setup).

Known Issues

Bot doesn't leave the voice chat when an audio effect is applied

When a track plays with an audio effect (Bass Boost, Nightcore, Slowed, Lofi, or 8D), the bot may not auto-leave the voice chat after it ends. With 🎵 Normal, it leaves correctly.

The effect runs through an FFmpeg filter chain that can block the end-of-stream signal, so the bot doesn't detect that the track has finished. The fix belongs in telecast/services/stream.py (end-of-stream detection) and telecast/services/effects.py (filter chain) — contributions welcome!


Contributing

Contributions are welcome!

  1. Fork the repo and clone your fork.
  2. Install Python 3.11 and the dependencies (pip install -r requirements.txt).
  3. Make your changes, keeping the style consistent with the rest of the project.
  4. Test by running the bot (python3.11 bot.py) and checking logs/bot.log.
  5. Open a pull request describing what changed and why.

Don't commit secrets — .env, *.session*, and cookies/yt.txt are gitignored.


Support


License & credits

This project is licensed under the MIT License. You are free to use, copy, modify, merge, publish, distribute, sublicense, and/or sell the software, provided the copyright notice above is included in all copies or substantial portions.

© @itsSmartDev — copyright holder.

Built with Pyrogram (via the kurigram fork), py-tgcalls, ntgcalls, yt-dlp, MongoDB/motor, Pillow and numpy.


Ethical Notice

Ethics Reminder: Simply modifying a few lines of code does not constitute original authorship. When forking a project, always fork responsibly and give proper credit to the original creators.

About

Telecast — a Telegram voice-chat music & video bot. Stream YouTube tracks, playlists, live streams and audio/video files into group voice chats with inline controls, audio effects and rankings.

Topics

Resources

Stars

45 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages