https://github.com/dheison0/telegram-downloader
Telegram bot for downloading files without a graphical session running
https://github.com/dheison0/telegram-downloader
bot docker pyrogram python telegram-bot
Last synced: 3 months ago
JSON representation
Telegram bot for downloading files without a graphical session running
- Host: GitHub
- URL: https://github.com/dheison0/telegram-downloader
- Owner: dheison0
- License: mit
- Created: 2022-08-15T12:31:58.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T14:05:47.000Z (4 months ago)
- Last Synced: 2025-03-21T05:32:49.655Z (3 months ago)
- Topics: bot, docker, pyrogram, python, telegram-bot
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 12
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[Pyrogram Framework]:
[My Telegram]:
[BotFather]:# Telegram downloader
This is a *simple* bot to download telegram files directly to your own server
without needing to keep telegram open or using telegram-cli, this uses Telegram's
MTProto protocol to download files up to 4GB using the [Pyrogram Framework].## Setup
To setup this bot on your own server you'll need a Telegram API ID/Hash, it can be
created at [My Telegram] website, do this before continueIf you want to run this bot on a docker server follow [Environment variables](#Environment%20variables)
guide and then [Docker install](#Docker%20install) guide.## Install dependencies
To install all needed dependencies use pip:
```bash
python3 -m pip install -r requirements.txt
```If you have any issue, try to install build-essentials in your system, the `psutil`
lib sometimes needs to be builded locally.## Environment variables
Observation: *This bot support dot files(`.env`)*
Now that you've your own ID/Hash it has to be passed to `TELEGRAM_API_ID` and
`TELEGRAM_API_HASH` environment variables, you also need to set the bot token(create
one [here][BotFather]) as `BOT_TOKEN`, and if you want to download files from channels
that doesn't allow forwarding/copying content you need to set `PHONE_NUMBER` with your
number that is used on a telegram account that is allowed to access the content you want
to download.The default **download** folder is `/data`, if you want to set another location define that
as `DOWNLOAD_FOLDER`, default **session** storage path is `/config` but it can be set by
`CONFIG_FOLDER`, this can be usefull for saving session across updates.You also need to set the bot administrator list using `ADMINS`, use spaces to separate
everyone.## Running
To run this bot it has to be started as a module, to this use `-m` flag:
```bash
python3 -m bot
```When you wanna stop the bot, press CTRL+\\
## Docker run
This bot is so simple that you only need to set some environment variables and mount a
folder inside the container to keep your downloads, for this, use this command replacing
values with your owns:```bash
# Build a docker image to your own server
docker build -t telegram-downloader .# Now run this
docker run \
-it `# optional, use -d if you won't use your account to download content` \
-v /home/$USER/TDownloader/data:/data \
-v /home/$USER/TDownloader/config:/config \
-e TELEGRAM_API_ID=123456 \
-e TELEGRAM_API_HASH="yourTelegramAPIHash" \
-e BOT_TOKEN="yourBotToken" \
-e PHONE_NUMBER="yourPhoneNumber" `# optional` \
-e ADMINS="@yourTelegramUsername" \
telegram-downloader
```