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
A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create cust

Aran 1 Oct 13, 2021
Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs.

pcs-toolbox Prisma Cloud utility scripts, and a Python SDK for Prisma Cloud APIs. Table of Contents Support Setup Configuration Script Usage CSPM Scri

Palo Alto Networks 34 Dec 15, 2022
A Telegram Video Watermark Adder Bot

Watermark-Bot A Telegram Video Watermark Adder Bot by @VideosWaterMarkRobot Features: Save Custom Watermark Image. Auto Resize Watermark According to

5 Jun 17, 2022
AWS Workmail Migration Tool

WMigrate A tool for migrating AWS Workmail Users and Groups cross region and cross accounts. It also creates user and group aliases and adds the users

NK 1 Oct 27, 2021
This discord bot will help you to control your target through PickleC2

PickleC2-Bot This discord bot will help you to control your target through PickleC2 WHAT's a PickleC2? PickleC2 is a simple C2 framework written in py

4 Jun 25, 2022
TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX)

TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX)

Crypto Trader 1 Jan 06, 2022
对hermit 的API进行简单的封装,做成了这个python moudle

hermit-py 对hermit 的API进行简单的封装,做成了这个Python Moudle,推荐通过wheel的方式安装。 目前对点击、滑动、模拟输入、找组件、等支持较好,支持查看页面的实时布局信息,再通过布局信息进行点击滑动等操作。 支持剪贴板相关的操作,支持设置剪贴的任意语言内容。

LookCos 40 Jun 25, 2022
An example of a chatbot with a number-based menu that can be used as a starting point for a project.

NumMenu Bot NumMenu Bot is an example chatbot showing a way to design a number-based menu assistant with Rasa. This type of bot is very useful on plat

Derguene 19 Nov 14, 2022
A python bot that will allow you to have maximum luck during Veve drops.

VeveBot You can follow me here Github | Twitter Features: - Click on the purchase at the time of the drop. - Be able to choose to do more than one tes

Rodz 1 Dec 04, 2021
The Python SDK for the BattleshAPI game

BattleshAPy The Python SDK for the BattleshAPI game Installation This library will be eventually going on PyPI, but until then, simply clone or downlo

Christopher 0 Apr 18, 2022
Discord Bot for League of Legends live match tracker

SABot Dicord Bot for League of Legends match auto tracker Features: Search Summoners statistics in League of Legends. Auto-notifications provide when

Jungyu Choi 4 Sep 27, 2022
The Python version of the official Discord bot for the Astura Studios Discord community server.

About Astura (Python version) is the official Discord bot for the Astura Studios Discord community server developed and maintained by Ascendus and the

Ascendus 1 Apr 21, 2022
Scrape Twitter for Tweets

Backers Thank you to all our backers! 🙏 [Become a backer] Sponsors Support this project by becoming a sponsor. Your logo will show up here with a lin

Ahmet Taspinar 2.2k Jan 02, 2023
The most fresh and updateable Telegram userbot. By one of the most active contibutors to GeekTG

Installation Script installation: Simply run this command out of root: . (wget -qO- http://gg.gg/get_hikka) Manual installation: apt update && apt in

Dan Gazizullin 150 Jan 04, 2023
An open source raffle bot made to increase the chance of winning limited sneaker raffles by automating entries.

🚀 SyneziaRaffles An open source raffle bot made to increase the chance of winning limited sneaker raffles by automating entries. 🏄‍♂️ Quick Start Pr

Alexis M. 29 Dec 22, 2022
An almost dependency-less, synchronous Discord gateway library meant for my personal use

An almost dependency-less, synchronous Discord gateway library meant for my personal use.

h0nda 4 Feb 05, 2022
A multipurpose bot designed to make Discord better for everyone, written in Python.

Hadum A multipurpose bot that makes Discord better for everyone Features A Fully Functional Moderation component: manage your staff, members and permi

1 Jan 25, 2022
Unofficial API wrapper for seedr.cc

Seedr API Unofficial API wrapper for seedr.cc Inspired by theabbie's seedr-api Powered by @harp_tech (Telegram) How to use You can install lib via git

Anjana Madu 49 Oct 24, 2022
ANKIT-OS/TG-MUSIC-PLAYER a special repository. Its Is A Telegram Bot To Play To Play Music In Voice Chat

🔥 🎶 TG MUSIC PLAYER 🎶 🔥 The owner would not be responsible for any kind of bans due to the bot. • ⚡ INSTALLING ⚡ • • 🛠️ Lᴀɴɢᴜᴀɢᴇs Aɴᴅ Tᴏᴏʟs 🔰 •

ANKIT KUMAR 1 Dec 27, 2021
Amazon AWS Web Tool (view only)

Amazon AWS Web Tool (AAWT) discontinued Features Cloudfront (simple) EC2 (With Charts and Prices) EC2 Reserved EBS ELB (With Charts) Obs:. only classi

Carlos Augusto Malucelli 9 Nov 07, 2022