slidgram.client#

Module Contents#

Classes#

CredentialsValidation

param api_id:

Application identifier for Telegram API access, which can be obtained at https://my.telegram.org

TelegramClient

param api_id:

Application identifier for Telegram API access, which can be obtained at https://my.telegram.org

Functions#

get_base_kwargs(user_reg_form)

slidgram.client.get_base_kwargs(user_reg_form)[source]#
Parameters:

user_reg_form (dict) –

exception slidgram.client.Timeout(*a, **k)[source]#

Bases: asyncio.TimeoutError, slixmpp.exceptions.XMPPError

Timeout expired.

Initialize self. See help(type(self)) for accurate signature.

exception slidgram.client.BadRequest(base)[source]#

Bases: aiotdlib.api.BadRequest, slixmpp.exceptions.XMPPError

This is the base exception class for all TDLib API related errors.

Initialize self. See help(type(self)) for accurate signature.

Parameters:

base (aiotdlib.api.BadRequest) –

exception slidgram.client.Unauthorized(base)[source]#

Bases: aiotdlib.api.Unauthorized, slixmpp.exceptions.XMPPError

This is the base exception class for all TDLib API related errors.

Initialize self. See help(type(self)) for accurate signature.

Parameters:

base (aiotdlib.api.Unauthorized) –

exception slidgram.client.NotFound(base)[source]#

Bases: aiotdlib.api.NotFound, slixmpp.exceptions.XMPPError

This is the base exception class for all TDLib API related errors.

Initialize self. See help(type(self)) for accurate signature.

Parameters:

base (aiotdlib.api.NotFound) –

class slidgram.client.CredentialsValidation(registration_form)[source]#

Bases: aiotdlib.Client

