Telegram-cloud’s Documentation¶
What is this?¶
It’s a python library for Telegram messenger, which can give you an ability to download, upload, and more options to do with your Telegram account on CLI.
How should I use the documentation?¶
If you are getting started with the commands, you should follow the documentation in order by pressing the “Next” button at the bottom-right of every page.
You can also use the menu on the left to quickly skip over sections.
Installation¶
Telegram-cloud is a Python script-library, which means you need to download and install Python from https://www.python.org/downloads/ if you haven’t already. Once you have Python installed, for downloading the lastest version, run:
pip3 install -U telegram-cloud --user
Verification¶
To verify that the library is installed correctly, run the following command:
python3 -c "import telegramcloud""
If there’s not any error, It means telegram-cloud installed successfully, but if you see invalid syntax error, try installing again.
Optional Dependencies¶
If cryptg is installed, the library will work a lot faster, since encryption and decryption will be made in C instead of Python. If your code deals with a lot of updates or you are downloading/uploading a lot of files, you will notice a considerable speed-up (from a hundred kilobytes per second to several megabytes per second, if your connection allows it). If it’s not installed, pyaes will be used (which is pure Python, so it’s much slower).
If aiohttp is installed, the library will be able to download :tl:`WebDocument` media files (otherwise you will get an error).
If hachoir is installed, it will be used to extract metadata from files when sending documents. Telegram uses this information to show the song’s performer, artist, title, duration, and for videos too (including size). Otherwise, they will default to empty values, and you can set the attributes manually.
Note
Some of the modules may require additional dependencies before being
installed through pip
. If you have an apt
-based system, consider
installing the most commonly missing dependencies:
apt update
apt install clang lib{jpeg-turbo,webp}-dev python{,-dev} zlib-dev
pip install -U --user setuptools
pip install -U --user telethon cryptg pillow
Thanks to `@bb010g`_ for writing down this nice list.
Signing In¶
Before working with Telegram’s API, you need to get your own API ID and hash:
- Login to your Telegram account with the phone number of the developer account to use.
- Click under API Development tools.
- 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.
- Click on Create application at the end. Remember that your API hash is secret and Telegram won’t let you revoke it. Don’t post it anywhere!
Note
This API ID and hash is the one used by your application, not your phone number. You can use this API ID and hash with any phone number or even for bot accounts.
Signing In¶
Now you can signin by running:
tglogin
Enter the api_id
and api_hash
and give it a unique name
for your client, when you want to download/upload any file you need to know you want to send it with which account (maybe you signin multiple accounts).
Also you must enter your phone number, thanks to Telethon it supports 2FA password.
The config files and sessions save in ~/.telegam-cloud/
directory.