telegram_upload package

Submodules

telegram_upload.client module

class telegram_upload.client.TelegramManagerClient(config_file, proxy=None, **kwargs)

Bases: telegram_upload.client.telegram_upload_client.TelegramUploadClient, telegram_upload.client.telegram_download_client.TelegramDownloadClient

property max_caption_length
property max_file_size
property me
start(phone=<function TelegramManagerClient.<lambda>>, password=<function TelegramManagerClient.<lambda>>, *, bot_token=None, force_sms=False, code_callback=None, first_name='New User', last_name='', max_attempts=3)

Starts the client (connects and logs in if necessary).

By default, this method will be interactive (asking for user input if needed), and will handle 2FA if enabled too.

If the phone doesn’t belong to an existing account (and will hence sign_up for a new one), you are agreeing to Telegram’s Terms of Service. This is required and your account will be banned otherwise. See https://telegram.org/tos and https://core.telegram.org/api/terms.

If the event loop is already running, this method returns a coroutine that you should await on your own code; otherwise the loop is ran until said coroutine completes.

Arguments
phone (str | int | callable):

The phone (or callable without arguments to get it) to which the code will be sent. If a bot-token-like string is given, it will be used as such instead. The argument may be a coroutine.

password (str, callable, optional):

The password for 2 Factor Authentication (2FA). This is only required if it is enabled in your account. The argument may be a coroutine.

bot_token (str):

Bot Token obtained by @BotFather to log in as a bot. Cannot be specified with phone (only one of either allowed).

force_sms (bool, optional):

Whether to force sending the code request as SMS. This only makes sense when signing in with a phone.

code_callback (callable, optional):

A callable that will be used to retrieve the Telegram login code. Defaults to input(). The argument may be a coroutine.

first_name (str, optional):

The first name to be used if signing up. This has no effect if the account already exists and you sign in.

last_name (str, optional):

Similar to the first name, but for the last. Optional.

max_attempts (int, optional):

How many times the code/password callback should be retried or switching between signing in and signing up.

Returns

This TelegramClient, so initialization can be chained with .start().

Example
client = TelegramClient('anon', api_id, api_hash)

# Starting as a bot account
await client.start(bot_token=bot_token)

# Starting as an user account
await client.start(phone)
# Please enter the code you received: 12345
# Please enter your password: *******
# (You are now logged in)

# Starting using a context manager (this calls start()):
with client:
    pass
telegram_upload.client.get_message_file_attribute(message)

telegram_upload.config module

telegram_upload.config.default_config()
telegram_upload.config.prompt_config(config_file)

telegram_upload.exceptions module

Exceptions for telegram-upload.

exception telegram_upload.exceptions.InvalidApiFileError(config_file, extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

exception telegram_upload.exceptions.MissingFileError(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

exception telegram_upload.exceptions.TelegramEnvironmentError(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

error_code = 31
exception telegram_upload.exceptions.TelegramInvalidFile(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

error_code = 3
exception telegram_upload.exceptions.TelegramProxyError(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

error_code = 30
exception telegram_upload.exceptions.TelegramUploadDataLoss(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

error_code = 29
exception telegram_upload.exceptions.TelegramUploadError(extra_body='')

Bases: Exception

body = ''
error_code = 1
exception telegram_upload.exceptions.TelegramUploadNoSpaceError(extra_body='')

Bases: telegram_upload.exceptions.TelegramUploadError

error_code = 28
exception telegram_upload.exceptions.ThumbError

Bases: Exception

exception telegram_upload.exceptions.ThumbVideoError

Bases: telegram_upload.exceptions.ThumbError

telegram_upload.exceptions.catch(fn)

telegram_upload.files module

telegram_upload.management module

Console script for telegram-upload.

class telegram_upload.management.MutuallyExclusiveOption(*args, **kwargs)

Bases: click.core.Option

handle_parse_result(ctx, opts, args)
property mutually_exclusive_text
telegram_upload.management.get_file_display_name(message)
async telegram_upload.management.interactive_select_dialog(client)
async telegram_upload.management.interactive_select_files(client, entity: str)
async telegram_upload.management.interactive_select_local_files()

telegram_upload.video module

telegram_upload.video.call_ffmpeg(args)
telegram_upload.video.get_ffmpeg_command()
telegram_upload.video.get_video_size(file)
telegram_upload.video.get_video_thumb(file, output=None, size=200)
telegram_upload.video.video_metadata(file)

Module contents

Top-level package for telegram-upload.