A simple MTProto-based bot that can download various types of media (>10MB) on a local storage

Overview

TG Media Downloader Bot 🤖

Preview

A telegram bot based on Pyrogram that downloads on a local storage the following media files: animation, audio, document, photo, video, voice.

The bot is inspired from the Telethon-based bot by rodriguezst.

TO-DO

  • It runs
  • It downloads supported media
  • Use a fallback for missing metadata
  • Allow custom names for un-named files instead of file_unique_id
  • Improve error handling related to Telegram's service

Why should I use a MTProto bot? 🧐

MTProto clients connect directly to Telegram’s servers, which means there is no HTTP connection, no “polling” or “web hooks”. This means less overhead, since the protocol used between you and the server is much more compact than HTTP requests with responses in wasteful JSON.

Since there is a direct connection to Telegram’s servers, even if their Bot API endpoint is down, you can still have connection to Telegram directly.

Using a MTProto client, you are also not limited to the public API that they expose, and instead, you have full control of what your bot can do.

HTTP Bots can't download file bigger than 10mb meanwhile MTProto can download files of 1.5~2GB!

How to use 🧠

After the setup the bot is ready to use, send/forward any supported media to the bot to download on local storage.

The bot supports the following commands:

Command Role
/start Initial command (invoked by Telegram) when you start the chat with the bot for the first time.
/help Gives you the available commands list.
/about Gives you information about the project.
/abort Cancel all the pending downloads.
/status Gives you the current configuration.
/usage Gives you the usage instructions.

Setup ⚙️

The bot requires the following env-vars o work properly:

Variable Name Role
TG_API_ID Telegram API ID obtained via developer settings (see here)
TG_API_HASH Telegram API HASH obtained via developer settings (see here)
TG_BOT_TOKEN Telegram Bot Token obtained via BotFather (see here)
TG_MAX_PARALLEL [OPTIONAL] Maximum number of parallel downloads allowed (default: 4)
A big number can cause flood bocks
TG_DL_TIMEOUT [OPTIONAL] Maximum time (in seconds) to wait for a download to complete (default: 5400)
In case of timeout the download is aborted and a error is triggered
TG_DOWNLOAD_PATH Download folder on the local storage/docker mount where the files will be downloaded
The files will appear inside the folder only after download completation
TG_AUTHORIZED_USER_ID List separated by comma of authorized users' id, you can get them using the userinfobot
It can't be empty

You can run the bot inside a Docker container or directly on your PC/Server OS.

Docker 🐋

If you want to containerize the bot, just pull or build a image and provide the requires env-vars.

A official GitHub Packages is available here.

Make sure that the download path is a mounted as a volume to allow the host system to access the downloaded files.

Barebone 🖥️

If you want to run the bot directly on your PC/Server OS, do the following:

  1. Make sure to have Python 3.6+ installed on your system;

  2. Create a folder anywhere on your pc and clone the repository there:

    git clone https://github.com/LightDestory/TG_MediaDownloader

  3. Install the requirements using pip:

    pip install -r requirements.txt

  4. Execute the bot and follow the wizard to provide the env-vars:

    python ./tg_downloader.py

Generating Telegram API keys

Before working with Telegram's API, you need to get your own API ID and hash:

  1. Go to My Telegram and login with your phone number;
  2. Click under API Development tools;
  3. A Create new application window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later;
  4. Click on Create application at the end. Remember that your API ID and API Hash are secrets and Telegram won't let you revoke it. Don't post it anywhere!

