upd: type hints based on Pyrogram V1

This commit is contained in:
Dineshkarthik 2020-11-02 17:04:32 +01:00
parent 090dda733a
commit d7d1cdc905
No known key found for this signature in database
GPG key ID: E256EF0EECD6F201

View file

@ -46,13 +46,13 @@ def _is_exist(file_path: str) -> bool:
async def _get_media_meta( async def _get_media_meta(
media_obj: pyrogram.client.types.messages_and_media, _type: str media_obj: pyrogram.types.messages_and_media, _type: str
) -> Tuple[str, str, Optional[str]]: ) -> Tuple[str, str, Optional[str]]:
"""Extract file name and file id. """Extract file name and file id.
Parameters Parameters
---------- ----------
media_obj: pyrogram.client.types.messages_and_media media_obj: pyrogram.types.messages_and_media
Media object to be extracted. Media object to be extracted.
_type: string _type: string
Type of media object. Type of media object.
@ -86,8 +86,8 @@ async def _get_media_meta(
async def download_media( async def download_media(
client: pyrogram.client.client.Client, client: pyrogram.client.Client,
message: pyrogram.Message, message: pyrogram.types.Message,
media_types: List[str], media_types: List[str],
file_formats: dict, file_formats: dict,
): ):
@ -95,9 +95,9 @@ async def download_media(
Parameters Parameters
---------- ----------
client: pyrogram.client.client.Client client: pyrogram.client.Client
Client to interact with Telegram APIs. Client to interact with Telegram APIs.
message: pyrogram.Message message: pyrogram.types.Message
Message object retrived from telegram. Message object retrived from telegram.
media_types: list media_types: list
List of strings of media types to be downloaded. List of strings of media types to be downloaded.
@ -141,8 +141,8 @@ async def download_media(
async def process_messages( async def process_messages(
client: pyrogram.client.client.Client, client: pyrogram.client.Client,
messages: List[pyrogram.Message], messages: List[pyrogram.types.Message],
media_types: List[str], media_types: List[str],
file_formats: dict, file_formats: dict,
) -> int: ) -> int:
@ -150,7 +150,7 @@ async def process_messages(
Parameters Parameters
---------- ----------
client: pyrogram.client.client.Client client: pyrogram.client.Client
Client to interact with Telegram APIs. Client to interact with Telegram APIs.
messages: list messages: list
List of telegram messages. List of telegram messages.
@ -193,7 +193,9 @@ async def begin_import(config: dict, pagination_limit: int):
await client.start() await client.start()
last_read_message_id: int = config["last_read_message_id"] last_read_message_id: int = config["last_read_message_id"]
messages_iter = client.iter_history( messages_iter = client.iter_history(
config["chat_id"], offset_id=last_read_message_id, reverse=True, config["chat_id"],
offset_id=last_read_message_id,
reverse=True,
) )
pagination_count: int = 0 pagination_count: int = 0
messages_list: list = [] messages_list: list = []