Storage#

class pyrogram.storage.Storage#

Abstract class for storage engines.

Parameters:

name (str) – The name of the session.

abstract async open()#

Opens the storage engine.

abstract async save()#

Saves the current state of the storage engine.

abstract async close()#

Closes the storage engine.

abstract async delete()#

Deletes the storage file.

abstract async update_peers(peers: list[tuple[int, int, str, str]]) None#

Update the peers table with the provided information.

Parameters:

peers (list[tuple[int, int, str, str]]) – A list of tuples containing the information of the peers to be updated. Each tuple must contain the following information: - int: The peer id. - int: The peer access hash. - str: The peer type (user, chat or channel). - str: The peer phone number (if any).

abstract async update_usernames(usernames: list[tuple[int, list[str]]]) None#

Update the usernames table with the provided information.

Parameters:

usernames (list[tuple[int, list[str]]]) – A list of tuples containing the information of the usernames to be updated. Each tuple must contain the following information: - int: The peer id. - list of str: The peer username (if any).

abstract async update_state(update_state: tuple[int, int, int, int, int] = <class 'object'>) tuple[int, int, int, int, int]#

Get or set the update state of the current session.

Parameters:

update_state (tuple[int, int, int, int, int]) – A tuple containing the update state to set. tuple must contain the following information: - int: The id of the entity. - int: The pts. - int: The qts. - int: The date. - int: The seq.

abstract async get_peer_by_id(peer_id: int) InputPeer#

Retrieve a peer by its ID.

Parameters:

peer_id (int) – The ID of the peer to retrieve.

abstract async get_peer_by_username(username: str) InputPeer#

Retrieve a peer by its username.

Parameters:

username (str) – The username of the peer to retrieve.

abstract async get_peer_by_phone_number(phone_number: str) InputPeer#

Retrieve a peer by its phone number.

Parameters:

phone_number (str) – The phone number of the peer to retrieve.

abstract async dc_id(value: int = <class 'object'>) int#

Get or set the DC ID of the current session.

Parameters:

value (int, optional) – The DC ID to set.

abstract async api_id(value: int = <class 'object'>) int#

Get or set the API ID of the current session.

Parameters:

value (int, optional) – The API ID to set.

abstract async test_mode(value: bool = <class 'object'>) bool#

Get or set the test mode of the current session.

Parameters:

value (bool, optional) – The test mode to set.

abstract async auth_key(value: bytes = <class 'object'>) bytes#

Get or set the authorization key of the current session.

Parameters:

value (bytes, optional) – The authorization key to set.

abstract async date(value: int = <class 'object'>) int#

Get or set the date of the current session.

Parameters:

value (int, optional) – The date to set.

abstract async user_id(value: int = <class 'object'>) int#

Get or set the user ID of the current session.

Parameters:

value (int, optional) – The user ID to set.

abstract async is_bot(value: bool = <class 'object'>) bool#

Get or set the bot flag of the current session.

Parameters:

value (bool, optional) – The bot flag to set.

async export_session_string() str#

Exports the session string for the current session.

Returns:

str – The session string for the current session.