PART 03 // AUTOMATION

Torrent → Google Drive using a Telegram Bot

Control downloads from anywhere. Send a link to your Telegram bot — it downloads, extracts, and moves the file to Google Drive.

Overview — one shot summary

You will install aria2 (URL downloader) and Transmission (torrent client), configure rclone for Google Drive, create a small Telegram bot script (sanitized here), start aria2 in RPC mode, then run the bot. Commands are shown in neon boxes — copy-paste into Google Cloud SSH.

Step 1 — Install core tools

sudo apt update sudo apt install -y aria2 transmission-daemon p7zip-full unzip curl curl https://rclone.org/install.sh | sudo bash # Then run: rclone config (create a remote, name it: gdrive)

Run these lines in the Google Cloud SSH window. During rclone config choose n (new remote) and follow auth steps in your browser.

Step 2 — Python deps & downloads folder

python3 -m pip install --upgrade pip pip install python-telegram-bot==20.3 aria2p transmission-rpc mkdir -p /home/YOUR_VM_USER/downloads

Replace /home/YOUR_VM_USER/ with your VM user path if different.

Step 3 — Start aria2 (RPC mode)

aria2c --enable-rpc --rpc-listen-all=false --rpc-allow-origin-all --rpc-secret="" -d /home/YOUR_VM_USER/downloads -j 16 -x 16 -s 16 & # check: ps aux | grep aria2c

Keep aria2 running. The bot connects to aria2 over RPC.

Sanitized bot.py — copy & paste into your editor

Open nano /home/YOUR_VM_USER/bot.py, paste the code below, save. Before running replace BOT_TOKEN and ADMIN_ID with your values.

#!/usr/bin/env python3 # Sanitized bot.py — REPLACE the BOT_TOKEN and ADMIN_ID placeholders before running. import os import asyncio import logging import zipfile import subprocess import aria2p import transmission_rpc from datetime import timedelta from telegram import Update from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes # --- CONFIG (REPLACE THESE) --- BOT_TOKEN = "PASTE_YOUR_TOKEN_HERE" ADMIN_ID = YOUR_TELEGRAM_ID RCLONE_REMOTE = "gdrive:/VM-Downloads" DOWNLOAD_DIR = "/home/YOUR_VM_USER/downloads" # --- CONNECTIONS --- aria2 = None tc = None try: aria2 = aria2p.API(aria2p.Client(host="http://localhost", port=6800, secret="")) except: print("⚠️ Aria2 offline") try: tc = transmission_rpc.Client(host='localhost', port=9091, username='admin', password='password') except: print("⚠️ Transmission offline") logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) if not os.path.exists(DOWNLOAD_DIR): os.makedirs(DOWNLOAD_DIR) status_map = {} async def start_download(update: Update, context: ContextTypes.DEFAULT_TYPE): if update.message.chat_id != ADMIN_ID: return link = update.message.text.strip() msg = await update.message.reply_html("⏳ Queueing...") asyncio.create_task(process_link_background(link, msg)) # (The rest of the working logic — aria2/transmission handling, extraction using 7z, rclone upload, status_map updates — is the same as the bot you used.) # Paste your full working logic here if you want the complete script in one shot.

Warning: do not publish your BOT_TOKEN or ADMIN_ID. Replace placeholders before running.

rclone upload example

rclone move /path/to/download_folder gdrive:/VM-Downloads --transfers=4 --progress --stats 3s

Change the /path/to/download_folder to your downloads path and the remote path if you named it differently.

Run the bot

python3 /home/YOUR_VM_USER/bot.py # to keep running after you close SSH: nohup python3 /home/YOUR_VM_USER/bot.py &
Final tips:
  1. Test with a small file first.
  2. Check logs if something fails: journalctl -u aria2 or ps aux | grep python.