Skip to content

abdo-hash1/tele-bot

Repository files navigation

Telegram to Google Drive Video Bot 🤖

Automatically upload videos sent to your Telegram "Saved Messages" to Google Drive. Designed for hourly VPS sessions.

Features

  • 📥 Downloads videos of any size (500MB - 2GB+)
  • ☁️ Resumable uploads to Google Drive
  • 🔄 Queue persistence across VPS restarts
  • 📲 Real-time Telegram notifications
  • 🐳 Docker-based for quick deployment

Quick Start (VPS)

# 1. Clone repo
git clone https://github.com/YOUR_USERNAME/telegram-drive-bot.git
cd telegram-drive-bot

# 2. Copy your credential files
# (see One-Time Setup below if you don't have these yet)

# 3. Configure environment
cp .env.example .env
nano .env  # Add your API credentials

# 4. Start the bot
docker compose up -d

One-Time Setup (Local Machine)

1. Get Telegram API Credentials

  1. Go to my.telegram.org
  2. Log in with your phone number
  3. Click "API development tools"
  4. Create a new application
  5. Copy your api_id and api_hash

2. Generate Pyrogram Session

Run this on your local machine (requires phone for verification):

# Install dependencies
pip install pyrogram tgcrypto

# Run session generator
python generate_session.py

This creates telegram_drive_bot.session - you'll need this file.

3. Create Google Drive Folder

  1. Open Google Drive
  2. Create a folder named tele bot (or any name)
  3. Open the folder
  4. Copy the folder ID from the URL:
    https://drive.google.com/drive/folders/1ABC123xyz
                                           └── This is your folder ID
    

4. Prepare Your Files

You should have these files ready:

  • token.pickle - Your Google OAuth pickle file
  • telegram_drive_bot.session - Generated in step 2
  • Your Telegram api_id and api_hash

VPS Deployment

Option A: Manual Setup

# SSH into your VPS
ssh user@your-vps-ip

# Clone and setup
git clone https://github.com/YOUR_USERNAME/telegram-drive-bot.git
cd telegram-drive-bot

# Upload credential files (run from your local machine)
scp token.pickle telegram_drive_bot.session user@your-vps-ip:~/telegram-drive-bot/

# On VPS: move session file to correct location
mkdir -p session
mv telegram_drive_bot.session session/

# Configure
cp .env.example .env
nano .env
# Add:
#   TELEGRAM_API_ID=your_id
#   TELEGRAM_API_HASH=your_hash
#   DRIVE_FOLDER_ID=your_folder_id

# Start
docker compose up -d

Option B: One-Liner (After First Setup)

After the first setup, you can restart with:

cd ~/telegram-drive-bot && docker compose up -d

Usage

  1. Send a video to your Telegram "Saved Messages"
  2. Bot downloads the video and shows progress
  3. Bot uploads to Google Drive with progress
  4. Bot sends you the Drive link when complete

Commands

  • /status - Check bot status and queue

File Structure

telegram-drive-bot/
├── bot/
│   ├── main.py              # Entry point
│   ├── telegram_handler.py  # Video download handling
│   ├── drive_uploader.py    # Drive upload with resume
│   └── queue_manager.py     # Persistent queue
├── session/                 # Pyrogram session file
├── queue/                   # Upload queue (persists)
├── downloads/               # Temporary downloads
├── token.pickle             # Google OAuth credentials
├── .env                     # Configuration
├── Dockerfile
└── docker-compose.yml

Troubleshooting

"Session file not found"

Generate the session file locally using generate_session.py

"Token pickle not found"

Ensure token.pickle is in the project root directory

"Upload failed"

The file is saved locally and will be retried on next restart

Check logs

docker compose logs -f

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published