Creating a Telegram Bot

  1. Open a conversation with @BotFather in Telegram

  2. Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.

    • The name of your bot is displayed in contact details and elsewhere.
    • The Username is a short name, to be used in mentions and telegram.me links. Usernames are 5-32 characters long and are case-insensitive, but may only include Latin characters, numbers, and underscores. Your bot`s username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.
    • The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot.

Support

Coindrop

⚠️ License

This collection is under GNU GPL-3.0 License.

Owner
Alessio Tudisco
Italian Computer Science Student, Tech Addicted, Casual Gamer, Manga/Comic Reader
Alessio Tudisco
AutomaTik is an automation system for MikroTik devices with simplicity and security in mind.

AutomaTik Installation AutomaTik is an automation system for MikroTik devices with simplicity and security in mind. Winbox is the main tool for MikroT

Osman Kazdal 4 Dec 05, 2022
Discord-selfbot - Very basic discord self bot

discord-selfbot Very basic discord self bot still being actively developed requi

nana 4 Apr 07, 2022
Python bindings for ArrayFire: A general purpose GPU library.

ArrayFire Python Bindings ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific

ArrayFire 402 Dec 20, 2022
Simple Telegram Bot to Download and Upload Files From Mega.nz

Mega.nz-Bot Simple Telegram Bot to Download Files From Mega.nz and Upload It to Telegram Features All Mega.nz File Links supported No login required A

I'm Not A Bot #Left_TG 245 Jan 01, 2023
This project is based on discord.py and is meant to be a 'Quick Start Bot' to cut down on the time it takes to write complex discord bots.

This project is based on discord.py and is meant to be a 'Quick Start Bot' to cut down on the time it takes to write complex discord bots.

Alec Ibarra 1 Mar 03, 2022
1.本项目采用Python Flask框架开发提供(应用管理,实例管理,Ansible管理,LDAP管理等相关功能)

op-devops-api 1.本项目采用Python Flask框架开发提供(应用管理,实例管理,Ansible管理,LDAP管理等相关功能) 后端项目配套前端项目为:op-devops-ui jenkinsManager 一.插件python-jenkins bug修复 (1).插件版本 pyt

3 Nov 12, 2021
A bot that downloads all the necessary files from WeLearn and lists your assignments, filter due assignments, etc.

Welearn-bot This is a bot which lets you interact with WeLearn from the command line. It can Download all files/resources from your courses and organi

Parth Bibekar 17 Oct 19, 2022
Wrapper for Between - 비트윈을 위한 파이썬 라이브러리

PyBetween Wrapper for Between - 비트윈을 위한 파이썬 라이브러리 Legal Disclaimer 오직 교육적 목적으로만 사용할수 있으며, 비트윈은 VCNC의 자산입니다. 악의적 공격에 이용할시 처벌 받을수 있습니다. 사용에 따른 책임은 사용자가

1 Mar 15, 2022
Analog clock that shows the weather instead of the actual numerical hour it points to.

Eli's weatherClock An digital analog clock but instead of showing the hours, the clock shows the weather at that hour of the day. So instead of showin

Kovin 154 Dec 01, 2022
A quick-and-dirty script to scrape the daily menu of Leipzig University Mensa and send it to a telegram channel.

Feed me Mensa UL A quick-and-dirty script to scrape the daily menu of Leipzig University Mensa and send it to a telegram channel. For food and cat lov

3 Apr 08, 2022
PR Changes Matrix Builder

Pr-changes-matrix-builder - A Github Action that will output a variable to be used in a matrix strategy job based on a PR&'s changes

Kyle James Walker (he/him) 21 Oct 04, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

🖥️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
Dados Públicos de CNPJ disponibilizados pela Receita Federal do Brasil

Dados Públicos CNPJ Fonte oficial da Receita Federal do Brasil, aqui. Layout dos arquivos, aqui. A Receita Federal do Brasil disponibiliza bases com o

Aphonso Henrique do Amaral Rafael 102 Dec 28, 2022
The Main Pythonic Version Of Twig Using Nextcord

The Main Pythonic Version Of Twig Using Nextcord

8 Mar 21, 2022
A maintained fork of Danny's discord.py

Nextcord A modern, easy-to-use, feature-rich, and async-ready API wrapper for Discord written in Python. Fork notice This is a fork of discord.py, whi

977 Jan 05, 2023
Apple iTunes In-app purchase verification tool

itunes-iap v2 Python 2 & 3 compatible! Even with :mod:`asyncio` support! Source code: https://github.com/youknowone/itunes-iap Documentation: http://i

Jeong YunWon 129 Dec 10, 2022
PS3API - PS3 API for TMAPI and CCAPI in python.

PS3API PS3 API for TMAPI and CCAPI in python. Examples Connecting and Attaching from ps3api import PS3API PS3 = PS3API(PS3API.API_TMAPI) if PS3.Conn

Adam 9 Sep 01, 2022
this is an op music pyrogram music bot.

amanrajputpytgcallmusic this is an op music pyrogram music bot..... this bot user music bot can play music without being admin...... TG-MusicPlayer A

2 Dec 27, 2021
This Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild

Discord-Bot Goal of Project The purpose of this Discord bot is to give timely notifications to Students in the Lakehead CS 2021 Guild. How can I contr

8 Jan 30, 2022
A Telegram Message Manager Bot by @AbirHasan2005

Messages-Manager-Bot A Telegram Message Manager Bot by @AbirHasan2005. This Bot can delete specific type of messages from Group. I specially use for @

Abir Hasan 32 Nov 12, 2022