Skip to content

Commit

Permalink
Docstrings for storage class
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Dec 4, 2023
1 parent 487117c commit fdf1c98
Showing 1 changed file with 83 additions and 1 deletion.
84 changes: 83 additions & 1 deletion pyrogram/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,133 @@ def __init__(self, name: str):
self.name = name

async def open(self):
"""Opens the storage engine."""
raise NotImplementedError

async def save(self):
"""Saves the current state of the storage engine."""
raise NotImplementedError

async def close(self):
"""Closes the storage engine."""
raise NotImplementedError

async def delete(self):
"""Deletes the storage."""
raise NotImplementedError

async def update_peers(self, peers: List[Tuple[int, int, str, str, str]]):
async def update_peers(self, peers: List[Tuple[int, int, str, List[str], str]]):
"""
Update the peers table with the provided information.
Parameters:
peers (``List[Tuple[int, int, str, List[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).
- List of ``str``: The peer username (if any).
- ``str``: The peer phone number (if any).
"""
raise NotImplementedError

async def get_peer_by_id(self, peer_id: int):
"""Retrieve a peer by its ID.
Parameters:
peer_id (``int``):
The ID of the peer to retrieve.
"""
raise NotImplementedError

async def get_peer_by_username(self, username: str):
"""Retrieve a peer by its username.
Parameters:
username (``str``):
The username of the peer to retrieve.
"""
raise NotImplementedError

async def get_peer_by_phone_number(self, phone_number: str):
"""Retrieve a peer by its phone number.
Parameters:
phone_number (``str``):
The phone number of the peer to retrieve.
"""
raise NotImplementedError

async def dc_id(self, value: int = object):
"""Get or set the DC ID of the current session.
Parameters:
value (``int``, *optional*):
The DC ID to set.
"""
raise NotImplementedError

async def api_id(self, value: int = object):
"""Get or set the API ID of the current session.
Parameters:
value (``int``, *optional*):
The API ID to set.
"""
raise NotImplementedError

async def test_mode(self, value: bool = object):
"""Get or set the test mode of the current session.
Parameters:
value (``bool``, *optional*):
The test mode to set.
"""
raise NotImplementedError

async def auth_key(self, value: bytes = object):
"""Get or set the authorization key of the current session.
Parameters:
value (``bytes``, *optional*):
The authorization key to set.
"""
raise NotImplementedError

async def date(self, value: int = object):
"""Get or set the date of the current session.
Parameters:
value (``int``, *optional*):
The date to set.
"""
raise NotImplementedError

async def user_id(self, value: int = object):
"""Get or set the user ID of the current session.
Parameters:
value (``int``, *optional*):
The user ID to set.
"""
raise NotImplementedError

async def is_bot(self, value: bool = object):
"""Get or set the bot flag of the current session.
Parameters:
value (``bool``, *optional*):
The bot flag to set.
"""
raise NotImplementedError

async def export_session_string(self):
"""Exports the session string for the current session.
Returns:
``str``: The session string for the current session.
"""
packed = struct.pack(
self.SESSION_STRING_FORMAT,
await self.dc_id(),
Expand Down

0 comments on commit fdf1c98

Please sign in to comment.