A Python bot that monitors YouTube channels and automatically sends notifications to Telegram groups/channels when new videos are uploaded.
- π Real-time monitoring of multiple YouTube channels
- π’ Instant notifications in Telegram when new videos are uploaded
- π― Clean and professional notification format with thumbnails
- π₯ Support for multiple Telegram groups/channels
- π Admin-only access control
- βοΈ Easy configuration via environment variables
- πΎ Persistent storage of channels and chat configurations
- π Automatic retry mechanism for failed notifications
- π‘οΈ Error handling and graceful shutdown
- Python 3.8+
- YouTube Data API v3 key
- Telegram Bot Token
- Required Python packages (see
requirements.txt)
- Clone the repository:
git clone https://github.com/ryuchi311/YouTube-Telegram-Notification-Bot.git
cd YouTube-Telegram-Notification-Bot
# YouTube Telegram Notification Bot
A simple, reliable Python bot that watches YouTube channels and sends notifications to Telegram groups/channels when new videos are published.
## Highlights
- Real-time monitoring of multiple YouTube channels
- Notifications with optional thumbnails and clickable links
- Smart link preview when thumbnails are disabled (small preview below text)
- Per-channel Telegram group links (Join_MyTG)
- Admin-only management commands
- Simple configuration via `.env` and `Pydata/` JSON files
## Quick start
1. Clone the repo:
```bash
git clone https://github.com/ryuchi311/YouTube-Telegram-Notification-Bot.git
cd YouTube-Telegram-Notification-Bot- Install dependencies:
pip install -r requirements.txt- Copy the environment template and edit it:
cp .env.template .env
# Edit .env and set YOUTUBE_API_KEY and TELEGRAM_BOT_TOKEN- Run the bot:
python YT-BOT.pyYT-BOT.pyβ main applicationtelegram_config.pyβ configuration manager (reads/writesPydata/)requirements.txtβ Python dependenciesPydata/telegram_chats.jsonβ saved Telegram chatsPydata/influencers.jsonβ monitored YouTube channels
A Dockerfile, docker-compose.yml, and docker-manage.sh are included for containerized deployment. See DOCKER.md.
YOUTUBE_API_KEYβ requiredTELEGRAM_BOT_TOKENβ requiredCHECK_INTERVALβ seconds between checks (default 300)THUMBNAILS_ENABLEDβ true/falseNOTIFICATIONS_ENABLEDβ true/falseADMIN_USERSβ comma-separated Telegram user IDs
Quick Command Reference β run these from an admin account in Telegram.
-
General:
/start_notifyβ show welcome message and quick tips/help_notifyβ full help and usage/how_notifyβ beginner setup guide
-
Chat / Bot Management:
/add_telegram_notifyβ add current chat to notifications (bot must be admin)/remove_notifyβ remove current chat from notifications/list_notifyβ list chats currently receiving notifications/pause_notifyβ pause all notifications/unpause_notifyβ resume notifications/status_notifyβ show bot status and stats
-
Thumbnail / Preview:
/enable_thumbnailsβ include video thumbnails in messages/disable_thumbnailsβ send text-only notifications/set_link_preview <option> <true|false>β fine tune link preview settings
-
YouTube Channel Management:
/add_youtube_channel <name> <id>β add a YouTube channel to monitor/add_youtube_channel_with_group <name> <id> <tg_link>β add channel and its TG group link/remove_youtube_channel <id>β remove a channel/list_youtube_channelsβ show monitored channels and TG links
-
Per-Group Channel Filters (NEW):
/enable_group_filter_notifyβ enable allowlist mode for this group (only allowed channels will post)/disable_group_filter_notifyβ disable group filter (allow all monitored channels)/allow_channel_notify <channel_id>β allow one monitored channel for this group/disallow_channel_notify <channel_id>β remove a channel from this group's allowlist/list_group_filter_notifyβ show this group's filter status and allowed channels/set_group_channels_notify id1,id2,...β bulk set allowed channels and enable the filter
-
Forum Topic (thread) Posting (NEW):
/set_group_topic_notify <message_thread_id>β send future notifications into this forum topic (requires group topics enabled)/clear_group_topic_notifyβ clear the configured topic and post to main chat
Examples:
# Allow two channels in current group and enable filter
/set_group_channels_notify UCR3aArAyYGXwJegyRGZ7WTg,UC-sXVjY3Lw1IGxsme-_4ixA
# Post notifications into forum topic id 12345
/set_group_topic_notify 12345
Notes:
- Commands that modify chat settings require you to be listed in
ADMIN_USERSin the bot.env(global admin). You can also editPydata/telegram_chats.jsondirectly if needed. channel_filter_enabled: falsemeans the group receives notifications from all monitored channels. Set it totrueand populateallowed_channel_idsto restrict./enable_group_filter_notifyβ enable per-group channel allowlist mode/disable_group_filter_notifyβ disable per-group filter (allow all)/allow_channel_notify <channel_id>β allow one monitored channel in current group/disallow_channel_notify <channel_id>β remove one allowed channel in current group/list_group_filter_notifyβ show current group filter status and allowlist
When a new video is detected the bot sends:
With thumbnails enabled (default):
π₯ NEW UPLOAD WATCH NOW π₯
βββββββββββββββββββββββββββ
π¬ <Video title (clickable)>
πΊ <Channel (clickable)>
π
<Upload date UTC>
<Join_MyTG (clickable if provided)> #ChannelName
Includes video thumbnail image
With thumbnails disabled:
π₯ NEW UPLOAD WATCH NOW π₯
βββββββββββββββββββββββββββ
π¬ <Video title (clickable)>
πΊ <Channel (clickable)>
π
<Upload date UTC>
<Join_MyTG (clickable if provided)> #ChannelName
Includes small link preview below text (using LinkPreviewOptions)
- If the bot doesn't respond: check
.envvalues and runpython YT-BOT.pyto view logs - If
Chat not founderrors appear: the bot may have been removed or blocked from the group - Network issues: the bot retries on transient errors; verify server connectivity
Fork, create a branch, implement changes, open a pull request.
MIT
For the full command list and step-by-step beginner guide see Pydata/command.txt.