Parameters:
  • api_id (int) – Application identifier for Telegram API access, which can be obtained at https://my.telegram.org

  • api_hash (str) – Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org

  • database_encryption_key (str) – Encryption key of local session database. Default: aiotdlib

  • phone_number (str Either phone_number or bot_token MUST be passed. ValueError would be raised otherwise) – The phone number of the user, in international format.

  • bot_token (str) – The bot token. Either phone_number or bot_token MUST be passed. ValueError would be raised otherwise

  • use_test_dc (bool) – If set to true, the Telegram test environment will be used instead of the production environment

  • system_language_code (str) – IETF language tag of the user’s operating system language; must be non-empty

  • device_model (str) – Model of the device the application is being run on; must be non-empty

  • system_version (str) – Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib

  • application_version (str) – Application version; must be non-empty

  • files_directory (str) – The path to the directory for storing files. Default: .aiotdlib/

  • first_name (str) – First name of new account if account with passed phone_number does not exist

  • last_name (str) – Last name of new account if account with passed phone_number does not exist

  • library_path (str) – Path to TDLib binary. By default, binary included in package is used

  • tdlib_verbosity (str) – Verbosity level of TDLib itself. Default: 2 (WARNING) for more info look at (TDLibLogVerbosity)

  • debug (bool) – When set to true all request and responses would be logged in console with DEBUG level

  • parse_mode (str) – Default parse mode for high-level methods like send_message. Default: html

  • proxy_settings (ClientProxySettings) – Settings for proxying telegram connection

  • use_file_database (bool) – If set to true, information about downloaded and uploaded files will be saved between application restarts

  • use_chat_info_database (bool) – If set to true, the library will maintain a cache of users, basic groups, supergroups, channels and secret chats. Implies use_file_database

  • use_message_database (bool) – If set to true, the library will maintain a cache of chats and messages. Implies use_chat_info_database

  • use_secret_chats (bool) – If set to true, support for secret chats will be enabled

  • enable_storage_optimizer (bool) – If set to true, old files will automatically be deleted

  • ignore_file_names (bool) – If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name

  • options (ClientOptions) – Writable TDLib options (Check the list of available options on https://core.telegram.org/tdlib/options.)

  • registration_form (dict) –

async _auth_get_code(code_type='SMS')[source]#
Parameters:

code_type (str) –

async _auth_get_password()[source]#
async get_main_list_chats(limit=0)[source]#

Returns an ordered list of chats in a main chat list. Chats are sorted by the pair (chat.position.order, chat.id) in descending order

Parameters:

limit (int) – Maximum amount of chats to be returned

class slidgram.client.TelegramClient(session)[source]#

Bases: aiotdlib.Client

Parameters:
  • api_id (int) – Application identifier for Telegram API access, which can be obtained at https://my.telegram.org

  • api_hash (str) – Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org

  • database_encryption_key (str) – Encryption key of local session database. Default: aiotdlib

  • phone_number (str Either phone_number or bot_token MUST be passed. ValueError would be raised otherwise) – The phone number of the user, in international format.

  • bot_token (str) – The bot token. Either phone_number or bot_token MUST be passed. ValueError would be raised otherwise

  • use_test_dc (bool) – If set to true, the Telegram test environment will be used instead of the production environment

  • system_language_code (str) – IETF language tag of the user’s operating system language; must be non-empty

  • device_model (str) – Model of the device the application is being run on; must be non-empty

  • system_version (str) – Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib

  • application_version (str) – Application version; must be non-empty

  • files_directory (str) – The path to the directory for storing files. Default: .aiotdlib/

  • first_name (str) – First name of new account if account with passed phone_number does not exist

  • last_name (str) – Last name of new account if account with passed phone_number does not exist

  • library_path (str) – Path to TDLib binary. By default, binary included in package is used

  • tdlib_verbosity (str) – Verbosity level of TDLib itself. Default: 2 (WARNING) for more info look at (TDLibLogVerbosity)

  • debug (bool) – When set to true all request and responses would be logged in console with DEBUG level

  • parse_mode (str) – Default parse mode for high-level methods like send_message. Default: html

  • proxy_settings (ClientProxySettings) – Settings for proxying telegram connection

  • use_file_database (bool) – If set to true, information about downloaded and uploaded files will be saved between application restarts

  • use_chat_info_database (bool) – If set to true, the library will maintain a cache of users, basic groups, supergroups, channels and secret chats. Implies use_file_database

  • use_message_database (bool) – If set to true, the library will maintain a cache of chats and messages. Implies use_chat_info_database

  • use_secret_chats (bool) – If set to true, support for secret chats will be enabled

  • enable_storage_optimizer (bool) – If set to true, old files will automatically be deleted

  • ignore_file_names (bool) – If set to true, original file names will be ignored. Otherwise, downloaded files will be saved under names as close as possible to the original name

  • options (ClientOptions) – Writable TDLib options (Check the list of available options on https://core.telegram.org/tdlib/options.)

  • session (slidgram.session.Session) –

async get_main_list_chats(limit=10)[source]#

Returns an ordered list of chats in a main chat list. Chats are sorted by the pair (chat.position.order, chat.id) in descending order

Parameters:

limit (int) – Maximum amount of chats to be returned

async request(query, *, request_id=None, request_timeout=None)[source]#
Parameters:
  • query (aiotdlib.api.BaseObject) –

  • request_id (str) –

  • request_timeout (Optional[int]) –

Return type:

Optional[aiotdlib.client.RequestResult]

async dispatch_update(_self, update)[source]#
Parameters:

update (aiotdlib.api.Update) –

async handle_NewMessage(update)[source]#
Parameters:

update (aiotdlib.api.UpdateNewMessage) –

async handle_UserStatus(update)[source]#
Parameters:

update (aiotdlib.api.UpdateUserStatus) –

async handle_ChatReadOutbox(update)[source]#
Parameters:

update (aiotdlib.api.UpdateChatReadOutbox) –

async handle_ChatAction(action)[source]#
Parameters:

action (aiotdlib.api.UpdateChatAction) –

async handle_ChatReadInbox(action)[source]#
Parameters:

action (aiotdlib.api.UpdateChatReadInbox) –

async handle_ChatTitle(update)[source]#
Parameters:

update (aiotdlib.api.UpdateChatTitle) –

async __get_contact_or_participant(msg)[source]#
Parameters:

msg (aiotdlib.api.Message) –

async handle_MessageContent(action)[source]#
Parameters:

action (aiotdlib.api.UpdateMessageContent) –

async get_poll_voters(chat_id, message_id, choice_id)[source]#
Parameters:
  • chat_id (int) –

  • message_id (int) –

  • choice_id (int) –

async update_poll_votes(action)[source]#
Parameters:

action (aiotdlib.api.UpdateMessageContent) –

async handle_User(action)[source]#
Parameters:

action (aiotdlib.api.UpdateUser) –

async handle_NewChat(action)[source]#
Parameters:

action (aiotdlib.api.UpdateNewChat) –

async handle_MessageInteractionInfo(update)[source]#
Parameters:

update (aiotdlib.api.UpdateMessageInteractionInfo) –

async react_group(update)[source]#
Parameters:

update (aiotdlib.api.UpdateMessageInteractionInfo) –

async handle_DeleteMessages(update)[source]#
Parameters:

update (aiotdlib.api.UpdateDeleteMessages) –

async handle_MessageSendSucceeded(update)[source]#
Parameters:

update (aiotdlib.api.UpdateMessageSendSucceeded) –

async handle_BasicGroupFullInfo(update)[source]#
Parameters:

update (aiotdlib.api.UpdateBasicGroupFullInfo) –

async handle_ActiveEmojiReactions(update)[source]#
Parameters:

update (aiotdlib.api.UpdateActiveEmojiReactions) –

async is_private_chat(chat_id)[source]#
Parameters:

chat_id (int) –

async get_local_path(file)[source]#
Parameters:

file (aiotdlib.api.File) –

Return type:

Optional[pathlib.Path]

async send_formatted_text(chat_id, text, *, reply_to_message_id=None)[source]#
Parameters:
  • chat_id (int) –

  • text (aiotdlib.api.FormattedText) –

  • reply_to_message_id (Optional[int]) –