From d340ddaca3d1ac2aa2f9e7e85e0d9a8b91dabdc5 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 08:33:34 +0100 Subject: [PATCH 01/20] v1 Follow-Up: df4d103 Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com> --- pyrogram/parser/markdown.py | 177 ++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 98 deletions(-) diff --git a/pyrogram/parser/markdown.py b/pyrogram/parser/markdown.py index 15c60c1b57..7c9dba5644 100644 --- a/pyrogram/parser/markdown.py +++ b/pyrogram/parser/markdown.py @@ -39,7 +39,7 @@ BLOCKQUOTE_DELIM = ">" BLOCKQUOTE_ESCAPE_DELIM = "|>" BLOCKQUOTE_EXPANDABLE_DELIM = "**>" -BLOCKQUOTE_EXPANDABLE_OPTIONAL_END_DELIM = "<**" +BLOCKQUOTE_EXPANDABLE_OPTIONAL_END_DELIM = "<**" # Kept for backwards compatibility if imported elsewhere MARKDOWN_RE = re.compile( r"({d})|(!?)\[(.+?)\]\((.+?)\)".format( @@ -81,98 +81,81 @@ def __init__(self, client: Optional["pyrogram.Client"]): @staticmethod def escape_and_create_quotes(text: str, strict: bool): text_lines: list[Union[str, None]] = text.splitlines() - - # Indexes of Already escaped lines html_escaped_list: list[int] = [] - # Temporary Queue to hold lines to be quoted - # Index and Line - to_quote_list: list[tuple[int, str]] = [] - - def create_blockquote(quote_type: str = "") -> None: - """ - Merges all lines in quote_queue into first line of queue - Encloses that line in html quote - Replaces rest of the lines with None placeholders to preserve indexes - """ - if len(to_quote_list) == 0: - return - - # Create quoted text block - joined_lines = "\n".join([text for _, text in to_quote_list]) - - first_line_index, _ = to_quote_list[0] - - # Enclose the block in html quote - # and add to starting index of quoted line - text_lines[first_line_index] = f"{joined_lines}" - - # Set None Placeholders for preserving indexes - for idx, line_to_remove in to_quote_list[1:]: - text_lines[idx] = None + i = 0 + while i < len(text_lines): + line = text_lines[i] - # clear queue - to_quote_list.clear() - - def process_text(start_delimiter, end_delimiter: str = "", quote_type: str = ""): - for index, line in enumerate(text_lines): - # Ignore None placeholders from previous runs - if line is None: - continue - - # Ignore Escaped > - if line.startswith(BLOCKQUOTE_ESCAPE_DELIM): - text_lines[index] = line[1:] - create_blockquote(quote_type=quote_type) - continue + if line is None: + i += 1 + continue - # Parse lines starting with delimiter - if line.startswith(start_delimiter): - endswith_delimiter = end_delimiter and line.endswith(end_delimiter) + # Ignore Escaped > + if line.startswith(BLOCKQUOTE_ESCAPE_DELIM): + text_lines[i] = html.escape(line[1:]) if strict else line[1:] + html_escaped_list.append(i) + i += 1 + continue - # Indexes to skip in line - start_index = len(start_delimiter) - end_index = end_index = len(line) - len(end_delimiter) if endswith_delimiter else len(line) + # Check if line starts a blockquote + is_bq = False + prefix_len = 0 + if line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): + is_bq = True + prefix_len = len(BLOCKQUOTE_EXPANDABLE_DELIM) + elif line.startswith(BLOCKQUOTE_DELIM): + is_bq = True + prefix_len = len(BLOCKQUOTE_DELIM) + + if is_bq: + start_index = i + bq_lines = [] + + # Collect all consecutive blockquote lines + while i < len(text_lines): + curr_line = text_lines[i] + curr_prefix_len = 0 + + if curr_line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): + curr_prefix_len = len(BLOCKQUOTE_EXPANDABLE_DELIM) + elif curr_line.startswith(BLOCKQUOTE_DELIM): + curr_prefix_len = len(BLOCKQUOTE_DELIM) + else: + break # No longer in a blockquote - # Strip delimiters - delimiter_stripped_line = line[start_index:end_index] + # Strip the delimiter + bq_lines.append(curr_line[curr_prefix_len:]) + i += 1 - # Escape if strict - parsed_line = html.escape(delimiter_stripped_line) if strict else delimiter_stripped_line - - # add to queue - to_quote_list.append((index, parsed_line)) + # Check if the blockquote ends with the expandability mark (||) + is_expandable = False + if bq_lines and bq_lines[-1].endswith(SPOILER_DELIM): + is_expandable = True + # Strip the || from the final line + bq_lines[-1] = bq_lines[-1][:-len(SPOILER_DELIM)] - # save line index - html_escaped_list.append(index) + # Escape if strict + if strict: + bq_lines = [html.escape(l) for l in bq_lines] - # if line doesn't end with delimiter continue loop - if not endswith_delimiter: - continue + # Create the merged blockquote entity + joined_lines = "\n".join(bq_lines) + quote_type = " expandable" if is_expandable else "" - # If line doesn't start with a delimiter - # or has ended with delimiter - # it means the block quote has ended - # create pending quotes if any - create_blockquote(quote_type=quote_type) + text_lines[start_index] = f"{joined_lines}" + html_escaped_list.append(start_index) + # Clear out the consumed lines + for j in range(start_index + 1, i): + text_lines[j] = None else: - # is triggered when there's only one line of text - # the line above won't be triggered - # because loop will exit after first iteration - # so try to create quote if any in queue - create_blockquote(quote_type=quote_type) - - process_text( - start_delimiter=BLOCKQUOTE_EXPANDABLE_DELIM, - end_delimiter=BLOCKQUOTE_EXPANDABLE_OPTIONAL_END_DELIM, - quote_type=" expandable", - ) - process_text(start_delimiter=BLOCKQUOTE_DELIM) + i += 1 + # Escape remaining text lines if strict if strict: for idx, line in enumerate(text_lines): - if idx not in html_escaped_list: + if line is not None and idx not in html_escaped_list: text_lines[idx] = html.escape(line) return "\n".join(filter(lambda x: x is not None, text_lines)) @@ -293,27 +276,16 @@ def unparse(text: str, entities: list): and blk_entity.offset < e <= blk_entity.offset + blk_entity.length for blk_entity in entities if blk_entity.type == MessageEntityType.BLOCKQUOTE + or blk_entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE ) - is_expandable = any( - blk_entity.offset <= s < blk_entity.offset + blk_entity.length - and blk_entity.offset < e <= blk_entity.offset + blk_entity.length - # and blk_entity.collapsed - for blk_entity in entities - if blk_entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE - ) + if inside_blockquote: - if is_expandable: - if entity.language: - open_delimiter = f"{delimiter}{entity.language}\n**>" - else: - open_delimiter = f"{delimiter}\n**>" - close_delimiter = f"\n**>{delimiter}" + # Inside any blockquote, inner lines use ">" + if entity.language: + open_delimiter = f"{delimiter}{entity.language}\n>" else: - if entity.language: - open_delimiter = f"{delimiter}{entity.language}\n>" - else: - open_delimiter = f"{delimiter}\n>" - close_delimiter = f"\n>{delimiter}" + open_delimiter = f"{delimiter}\n>" + close_delimiter = f"\n>{delimiter}" else: if entity.language: open_delimiter = f"{delimiter}{entity.language}\n" @@ -337,10 +309,19 @@ def unparse(text: str, entities: list): for line_num, line in enumerate(lines): line_start = s + sum(len(l) + 1 for l in lines[:line_num]) if entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE: - insert_at.append((line_start, i, BLOCKQUOTE_EXPANDABLE_DELIM)) + # Bot API Style: First line can be **, rest are > + if line_num == 0: + insert_at.append((line_start, i, BLOCKQUOTE_EXPANDABLE_DELIM)) + else: + insert_at.append((line_start, i, BLOCKQUOTE_DELIM)) else: insert_at.append((line_start, i, BLOCKQUOTE_DELIM)) - # No closing delimiter for blockquotes + + # Append expandability mark for expandable blockquotes + if entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE: + insert_at.append((e, -i, SPOILER_DELIM)) + + # No closing delimiter for blockquotes (handled by lines above) else: url = None is_emoji_or_date = False From dea6f7f5bf59bbf5c8d279e6e8588027967a3024 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 08:34:55 +0100 Subject: [PATCH 02/20] v2 Follow-Up: df4d103 Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com> --- pyrogram/parser/markdown.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pyrogram/parser/markdown.py b/pyrogram/parser/markdown.py index 7c9dba5644..01ad8a9f90 100644 --- a/pyrogram/parser/markdown.py +++ b/pyrogram/parser/markdown.py @@ -100,13 +100,13 @@ def escape_and_create_quotes(text: str, strict: bool): # Check if line starts a blockquote is_bq = False - prefix_len = 0 + started_as_expandable = False + if line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): is_bq = True - prefix_len = len(BLOCKQUOTE_EXPANDABLE_DELIM) + started_as_expandable = True elif line.startswith(BLOCKQUOTE_DELIM): is_bq = True - prefix_len = len(BLOCKQUOTE_DELIM) if is_bq: start_index = i @@ -115,8 +115,19 @@ def escape_and_create_quotes(text: str, strict: bool): # Collect all consecutive blockquote lines while i < len(text_lines): curr_line = text_lines[i] - curr_prefix_len = 0 + # Detect boundaries between consecutive blockquotes + if i > start_index: + # Boundary 1: `**>` explicitly starts a NEW expandable blockquote + if curr_line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): + break + + # Boundary 2: If the current block is expandable and the PREVIOUS + # line closed it with `||`, this line starts a NEW blockquote. + if started_as_expandable and bq_lines and bq_lines[-1].endswith(SPOILER_DELIM): + break + + curr_prefix_len = 0 if curr_line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): curr_prefix_len = len(BLOCKQUOTE_EXPANDABLE_DELIM) elif curr_line.startswith(BLOCKQUOTE_DELIM): @@ -128,9 +139,10 @@ def escape_and_create_quotes(text: str, strict: bool): bq_lines.append(curr_line[curr_prefix_len:]) i += 1 - # Check if the blockquote ends with the expandability mark (||) + # Check if it properly closes as an expandable blockquote is_expandable = False - if bq_lines and bq_lines[-1].endswith(SPOILER_DELIM): + # Strict Bot API requirement: Must have started with **> AND end with || + if started_as_expandable and bq_lines and bq_lines[-1].endswith(SPOILER_DELIM): is_expandable = True # Strip the || from the final line bq_lines[-1] = bq_lines[-1][:-len(SPOILER_DELIM)] From 63667b8b63e188f1d920ee97cfc375d32fb8bfaf Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 08:38:27 +0100 Subject: [PATCH 03/20] docs Closes #229 --- docs/source/topics/text-formatting.rst | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/source/topics/text-formatting.rst b/docs/source/topics/text-formatting.rst index 80948aebc0..7b472385d2 100644 --- a/docs/source/topics/text-formatting.rst +++ b/docs/source/topics/text-formatting.rst @@ -160,13 +160,12 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.ParseMode.MARKDOWN` to the >Block quotation continued >The last line of the block quotation - **> - The expandable block quotation started right after the previous block quotation - It is separated from the previous block quotation by expandable syntax - Expandable block quotation continued - Hidden by default part of the expandable block quotation started - Expandable block quotation continued - The last line of the expandable block quotation with the expandability mark<** + **>The expandable block quotation started right after the previous block quotation + >It is separated from the previous block quotation by expandable syntax + >Expandable block quotation continued + >Hidden by default part of the expandable block quotation started + >Expandable block quotation continued + >The last line of the expandable block quotation with the expandability mark|| `inline fixed-width code` @@ -215,13 +214,12 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.ParseMode.MARKDOWN` to the ">Block quotation continued\n" ">The last line of the block quotation" - "**>\n" - "The expandable block quotation started right after the previous block quotation\n" - "It is separated from the previous block quotation by expandable syntax\n" - "Expandable block quotation continued\n" - "Hidden by default part of the expandable block quotation started\n" - "Expandable block quotation continued\n" - "The last line of the expandable block quotation with the expandability mark<**" + "**>The expandable block quotation started right after the previous block quotation\n" + ">It is separated from the previous block quotation by expandable syntax\n" + ">Expandable block quotation continued\n" + ">Hidden by default part of the expandable block quotation started\n" + ">Expandable block quotation continued\n" + ">The last line of the expandable block quotation with the expandability mark||" ), parse_mode=ParseMode.MARKDOWN From 5f4b41bf1f089d6c5440a46a08e1e294d93033df Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 08:53:28 +0100 Subject: [PATCH 04/20] docs --- pyrogram/methods/advanced/invoke.py | 1 + pyrogram/methods/advanced/resolve_peer.py | 1 + pyrogram/methods/advanced/save_file.py | 1 + pyrogram/methods/auth/accept_terms_of_service.py | 4 ++++ pyrogram/methods/auth/check_password.py | 2 ++ pyrogram/methods/auth/connect.py | 1 + pyrogram/methods/auth/disconnect.py | 4 ++-- pyrogram/methods/auth/get_active_sessions.py | 3 +++ pyrogram/methods/auth/get_password_hint.py | 4 ++++ pyrogram/methods/auth/initialize.py | 4 ++-- pyrogram/methods/auth/log_out.py | 3 +++ pyrogram/methods/auth/recover_password.py | 2 ++ pyrogram/methods/auth/resend_code.py | 2 ++ pyrogram/methods/auth/send_code.py | 2 ++ pyrogram/methods/auth/sign_in.py | 2 ++ pyrogram/methods/auth/sign_in_bot.py | 2 ++ pyrogram/methods/auth/sign_up.py | 2 ++ pyrogram/methods/auth/terminate.py | 1 + pyrogram/methods/bots/answer_callback_query.py | 3 +++ pyrogram/methods/bots/answer_inline_query.py | 3 +++ pyrogram/methods/bots/answer_web_app_query.py | 4 ++++ pyrogram/methods/bots/delete_bot_commands.py | 3 +++ pyrogram/methods/bots/get_bot_commands.py | 3 +++ pyrogram/methods/bots/get_bot_default_privileges.py | 3 +++ pyrogram/methods/bots/get_bot_info_description.py | 3 +++ pyrogram/methods/bots/get_bot_info_short_description.py | 3 +++ pyrogram/methods/bots/get_bot_name.py | 3 +++ pyrogram/methods/bots/get_chat_menu_button.py | 4 ++++ pyrogram/methods/bots/get_game_high_scores.py | 3 +++ pyrogram/methods/bots/get_inline_bot_results.py | 1 + pyrogram/methods/bots/get_owned_bots.py | 3 +++ pyrogram/methods/bots/get_similar_bots.py | 3 +++ pyrogram/methods/bots/send_game.py | 3 +++ pyrogram/methods/bots/send_web_app_custom_request.py | 4 ++++ pyrogram/methods/bots/set_bot_commands.py | 3 +++ pyrogram/methods/bots/set_bot_default_privileges.py | 4 ++++ pyrogram/methods/bots/set_bot_info_description.py | 3 +++ pyrogram/methods/bots/set_bot_info_short_description.py | 3 +++ pyrogram/methods/bots/set_bot_name.py | 3 +++ pyrogram/methods/bots/set_chat_menu_button.py | 4 ++++ pyrogram/methods/bots/set_game_score.py | 3 +++ 41 files changed, 109 insertions(+), 4 deletions(-) diff --git a/pyrogram/methods/advanced/invoke.py b/pyrogram/methods/advanced/invoke.py index 0d35bdb752..f477ecee80 100644 --- a/pyrogram/methods/advanced/invoke.py +++ b/pyrogram/methods/advanced/invoke.py @@ -69,6 +69,7 @@ async def invoke( Raises: RPCError: In case of a Telegram RPC error. + """ if not self.is_connected: raise ConnectionError("Client has not been started yet") diff --git a/pyrogram/methods/advanced/resolve_peer.py b/pyrogram/methods/advanced/resolve_peer.py index 6cb5da6697..c1a04f6738 100644 --- a/pyrogram/methods/advanced/resolve_peer.py +++ b/pyrogram/methods/advanced/resolve_peer.py @@ -53,6 +53,7 @@ async def resolve_peer( Raises: KeyError: In case the peer doesn't exist in the internal database. + """ if not self.is_connected: raise ConnectionError("Client has not been started yet") diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py index f2bd4196f5..095a09eb2f 100644 --- a/pyrogram/methods/advanced/save_file.py +++ b/pyrogram/methods/advanced/save_file.py @@ -91,6 +91,7 @@ async def save_file( Raises: RPCError: In case of a Telegram RPC error. + """ if path is None: return None diff --git a/pyrogram/methods/auth/accept_terms_of_service.py b/pyrogram/methods/auth/accept_terms_of_service.py index cc1fcf5453..7b411b6a7c 100644 --- a/pyrogram/methods/auth/accept_terms_of_service.py +++ b/pyrogram/methods/auth/accept_terms_of_service.py @@ -32,6 +32,10 @@ async def accept_terms_of_service( Parameters: terms_of_service_id (``str``): The terms of service identifier. + + Raises: + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( raw.functions.help.AcceptTermsOfService( diff --git a/pyrogram/methods/auth/check_password.py b/pyrogram/methods/auth/check_password.py index 39aa82fcc0..67b73086af 100644 --- a/pyrogram/methods/auth/check_password.py +++ b/pyrogram/methods/auth/check_password.py @@ -44,6 +44,8 @@ async def check_password( Raises: BadRequest: In case the password is invalid. + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( raw.functions.auth.CheckPassword( diff --git a/pyrogram/methods/auth/connect.py b/pyrogram/methods/auth/connect.py index 612e064bb4..ae7d94f530 100644 --- a/pyrogram/methods/auth/connect.py +++ b/pyrogram/methods/auth/connect.py @@ -33,6 +33,7 @@ async def connect( Raises: ConnectionError: In case you try to connect an already connected client. + """ if self.is_connected: raise ConnectionError("Client is already connected") diff --git a/pyrogram/methods/auth/disconnect.py b/pyrogram/methods/auth/disconnect.py index daa07b8353..ee8893b832 100644 --- a/pyrogram/methods/auth/disconnect.py +++ b/pyrogram/methods/auth/disconnect.py @@ -26,8 +26,8 @@ async def disconnect( """Disconnect the client from Telegram servers. Raises: - ConnectionError: In case you try to disconnect an already disconnected client or in case you try to - disconnect a client that needs to be terminated first. + ConnectionError: In case you try to disconnect an already disconnected client or in case you try to disconnect a client that needs to be terminated first. + """ if not self.is_connected: raise ConnectionError("Client is already disconnected") diff --git a/pyrogram/methods/auth/get_active_sessions.py b/pyrogram/methods/auth/get_active_sessions.py index f09f50e7d5..8d3b9c8e6f 100644 --- a/pyrogram/methods/auth/get_active_sessions.py +++ b/pyrogram/methods/auth/get_active_sessions.py @@ -31,6 +31,9 @@ async def get_active_sessions( Returns: :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned. + Raises: + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( raw.functions.account.GetAuthorizations() diff --git a/pyrogram/methods/auth/get_password_hint.py b/pyrogram/methods/auth/get_password_hint.py index a57f7c8075..e585ce376b 100644 --- a/pyrogram/methods/auth/get_password_hint.py +++ b/pyrogram/methods/auth/get_password_hint.py @@ -34,5 +34,9 @@ async def get_password_hint( Returns: ``str``: On success, the password hint as string is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ return (await self.invoke(raw.functions.account.GetPassword())).hint diff --git a/pyrogram/methods/auth/initialize.py b/pyrogram/methods/auth/initialize.py index 7188b66817..ee7d49e04b 100644 --- a/pyrogram/methods/auth/initialize.py +++ b/pyrogram/methods/auth/initialize.py @@ -34,8 +34,8 @@ async def initialize( It will also load plugins and start the internal dispatcher. Raises: - ConnectionError: In case you try to initialize a disconnected client or in case you try to initialize an - already initialized client. + ConnectionError: In case you try to initialize a disconnected client or in case you try to initialize an already initialized client. + """ if not self.is_connected: raise ConnectionError("Can't initialize a disconnected client") diff --git a/pyrogram/methods/auth/log_out.py b/pyrogram/methods/auth/log_out.py index 84b7db64cd..b7aabdcf59 100644 --- a/pyrogram/methods/auth/log_out.py +++ b/pyrogram/methods/auth/log_out.py @@ -38,6 +38,9 @@ async def log_out( Returns: ``bool``: On success, True is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/auth/recover_password.py b/pyrogram/methods/auth/recover_password.py index 0a34750752..c0e571a5f1 100644 --- a/pyrogram/methods/auth/recover_password.py +++ b/pyrogram/methods/auth/recover_password.py @@ -44,6 +44,8 @@ async def recover_password( Raises: BadRequest: In case the recovery code is invalid. + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( raw.functions.auth.RecoverPassword( diff --git a/pyrogram/methods/auth/resend_code.py b/pyrogram/methods/auth/resend_code.py index 9644ac4f54..93d219cde9 100644 --- a/pyrogram/methods/auth/resend_code.py +++ b/pyrogram/methods/auth/resend_code.py @@ -51,6 +51,8 @@ async def resend_code( Raises: BadRequest: In case the arguments are invalid. + RPCError: In case of a Telegram RPC error. + """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/send_code.py b/pyrogram/methods/auth/send_code.py index 92ffc99996..fc1a471be1 100644 --- a/pyrogram/methods/auth/send_code.py +++ b/pyrogram/methods/auth/send_code.py @@ -46,6 +46,8 @@ async def send_code( Raises: BadRequest: In case the phone number is invalid. + RPCError: In case of a Telegram RPC error. + """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in.py b/pyrogram/methods/auth/sign_in.py index 9d77f1cd37..3710041138 100644 --- a/pyrogram/methods/auth/sign_in.py +++ b/pyrogram/methods/auth/sign_in.py @@ -57,6 +57,8 @@ async def sign_in( Raises: BadRequest: In case the arguments are invalid. SessionPasswordNeeded: In case a password is needed to sign in. + RPCError: In case of a Telegram RPC error. + """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in_bot.py b/pyrogram/methods/auth/sign_in_bot.py index 09a2f28379..a9bc5486b5 100644 --- a/pyrogram/methods/auth/sign_in_bot.py +++ b/pyrogram/methods/auth/sign_in_bot.py @@ -45,6 +45,8 @@ async def sign_in_bot( Raises: BadRequest: In case the bot token is invalid. + RPCError: In case of a Telegram RPC error. + """ while True: try: diff --git a/pyrogram/methods/auth/sign_up.py b/pyrogram/methods/auth/sign_up.py index eee64fdd3f..87283c04b6 100644 --- a/pyrogram/methods/auth/sign_up.py +++ b/pyrogram/methods/auth/sign_up.py @@ -55,6 +55,8 @@ async def sign_up( Raises: BadRequest: In case the arguments are invalid. + RPCError: In case of a Telegram RPC error. + """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/terminate.py b/pyrogram/methods/auth/terminate.py index d5fd949cba..ec5b891944 100644 --- a/pyrogram/methods/auth/terminate.py +++ b/pyrogram/methods/auth/terminate.py @@ -35,6 +35,7 @@ async def terminate( Raises: ConnectionError: In case you try to terminate a client that is already terminated. + """ if not self.is_initialized: raise ConnectionError("Client is already terminated") diff --git a/pyrogram/methods/bots/answer_callback_query.py b/pyrogram/methods/bots/answer_callback_query.py index a6d8747cd5..eb5ef803c4 100644 --- a/pyrogram/methods/bots/answer_callback_query.py +++ b/pyrogram/methods/bots/answer_callback_query.py @@ -58,6 +58,9 @@ async def answer_callback_query( Returns: ``bool``: True, on success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_inline_query.py b/pyrogram/methods/bots/answer_inline_query.py index c3a450a015..9bca881ded 100644 --- a/pyrogram/methods/bots/answer_inline_query.py +++ b/pyrogram/methods/bots/answer_inline_query.py @@ -83,6 +83,9 @@ async def answer_inline_query( Returns: ``bool``: True, on success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_web_app_query.py b/pyrogram/methods/bots/answer_web_app_query.py index 74f56079bb..04b5a6299f 100644 --- a/pyrogram/methods/bots/answer_web_app_query.py +++ b/pyrogram/methods/bots/answer_web_app_query.py @@ -41,6 +41,10 @@ async def answer_web_app_query( Returns: :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( diff --git a/pyrogram/methods/bots/delete_bot_commands.py b/pyrogram/methods/bots/delete_bot_commands.py index e8173d32d9..de9058c532 100644 --- a/pyrogram/methods/bots/delete_bot_commands.py +++ b/pyrogram/methods/bots/delete_bot_commands.py @@ -47,6 +47,9 @@ async def delete_bot_commands( Returns: ``bool``: On success, True is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_commands.py b/pyrogram/methods/bots/get_bot_commands.py index ed0c2848ae..b1f42df7d4 100644 --- a/pyrogram/methods/bots/get_bot_commands.py +++ b/pyrogram/methods/bots/get_bot_commands.py @@ -47,6 +47,9 @@ async def get_bot_commands( Returns: List of :obj:`~pyrogram.types.BotCommand`: On success, the list of bot commands is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_default_privileges.py b/pyrogram/methods/bots/get_bot_default_privileges.py index 217d9b4384..ed63d9101e 100644 --- a/pyrogram/methods/bots/get_bot_default_privileges.py +++ b/pyrogram/methods/bots/get_bot_default_privileges.py @@ -40,6 +40,9 @@ async def get_bot_default_privileges( Returns: ``bool``: On success, True is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_description.py b/pyrogram/methods/bots/get_bot_info_description.py index 739e6d60dc..e9cac1694a 100644 --- a/pyrogram/methods/bots/get_bot_info_description.py +++ b/pyrogram/methods/bots/get_bot_info_description.py @@ -47,6 +47,9 @@ async def get_bot_info_description( Returns: ``str``: On success, returns the text shown in the chat with a bot if the chat is empty in the given language. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_short_description.py b/pyrogram/methods/bots/get_bot_info_short_description.py index c78eb186c5..783b11b290 100644 --- a/pyrogram/methods/bots/get_bot_info_short_description.py +++ b/pyrogram/methods/bots/get_bot_info_short_description.py @@ -47,6 +47,9 @@ async def get_bot_info_short_description( Returns: ``str``: On success, returns the text shown on a bot's profile page and sent together with the link when users share the bot in the given language. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_name.py b/pyrogram/methods/bots/get_bot_name.py index e2775b89fc..4ec42b3de5 100644 --- a/pyrogram/methods/bots/get_bot_name.py +++ b/pyrogram/methods/bots/get_bot_name.py @@ -44,6 +44,9 @@ async def get_bot_name( Unique identifier (int) or username (str) of the bot for which profile photo has to be updated instead of the current user. The bot should have ``can_be_edited`` property set to True. + Raises: + RPCError: In case of a Telegram RPC error. + Returns: ``str``: On success, returns the name of a bot in the given language. diff --git a/pyrogram/methods/bots/get_chat_menu_button.py b/pyrogram/methods/bots/get_chat_menu_button.py index 9d143d5819..4c3449325b 100644 --- a/pyrogram/methods/bots/get_chat_menu_button.py +++ b/pyrogram/methods/bots/get_chat_menu_button.py @@ -36,6 +36,10 @@ async def get_chat_menu_button( chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. If not specified, default bot's menu button will be returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ if chat_id: diff --git a/pyrogram/methods/bots/get_game_high_scores.py b/pyrogram/methods/bots/get_game_high_scores.py index 17445edd09..b47b8a27ae 100644 --- a/pyrogram/methods/bots/get_game_high_scores.py +++ b/pyrogram/methods/bots/get_game_high_scores.py @@ -53,6 +53,9 @@ async def get_game_high_scores( Returns: List of :obj:`~pyrogram.types.GameHighScore`: On success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_inline_bot_results.py b/pyrogram/methods/bots/get_inline_bot_results.py index bbde018e2d..564744b185 100644 --- a/pyrogram/methods/bots/get_inline_bot_results.py +++ b/pyrogram/methods/bots/get_inline_bot_results.py @@ -69,6 +69,7 @@ async def get_inline_bot_results( Raises: TimeoutError: In case the bot fails to answer within 10 seconds. + RPCError: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_owned_bots.py b/pyrogram/methods/bots/get_owned_bots.py index 884ec248cb..1025049ab0 100644 --- a/pyrogram/methods/bots/get_owned_bots.py +++ b/pyrogram/methods/bots/get_owned_bots.py @@ -31,6 +31,9 @@ async def get_owned_bots( Returns: List of :obj:`~pyrogram.types.User`: On success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_similar_bots.py b/pyrogram/methods/bots/get_similar_bots.py index 461fb5c4a2..2a05aa9e5f 100644 --- a/pyrogram/methods/bots/get_similar_bots.py +++ b/pyrogram/methods/bots/get_similar_bots.py @@ -38,6 +38,9 @@ async def get_similar_bots( Returns: List of :obj:`~pyrogram.types.User`: On success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_game.py b/pyrogram/methods/bots/send_game.py index f659bb0cd3..b42ff32ea4 100644 --- a/pyrogram/methods/bots/send_game.py +++ b/pyrogram/methods/bots/send_game.py @@ -99,6 +99,9 @@ async def send_game( Returns: :obj:`~pyrogram.types.Message`: On success, the sent game message is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_web_app_custom_request.py b/pyrogram/methods/bots/send_web_app_custom_request.py index 8bf1a950b5..99f7d4f181 100644 --- a/pyrogram/methods/bots/send_web_app_custom_request.py +++ b/pyrogram/methods/bots/send_web_app_custom_request.py @@ -46,6 +46,10 @@ async def send_web_app_custom_request( Returns: ``str``: On success, a JSON-serialized result is returned. + + Raises: + RPCError: In case of a Telegram RPC error. + """ r = await self.invoke( diff --git a/pyrogram/methods/bots/set_bot_commands.py b/pyrogram/methods/bots/set_bot_commands.py index 29cacf1c86..6bd68dd237 100644 --- a/pyrogram/methods/bots/set_bot_commands.py +++ b/pyrogram/methods/bots/set_bot_commands.py @@ -51,6 +51,9 @@ async def set_bot_commands( Returns: ``bool``: On success, True is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_default_privileges.py b/pyrogram/methods/bots/set_bot_default_privileges.py index 2890ee1ae1..ddaef2cd93 100644 --- a/pyrogram/methods/bots/set_bot_default_privileges.py +++ b/pyrogram/methods/bots/set_bot_default_privileges.py @@ -45,6 +45,9 @@ async def set_bot_default_privileges( Returns: ``bool``: On success, True is returned. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python @@ -77,5 +80,6 @@ async def set_bot_default_privileges( manage_call=privileges.can_manage_video_chats, other=privileges.can_manage_chat ) if privileges else raw.types.ChatAdminRights() + # TODO return await self.invoke(function(admin_rights=admin_rights)) diff --git a/pyrogram/methods/bots/set_bot_info_description.py b/pyrogram/methods/bots/set_bot_info_description.py index 6be130aca4..ddcddbc150 100644 --- a/pyrogram/methods/bots/set_bot_info_description.py +++ b/pyrogram/methods/bots/set_bot_info_description.py @@ -51,6 +51,9 @@ async def set_bot_info_description( Returns: ``bool``: True on success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_info_short_description.py b/pyrogram/methods/bots/set_bot_info_short_description.py index 5a3903d55a..6412bc2954 100644 --- a/pyrogram/methods/bots/set_bot_info_short_description.py +++ b/pyrogram/methods/bots/set_bot_info_short_description.py @@ -51,6 +51,9 @@ async def set_bot_info_short_description( Returns: ``bool``: True on success. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_name.py b/pyrogram/methods/bots/set_bot_name.py index 34fd2fffeb..657d227c05 100644 --- a/pyrogram/methods/bots/set_bot_name.py +++ b/pyrogram/methods/bots/set_bot_name.py @@ -48,6 +48,9 @@ async def set_bot_name( Unique identifier (int) or username (str) of the bot for which profile photo has to be updated instead of the current user. The bot should have ``can_be_edited`` property set to True. + Raises: + RPCError: In case of a Telegram RPC error. + Returns: ``bool``: True on success. diff --git a/pyrogram/methods/bots/set_chat_menu_button.py b/pyrogram/methods/bots/set_chat_menu_button.py index fa5af85ceb..6419d7ef4d 100644 --- a/pyrogram/methods/bots/set_chat_menu_button.py +++ b/pyrogram/methods/bots/set_chat_menu_button.py @@ -41,6 +41,10 @@ async def set_chat_menu_button( menu_button (:obj:`~pyrogram.types.MenuButton`, *optional*): The new bot's menu button. Defaults to :obj:`~pyrogram.types.MenuButtonDefault`. + + Raises: + RPCError: In case of a Telegram RPC error. + """ await self.invoke( diff --git a/pyrogram/methods/bots/set_game_score.py b/pyrogram/methods/bots/set_game_score.py index 020e17293d..24c0982e35 100644 --- a/pyrogram/methods/bots/set_game_score.py +++ b/pyrogram/methods/bots/set_game_score.py @@ -68,6 +68,9 @@ async def set_game_score( :obj:`~pyrogram.types.Message` | ``bool``: On success, if the message was sent by the bot, the edited message is returned, True otherwise. + Raises: + RPCError: In case of a Telegram RPC error. + Example: .. code-block:: python From d507717f2020820b4207d0c276467ae7db355215 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 09:12:54 +0100 Subject: [PATCH 05/20] docs --- docs/source/api/errors/index.rst | 6 +++--- docs/source/start/errors.rst | 6 ++++-- pyrogram/methods/advanced/invoke.py | 2 +- pyrogram/methods/advanced/save_file.py | 2 +- pyrogram/methods/auth/accept_terms_of_service.py | 2 +- pyrogram/methods/auth/check_password.py | 2 +- pyrogram/methods/auth/get_active_sessions.py | 2 +- pyrogram/methods/auth/get_password_hint.py | 2 +- pyrogram/methods/auth/log_out.py | 2 +- pyrogram/methods/auth/recover_password.py | 2 +- pyrogram/methods/auth/resend_code.py | 2 +- pyrogram/methods/auth/send_code.py | 2 +- pyrogram/methods/auth/sign_in.py | 2 +- pyrogram/methods/auth/sign_in_bot.py | 2 +- pyrogram/methods/auth/sign_up.py | 2 +- pyrogram/methods/auth/terminate_all_other_sessions.py | 2 +- pyrogram/methods/auth/terminate_session.py | 2 +- pyrogram/methods/bots/answer_callback_query.py | 2 +- pyrogram/methods/bots/answer_inline_query.py | 2 +- pyrogram/methods/bots/answer_web_app_query.py | 2 +- pyrogram/methods/bots/delete_bot_commands.py | 2 +- pyrogram/methods/bots/get_bot_commands.py | 2 +- pyrogram/methods/bots/get_bot_default_privileges.py | 2 +- pyrogram/methods/bots/get_bot_info_description.py | 2 +- pyrogram/methods/bots/get_bot_info_short_description.py | 2 +- pyrogram/methods/bots/get_bot_name.py | 2 +- pyrogram/methods/bots/get_chat_menu_button.py | 2 +- pyrogram/methods/bots/get_game_high_scores.py | 2 +- pyrogram/methods/bots/get_inline_bot_results.py | 2 +- pyrogram/methods/bots/get_owned_bots.py | 2 +- pyrogram/methods/bots/get_similar_bots.py | 2 +- pyrogram/methods/bots/request_callback_answer.py | 2 +- pyrogram/methods/bots/send_game.py | 2 +- pyrogram/methods/bots/send_inline_bot_result.py | 2 +- pyrogram/methods/bots/send_web_app_custom_request.py | 2 +- pyrogram/methods/bots/set_bot_commands.py | 2 +- pyrogram/methods/bots/set_bot_default_privileges.py | 2 +- pyrogram/methods/bots/set_bot_info_description.py | 2 +- pyrogram/methods/bots/set_bot_info_short_description.py | 2 +- pyrogram/methods/bots/set_bot_name.py | 2 +- pyrogram/methods/bots/set_chat_menu_button.py | 2 +- pyrogram/methods/bots/set_game_score.py | 2 +- .../methods/chat_topics/toggle_forum_topic_is_pinned.py | 2 +- pyrogram/methods/chats/add_profile_audio.py | 2 +- pyrogram/methods/chats/set_chat_direct_messages_group.py | 2 +- pyrogram/methods/chats/set_chat_protected_content.py | 4 ++-- pyrogram/methods/chats/transfer_chat_ownership.py | 2 +- pyrogram/methods/messages/copy_message.py | 2 +- pyrogram/methods/messages/download_media.py | 2 +- pyrogram/methods/messages/forward_messages.py | 3 +++ pyrogram/methods/stories/edit_story.py | 4 ++-- pyrogram/methods/stories/hide_my_story_view.py | 2 +- pyrogram/methods/stories/post_story.py | 2 +- 53 files changed, 62 insertions(+), 57 deletions(-) diff --git a/docs/source/api/errors/index.rst b/docs/source/api/errors/index.rst index c3557b77e2..d197b41c2f 100644 --- a/docs/source/api/errors/index.rst +++ b/docs/source/api/errors/index.rst @@ -39,14 +39,14 @@ follow the usual *PascalCase* convention. .. admonition :: RPC Errors :class: tip - There isn't any official list of all possible RPC errors, so the list of known errors is provided on a best-effort basis. When new methods are available, the list may be lacking since we simply don't know what errors can raise from them. Pyrogram creates an `unknown_errors.txt` file in the root directory from where the `Client` is run. + There isn't any official list of all possible RPC errors, so the list of known errors is provided on a best-effort basis. When new methods are available, the list may be lacking since we simply don't know what errors can raise from them. Pyrogram creates an ``unknown_errors.txt`` file in the root directory from where the `Client` is run. .. admonition :: PLEASE DO NOT DO THIS .. tip:: - If you do not want this file to be created, set the `PYROGRAM_DONOT_LOG_UNKNOWN_ERRORS` environment variable before running the Pyrogram `Client`. + If you want the file to be created in a different location, set the ``PYROGRAM_LOG_UNKNOWN_ERRORS_FILENAME`` environment variable to an absolute file path of your choice. .. tip:: - If you want the file to be created in a different location, set the `PYROGRAM_LOG_UNKNOWN_ERRORS_FILENAME` to a file path of your choice. + If you do not want this file to be created, set the ``PYROGRAM_DONOT_LOG_UNKNOWN_ERRORS`` environment variable before running the Pyrogram `Client`. diff --git a/docs/source/start/errors.rst b/docs/source/start/errors.rst index f6346fd1b8..c03860e214 100644 --- a/docs/source/start/errors.rst +++ b/docs/source/start/errors.rst @@ -1,3 +1,5 @@ +.. _handling_errors: + Error Handling ============== @@ -80,11 +82,11 @@ whole category of errors and be sure to also handle these unknown errors. .. admonition :: RPC Errors :class: tip - There isn't any official list of all possible RPC errors, so the list of known errors is provided on a best-effort basis. When new methods are available, the list may be lacking since we simply don't know what errors can raise from them. Pyrogram creates an `unknown_errors.txt` file in the root directory from where the `Client` is run. + There isn't any official list of all possible RPC errors, so the list of known errors is provided on a best-effort basis. When new methods are available, the list may be lacking since we simply don't know what errors can raise from them. Pyrogram creates an ``unknown_errors.txt`` file in the root directory from where the `Client` is run. .. admonition :: `... `__ - If you want the file to be created in a different location, set the ``PYROGRAM_LOG_UNKNOWN_ERRORS_FILENAME`` to an absolute file path of your choice. + If you want the file to be created in a different location, set the ``PYROGRAM_LOG_UNKNOWN_ERRORS_FILENAME`` environment variable to an absolute file path of your choice. Errors with Values diff --git a/pyrogram/methods/advanced/invoke.py b/pyrogram/methods/advanced/invoke.py index f477ecee80..ce6ede726a 100644 --- a/pyrogram/methods/advanced/invoke.py +++ b/pyrogram/methods/advanced/invoke.py @@ -68,7 +68,7 @@ async def invoke( ``RawType``: The raw type response generated by the query. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ if not self.is_connected: diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py index 095a09eb2f..5e76ca4018 100644 --- a/pyrogram/methods/advanced/save_file.py +++ b/pyrogram/methods/advanced/save_file.py @@ -90,7 +90,7 @@ async def save_file( ``InputFile``: On success, the uploaded file is returned in form of an InputFile object. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ if path is None: diff --git a/pyrogram/methods/auth/accept_terms_of_service.py b/pyrogram/methods/auth/accept_terms_of_service.py index 7b411b6a7c..e2c0e1f1e8 100644 --- a/pyrogram/methods/auth/accept_terms_of_service.py +++ b/pyrogram/methods/auth/accept_terms_of_service.py @@ -34,7 +34,7 @@ async def accept_terms_of_service( The terms of service identifier. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/check_password.py b/pyrogram/methods/auth/check_password.py index 67b73086af..eb3038f5ab 100644 --- a/pyrogram/methods/auth/check_password.py +++ b/pyrogram/methods/auth/check_password.py @@ -44,7 +44,7 @@ async def check_password( Raises: BadRequest: In case the password is invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/get_active_sessions.py b/pyrogram/methods/auth/get_active_sessions.py index 8d3b9c8e6f..41f4035dd2 100644 --- a/pyrogram/methods/auth/get_active_sessions.py +++ b/pyrogram/methods/auth/get_active_sessions.py @@ -32,7 +32,7 @@ async def get_active_sessions( :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/get_password_hint.py b/pyrogram/methods/auth/get_password_hint.py index e585ce376b..2f321cebbd 100644 --- a/pyrogram/methods/auth/get_password_hint.py +++ b/pyrogram/methods/auth/get_password_hint.py @@ -36,7 +36,7 @@ async def get_password_hint( ``str``: On success, the password hint as string is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ return (await self.invoke(raw.functions.account.GetPassword())).hint diff --git a/pyrogram/methods/auth/log_out.py b/pyrogram/methods/auth/log_out.py index b7aabdcf59..4e112da767 100644 --- a/pyrogram/methods/auth/log_out.py +++ b/pyrogram/methods/auth/log_out.py @@ -39,7 +39,7 @@ async def log_out( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/auth/recover_password.py b/pyrogram/methods/auth/recover_password.py index c0e571a5f1..46fbf39ac3 100644 --- a/pyrogram/methods/auth/recover_password.py +++ b/pyrogram/methods/auth/recover_password.py @@ -44,7 +44,7 @@ async def recover_password( Raises: BadRequest: In case the recovery code is invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/resend_code.py b/pyrogram/methods/auth/resend_code.py index 93d219cde9..d3b72a590e 100644 --- a/pyrogram/methods/auth/resend_code.py +++ b/pyrogram/methods/auth/resend_code.py @@ -51,7 +51,7 @@ async def resend_code( Raises: BadRequest: In case the arguments are invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/send_code.py b/pyrogram/methods/auth/send_code.py index fc1a471be1..9cb3e3ec14 100644 --- a/pyrogram/methods/auth/send_code.py +++ b/pyrogram/methods/auth/send_code.py @@ -46,7 +46,7 @@ async def send_code( Raises: BadRequest: In case the phone number is invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in.py b/pyrogram/methods/auth/sign_in.py index 3710041138..c1f7c0c694 100644 --- a/pyrogram/methods/auth/sign_in.py +++ b/pyrogram/methods/auth/sign_in.py @@ -57,7 +57,7 @@ async def sign_in( Raises: BadRequest: In case the arguments are invalid. SessionPasswordNeeded: In case a password is needed to sign in. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in_bot.py b/pyrogram/methods/auth/sign_in_bot.py index a9bc5486b5..50c3f43df6 100644 --- a/pyrogram/methods/auth/sign_in_bot.py +++ b/pyrogram/methods/auth/sign_in_bot.py @@ -45,7 +45,7 @@ async def sign_in_bot( Raises: BadRequest: In case the bot token is invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ while True: diff --git a/pyrogram/methods/auth/sign_up.py b/pyrogram/methods/auth/sign_up.py index 87283c04b6..fce4ecad0e 100644 --- a/pyrogram/methods/auth/sign_up.py +++ b/pyrogram/methods/auth/sign_up.py @@ -55,7 +55,7 @@ async def sign_up( Raises: BadRequest: In case the arguments are invalid. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/terminate_all_other_sessions.py b/pyrogram/methods/auth/terminate_all_other_sessions.py index 027ea3cc3b..ae54f47b6d 100644 --- a/pyrogram/methods/auth/terminate_all_other_sessions.py +++ b/pyrogram/methods/auth/terminate_all_other_sessions.py @@ -32,7 +32,7 @@ async def terminate_all_other_sessions( ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ return await self.invoke( diff --git a/pyrogram/methods/auth/terminate_session.py b/pyrogram/methods/auth/terminate_session.py index 90ddaf7a70..c01de78884 100644 --- a/pyrogram/methods/auth/terminate_session.py +++ b/pyrogram/methods/auth/terminate_session.py @@ -37,7 +37,7 @@ async def terminate_session( ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ return await self.invoke( diff --git a/pyrogram/methods/bots/answer_callback_query.py b/pyrogram/methods/bots/answer_callback_query.py index eb5ef803c4..00307cf4e2 100644 --- a/pyrogram/methods/bots/answer_callback_query.py +++ b/pyrogram/methods/bots/answer_callback_query.py @@ -59,7 +59,7 @@ async def answer_callback_query( ``bool``: True, on success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_inline_query.py b/pyrogram/methods/bots/answer_inline_query.py index 9bca881ded..7b9f493b3e 100644 --- a/pyrogram/methods/bots/answer_inline_query.py +++ b/pyrogram/methods/bots/answer_inline_query.py @@ -84,7 +84,7 @@ async def answer_inline_query( ``bool``: True, on success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_web_app_query.py b/pyrogram/methods/bots/answer_web_app_query.py index 04b5a6299f..4264c2248e 100644 --- a/pyrogram/methods/bots/answer_web_app_query.py +++ b/pyrogram/methods/bots/answer_web_app_query.py @@ -43,7 +43,7 @@ async def answer_web_app_query( :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/delete_bot_commands.py b/pyrogram/methods/bots/delete_bot_commands.py index de9058c532..4729bfde38 100644 --- a/pyrogram/methods/bots/delete_bot_commands.py +++ b/pyrogram/methods/bots/delete_bot_commands.py @@ -48,7 +48,7 @@ async def delete_bot_commands( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_commands.py b/pyrogram/methods/bots/get_bot_commands.py index b1f42df7d4..27eba39d08 100644 --- a/pyrogram/methods/bots/get_bot_commands.py +++ b/pyrogram/methods/bots/get_bot_commands.py @@ -48,7 +48,7 @@ async def get_bot_commands( List of :obj:`~pyrogram.types.BotCommand`: On success, the list of bot commands is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_default_privileges.py b/pyrogram/methods/bots/get_bot_default_privileges.py index ed63d9101e..ec60dbed33 100644 --- a/pyrogram/methods/bots/get_bot_default_privileges.py +++ b/pyrogram/methods/bots/get_bot_default_privileges.py @@ -41,7 +41,7 @@ async def get_bot_default_privileges( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_description.py b/pyrogram/methods/bots/get_bot_info_description.py index e9cac1694a..004a888eaa 100644 --- a/pyrogram/methods/bots/get_bot_info_description.py +++ b/pyrogram/methods/bots/get_bot_info_description.py @@ -48,7 +48,7 @@ async def get_bot_info_description( ``str``: On success, returns the text shown in the chat with a bot if the chat is empty in the given language. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_short_description.py b/pyrogram/methods/bots/get_bot_info_short_description.py index 783b11b290..108999a9a1 100644 --- a/pyrogram/methods/bots/get_bot_info_short_description.py +++ b/pyrogram/methods/bots/get_bot_info_short_description.py @@ -48,7 +48,7 @@ async def get_bot_info_short_description( ``str``: On success, returns the text shown on a bot's profile page and sent together with the link when users share the bot in the given language. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_name.py b/pyrogram/methods/bots/get_bot_name.py index 4ec42b3de5..67e8221a22 100644 --- a/pyrogram/methods/bots/get_bot_name.py +++ b/pyrogram/methods/bots/get_bot_name.py @@ -45,7 +45,7 @@ async def get_bot_name( The bot should have ``can_be_edited`` property set to True. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Returns: ``str``: On success, returns the name of a bot in the given language. diff --git a/pyrogram/methods/bots/get_chat_menu_button.py b/pyrogram/methods/bots/get_chat_menu_button.py index 4c3449325b..e5ac91f5c2 100644 --- a/pyrogram/methods/bots/get_chat_menu_button.py +++ b/pyrogram/methods/bots/get_chat_menu_button.py @@ -38,7 +38,7 @@ async def get_chat_menu_button( If not specified, default bot's menu button will be returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/get_game_high_scores.py b/pyrogram/methods/bots/get_game_high_scores.py index b47b8a27ae..9d2237fa4b 100644 --- a/pyrogram/methods/bots/get_game_high_scores.py +++ b/pyrogram/methods/bots/get_game_high_scores.py @@ -54,7 +54,7 @@ async def get_game_high_scores( List of :obj:`~pyrogram.types.GameHighScore`: On success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_inline_bot_results.py b/pyrogram/methods/bots/get_inline_bot_results.py index 564744b185..a2a7ba2632 100644 --- a/pyrogram/methods/bots/get_inline_bot_results.py +++ b/pyrogram/methods/bots/get_inline_bot_results.py @@ -69,7 +69,7 @@ async def get_inline_bot_results( Raises: TimeoutError: In case the bot fails to answer within 10 seconds. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_owned_bots.py b/pyrogram/methods/bots/get_owned_bots.py index 1025049ab0..8d0c4fbfc6 100644 --- a/pyrogram/methods/bots/get_owned_bots.py +++ b/pyrogram/methods/bots/get_owned_bots.py @@ -32,7 +32,7 @@ async def get_owned_bots( List of :obj:`~pyrogram.types.User`: On success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_similar_bots.py b/pyrogram/methods/bots/get_similar_bots.py index 2a05aa9e5f..5296053b83 100644 --- a/pyrogram/methods/bots/get_similar_bots.py +++ b/pyrogram/methods/bots/get_similar_bots.py @@ -39,7 +39,7 @@ async def get_similar_bots( List of :obj:`~pyrogram.types.User`: On success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/request_callback_answer.py b/pyrogram/methods/bots/request_callback_answer.py index 8dd3b8905c..ce07e31ab2 100644 --- a/pyrogram/methods/bots/request_callback_answer.py +++ b/pyrogram/methods/bots/request_callback_answer.py @@ -62,7 +62,7 @@ async def request_callback_answer( Raises: TimeoutError: In case the bot fails to answer within 10 seconds. ValueError: In case of invalid arguments. - RPCError: In case of Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_game.py b/pyrogram/methods/bots/send_game.py index b42ff32ea4..21e569e86c 100644 --- a/pyrogram/methods/bots/send_game.py +++ b/pyrogram/methods/bots/send_game.py @@ -100,7 +100,7 @@ async def send_game( :obj:`~pyrogram.types.Message`: On success, the sent game message is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_inline_bot_result.py b/pyrogram/methods/bots/send_inline_bot_result.py index 06fda3bd8b..72ae280908 100644 --- a/pyrogram/methods/bots/send_inline_bot_result.py +++ b/pyrogram/methods/bots/send_inline_bot_result.py @@ -84,7 +84,7 @@ async def send_inline_bot_result( :obj:`~pyrogram.types.Message`: On success, the sent message is returned or False if no message was sent. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_web_app_custom_request.py b/pyrogram/methods/bots/send_web_app_custom_request.py index 99f7d4f181..bf5e4a4a46 100644 --- a/pyrogram/methods/bots/send_web_app_custom_request.py +++ b/pyrogram/methods/bots/send_web_app_custom_request.py @@ -48,7 +48,7 @@ async def send_web_app_custom_request( ``str``: On success, a JSON-serialized result is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/set_bot_commands.py b/pyrogram/methods/bots/set_bot_commands.py index 6bd68dd237..ada5112097 100644 --- a/pyrogram/methods/bots/set_bot_commands.py +++ b/pyrogram/methods/bots/set_bot_commands.py @@ -52,7 +52,7 @@ async def set_bot_commands( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_default_privileges.py b/pyrogram/methods/bots/set_bot_default_privileges.py index ddaef2cd93..af4d3c7801 100644 --- a/pyrogram/methods/bots/set_bot_default_privileges.py +++ b/pyrogram/methods/bots/set_bot_default_privileges.py @@ -46,7 +46,7 @@ async def set_bot_default_privileges( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_info_description.py b/pyrogram/methods/bots/set_bot_info_description.py index ddcddbc150..c6f3117aa5 100644 --- a/pyrogram/methods/bots/set_bot_info_description.py +++ b/pyrogram/methods/bots/set_bot_info_description.py @@ -52,7 +52,7 @@ async def set_bot_info_description( ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_info_short_description.py b/pyrogram/methods/bots/set_bot_info_short_description.py index 6412bc2954..474831e7c2 100644 --- a/pyrogram/methods/bots/set_bot_info_short_description.py +++ b/pyrogram/methods/bots/set_bot_info_short_description.py @@ -52,7 +52,7 @@ async def set_bot_info_short_description( ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_name.py b/pyrogram/methods/bots/set_bot_name.py index 657d227c05..5b157bcbe7 100644 --- a/pyrogram/methods/bots/set_bot_name.py +++ b/pyrogram/methods/bots/set_bot_name.py @@ -49,7 +49,7 @@ async def set_bot_name( The bot should have ``can_be_edited`` property set to True. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Returns: ``bool``: True on success. diff --git a/pyrogram/methods/bots/set_chat_menu_button.py b/pyrogram/methods/bots/set_chat_menu_button.py index 6419d7ef4d..1835c7aff9 100644 --- a/pyrogram/methods/bots/set_chat_menu_button.py +++ b/pyrogram/methods/bots/set_chat_menu_button.py @@ -43,7 +43,7 @@ async def set_chat_menu_button( Defaults to :obj:`~pyrogram.types.MenuButtonDefault`. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/set_game_score.py b/pyrogram/methods/bots/set_game_score.py index 24c0982e35..ae956b0435 100644 --- a/pyrogram/methods/bots/set_game_score.py +++ b/pyrogram/methods/bots/set_game_score.py @@ -69,7 +69,7 @@ async def set_game_score( message is returned, True otherwise. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py index f07558fae3..ed7cfdfd80 100644 --- a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py +++ b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py @@ -46,7 +46,7 @@ async def toggle_forum_topic_is_pinned( ``bool``: On success, True is returned. Raises: - RPCError: In case of invalid arguments. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/add_profile_audio.py b/pyrogram/methods/chats/add_profile_audio.py index 8b7ebc9e55..d82169cc88 100644 --- a/pyrogram/methods/chats/add_profile_audio.py +++ b/pyrogram/methods/chats/add_profile_audio.py @@ -40,7 +40,7 @@ async def add_profile_audio( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/set_chat_direct_messages_group.py b/pyrogram/methods/chats/set_chat_direct_messages_group.py index 311a555c7e..d3efa83bd8 100644 --- a/pyrogram/methods/chats/set_chat_direct_messages_group.py +++ b/pyrogram/methods/chats/set_chat_direct_messages_group.py @@ -50,7 +50,7 @@ async def set_chat_direct_messages_group( otherwise, in case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/set_chat_protected_content.py b/pyrogram/methods/chats/set_chat_protected_content.py index e2e43a2663..ffecc89e5c 100644 --- a/pyrogram/methods/chats/set_chat_protected_content.py +++ b/pyrogram/methods/chats/set_chat_protected_content.py @@ -49,7 +49,7 @@ async def set_chat_protected_content( otherwise, in case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPCError. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( @@ -95,7 +95,7 @@ async def process_chat_protected_content_disable_request( otherwise, in case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPCError. + :ref:`RPCError `: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/chats/transfer_chat_ownership.py b/pyrogram/methods/chats/transfer_chat_ownership.py index e61406c59e..755fdd6d44 100644 --- a/pyrogram/methods/chats/transfer_chat_ownership.py +++ b/pyrogram/methods/chats/transfer_chat_ownership.py @@ -52,7 +52,7 @@ async def transfer_chat_ownership( Raises: ValueError: In case of invalid parameters. - RPCError: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/messages/copy_message.py b/pyrogram/methods/messages/copy_message.py index 4458002967..5b4ccaaaca 100644 --- a/pyrogram/methods/messages/copy_message.py +++ b/pyrogram/methods/messages/copy_message.py @@ -131,8 +131,8 @@ async def copy_message( :obj:`~pyrogram.types.Message`: On success, the copied message is returned. Raises: - RPCError: In case of a Telegram RPC error. ValueError: In case if an invalid message_id was provided. + :ref:`RPCError `: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/messages/download_media.py b/pyrogram/methods/messages/download_media.py index 7e1157c764..a71bf10ac0 100644 --- a/pyrogram/methods/messages/download_media.py +++ b/pyrogram/methods/messages/download_media.py @@ -117,9 +117,9 @@ async def download_media( If the message is a :obj:`~pyrogram.types.PaidMediaInfo` with more than one ``paid_media`` containing ``minithumbnail`` and ``idx`` is not specified, then a list of paths or binary file-like objects is returned. Raises: - RPCError: In case of a Telegram RPC error. IndexError: In case of wrong value of ``idx``. ValueError: If the message doesn't contain any downloadable media. + :ref:`RPCError `: In case of a Telegram RPC error. Example: Download media to file diff --git a/pyrogram/methods/messages/forward_messages.py b/pyrogram/methods/messages/forward_messages.py index db86abd207..70b3f9edbc 100644 --- a/pyrogram/methods/messages/forward_messages.py +++ b/pyrogram/methods/messages/forward_messages.py @@ -105,6 +105,9 @@ async def forward_messages( :obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not a list, a single message is returned, otherwise a list of messages is returned. + Raises: + :ref:`RPCError `: In case of a Telegram RPC error. + Example: .. code-block:: python diff --git a/pyrogram/methods/stories/edit_story.py b/pyrogram/methods/stories/edit_story.py index 437822efc2..74f22fe0b5 100644 --- a/pyrogram/methods/stories/edit_story.py +++ b/pyrogram/methods/stories/edit_story.py @@ -95,7 +95,7 @@ async def edit_story( Raises: ValueError: In case of invalid arguments. - RPCError: In case of Telegram RPCError. + :ref:`RPCError `: In case of Telegram RPCError. """ @@ -256,7 +256,7 @@ async def edit_business_story( Raises: ValueError: In case of invalid arguments. - RPCError: In case of Telegram RPCError. + :ref:`RPCError `: In case of Telegram RPCError. """ if not business_connection_id: diff --git a/pyrogram/methods/stories/hide_my_story_view.py b/pyrogram/methods/stories/hide_my_story_view.py index 8d21b85cb7..84bfae1dd3 100644 --- a/pyrogram/methods/stories/hide_my_story_view.py +++ b/pyrogram/methods/stories/hide_my_story_view.py @@ -49,7 +49,7 @@ async def hide_my_story_view( await app.hide_my_story_view() Raises: - RPCError: In case of Telegram RPCError. + :ref:`RPCError `: In case of Telegram RPCError. """ diff --git a/pyrogram/methods/stories/post_story.py b/pyrogram/methods/stories/post_story.py index bb6e66bdc3..af9f18717c 100644 --- a/pyrogram/methods/stories/post_story.py +++ b/pyrogram/methods/stories/post_story.py @@ -124,7 +124,7 @@ async def post_story( Raises: ValueError: In case of invalid arguments. - RPCError: In case of Telegram RPCError. + :ref:`RPCError `: In case of Telegram RPCError. """ if business_connection_id: From 9fb077b7766f8dde55e6d2d0139f1fc0743775f1 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 09:27:13 +0100 Subject: [PATCH 06/20] sphinx.ext.linkcode Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com> --- docs/source/conf.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 87a8d2faf7..470175574b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -19,6 +19,7 @@ import os import subprocess import sys +import inspect sys.path.insert(0, os.path.abspath("../..")) @@ -32,6 +33,7 @@ "HEAD", ]).decode("UTF-8").strip() +project_url = "https://github.com/TelegramPlayGround/Pyrogram" project = "pyrotgfork" copyright = "2017-present, Dan" author = "Dan" @@ -45,6 +47,7 @@ # "sphinx.ext.viewcode", "sphinx_copybutton", # "sphinx.ext.coverage", + "sphinx.ext.linkcode", "sphinx_llms_txt", ] @@ -158,3 +161,32 @@ "genindex", "modindex", ] + +def linkcode_resolve(domain, info): + """ + Determine the URL corresponding to Python object + """ + if domain != "py": + return None + if not info["module"]: + return None + + filename = info["module"].replace(".", "/") + + # Attempt to find the exact line numbers using the inspect module + module = sys.modules.get(info["module"]) + if module is not None: + obj = module + for part in info["fullname"].split("."): + obj = getattr(obj, part, None) + + if obj is not None: + try: + source, lineno = inspect.getsourcelines(obj) + # Returns a link like: https://github.com/user/repo/blob/main/module.py#L10-L25 + return f"{project_url}/blob/{commit_id}/{filename}.py#L{lineno}-L{lineno + len(source) - 1}" + except (TypeError, OSError): + pass + + # Fallback to just linking to the file if line numbers can't be resolved + return f"{project_url}/blob/{commit_id}/{filename}.py" From a13071400160ee821ac90d2aad43bbcdd1d63631 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 09:33:11 +0100 Subject: [PATCH 07/20] docs --- docs/source/releases/changes-in-this-fork.rst | 3 --- docs/source/start/errors.rst | 2 +- docs/source/topics/message-identifiers.rst | 14 ++++++-------- pyrogram/methods/advanced/invoke.py | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index 94fe41b541..99af12e190 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -1,7 +1,4 @@ -Changes in this Fork -===================== - .. admonition :: A Word of Warning :class: tip diff --git a/docs/source/start/errors.rst b/docs/source/start/errors.rst index c03860e214..d7a47d59fc 100644 --- a/docs/source/start/errors.rst +++ b/docs/source/start/errors.rst @@ -1,4 +1,4 @@ -.. _handling_errors: +.. _handling-errors: Error Handling ============== diff --git a/docs/source/topics/message-identifiers.rst b/docs/source/topics/message-identifiers.rst index 5a66070803..0029546cd9 100644 --- a/docs/source/topics/message-identifiers.rst +++ b/docs/source/topics/message-identifiers.rst @@ -43,9 +43,8 @@ This means everyone has a message counter of one. First, User-A will sent a welcome message to both User-B and User-C:: .. - User-A → User-B: Hey, welcome! - - User-A → User-C: ¡Bienvenido! + User-A → User-B: Hey, welcome! + User-A → User-C: ¡Bienvenido! * For User-A, "Hey, welcome!" will have the message identifier 1. The message with "¡Bienvenido!" will have an ID of 2. * For User-B, "Hey, welcome" will have ID 1. @@ -60,9 +59,8 @@ First, User-A will sent a welcome message to both User-B and User-C:: Next, User-B and User-C will respond to User-A:: .. - User-B → User-A: Thanks! - - User-C → User-A: Gracias :) + User-B → User-A: Thanks! + User-C → User-A: Gracias :) .. csv-table:: Message identifiers :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M" @@ -77,7 +75,7 @@ Notice how for each message, the counter goes up by one, and they are independen Let's see what happens when User-B sends a message to Group-S:: .. - User-B → Group-S: Nice group + User-B → Group-S: Nice group .. csv-table:: Message identifiers :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M" @@ -95,7 +93,7 @@ The chat where the message was sent can be completely ignored. Megagroups behave differently:: .. - User-C → Group-M: Buen grupo + User-C → Group-M: Buen grupo .. csv-table:: Message identifiers :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M" diff --git a/pyrogram/methods/advanced/invoke.py b/pyrogram/methods/advanced/invoke.py index ce6ede726a..ef4bc57fc7 100644 --- a/pyrogram/methods/advanced/invoke.py +++ b/pyrogram/methods/advanced/invoke.py @@ -68,7 +68,7 @@ async def invoke( ``RawType``: The raw type response generated by the query. Raises: - :ref:`RPCError `: In case of a Telegram RPC error. + :ref:`RPCError `: In case of a Telegram RPC error. """ if not self.is_connected: From 45fbadf91ddbe19943d1ce935afab07f77b0f0ca Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 10:04:34 +0100 Subject: [PATCH 08/20] bump version --- .github/workflows/build-docs.yml | 6 +++--- docs/source/releases/changes-in-this-fork.rst | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 49d4b20a42..52a03abae1 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -11,13 +11,13 @@ jobs: name: build-doc runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 1 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: "3.10" - name: Install dependencies AND Build Documentation env: diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index 99af12e190..b3155200e3 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -14,15 +14,15 @@ it can take advantage of new goodies! If you found any issue or have any suggestions, feel free to make `an issue `__ on github. -Breaking Changes in this Fork -============================== - -- In :meth:`~pyrogram.Client.copy_message`, ``ValueError`` is raised instead of ``logging`` it. -- In :meth:`~pyrogram.Client.download_media`, if the message is a :obj:`~pyrogram.types.PaidMediaInfo` with more than one ``paid_media`` **and** ``idx`` was not specified, then a list of paths or binary file-like objects is returned. -- PR `#115 `_ This `change `_ breaks some usages with offset-naive and offset-aware datetimes. -- PR from upstream: `#1411 `_ without attribution. -- If you relied on internal types like ``import pyrogram.file_id`` OR ``import pyrogram.utils``, Then read this full document to know where `else `_ your code will break. -- :obj:`~pyrogram.types.InlineKeyboardButton` only accepts keyword arguments instead of positional arguments. +.. admonition :: Breaking Changes in this Fork + :class: tip + + - In :meth:`~pyrogram.Client.copy_message`, ``ValueError`` is raised instead of ``logging`` it. + - In :meth:`~pyrogram.Client.download_media`, if the message is a :obj:`~pyrogram.types.PaidMediaInfo` with more than one ``paid_media`` **and** ``idx`` was not specified, then a list of paths or binary file-like objects is returned. + - PR `#115 `_ This `change `_ breaks some usages with offset-naive and offset-aware datetimes. + - PR from upstream: `#1411 `_ without attribution. + - If you relied on internal types like ``import pyrogram.file_id`` OR ``import pyrogram.utils``, Then read this full document to know where `else `_ your code will break. + - :obj:`~pyrogram.types.InlineKeyboardButton` only accepts keyword arguments instead of positional arguments. Changes in this Fork From 7ec69daaf24e615d52c679acf80b0a87853f5b3d Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 10:14:59 +0100 Subject: [PATCH 09/20] v4 Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com> --- pyrogram/parser/markdown.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pyrogram/parser/markdown.py b/pyrogram/parser/markdown.py index 01ad8a9f90..4633908a73 100644 --- a/pyrogram/parser/markdown.py +++ b/pyrogram/parser/markdown.py @@ -121,11 +121,6 @@ def escape_and_create_quotes(text: str, strict: bool): # Boundary 1: `**>` explicitly starts a NEW expandable blockquote if curr_line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): break - - # Boundary 2: If the current block is expandable and the PREVIOUS - # line closed it with `||`, this line starts a NEW blockquote. - if started_as_expandable and bq_lines and bq_lines[-1].endswith(SPOILER_DELIM): - break curr_prefix_len = 0 if curr_line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM): @@ -320,18 +315,25 @@ def unparse(text: str, entities: list): lines = text_subset.splitlines() for line_num, line in enumerate(lines): line_start = s + sum(len(l) + 1 for l in lines[:line_num]) + + # Blockquote prefixes MUST be placed at the absolute start of the line. + # We use `-10000 + i` to ensure they are popped last and end up on the far left, + # wrapping perfectly around any inline entities sharing the same offset. + prefix_priority = -10000 + i + if entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE: - # Bot API Style: First line can be **, rest are > if line_num == 0: - insert_at.append((line_start, i, BLOCKQUOTE_EXPANDABLE_DELIM)) + insert_at.append((line_start, prefix_priority, BLOCKQUOTE_EXPANDABLE_DELIM)) else: - insert_at.append((line_start, i, BLOCKQUOTE_DELIM)) + insert_at.append((line_start, prefix_priority, BLOCKQUOTE_DELIM)) else: - insert_at.append((line_start, i, BLOCKQUOTE_DELIM)) + insert_at.append((line_start, prefix_priority, BLOCKQUOTE_DELIM)) # Append expandability mark for expandable blockquotes if entity.type == MessageEntityType.EXPANDABLE_BLOCKQUOTE: - insert_at.append((e, -i, SPOILER_DELIM)) + # Expandability marks MUST be at the absolute end of the blockquote. + # We use `10000 - i` to ensure it is popped first and ends up on the far right. + insert_at.append((e, 10000 - i, SPOILER_DELIM)) # No closing delimiter for blockquotes (handled by lines above) else: From 5f65d7384036b7d90af0fc26b6728e7ada78a854 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 10:18:16 +0100 Subject: [PATCH 10/20] v5 Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com> --- pyrogram/parser/markdown.py | 125 +++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 43 deletions(-) diff --git a/pyrogram/parser/markdown.py b/pyrogram/parser/markdown.py index 4633908a73..9b90a4d669 100644 --- a/pyrogram/parser/markdown.py +++ b/pyrogram/parser/markdown.py @@ -169,36 +169,68 @@ def escape_and_create_quotes(text: str, strict: bool): async def parse(self, text: str, strict: bool = False): text = self.escape_and_create_quotes(text, strict=strict) + + matches = list(re.finditer(MARKDOWN_RE, text)) + valid_delims = set() + opened = {} + active_fixed_width = None + + # --- Pass 1: Identify paired delimiters --- + for i, match in enumerate(matches): + delim, is_emoji_or_date, text_url, url = match.groups() + + if not delim: + continue + + # If we are inside a code block, ignore all other formatting + if active_fixed_width: + if delim == active_fixed_width: + # Closing the code block + valid_delims.add(opened[delim]) + valid_delims.add(i) + del opened[delim] + active_fixed_width = None + continue + + # Opening a new code block + if delim in FIXED_WIDTH_DELIMS: + active_fixed_width = delim + opened[delim] = i + continue + + # Standard formatting delimiters + if delim in [BOLD_DELIM, ITALIC_DELIM, UNDERLINE_DELIM, STRIKE_DELIM, SPOILER_DELIM]: + if delim not in opened: + opened[delim] = i + else: + # Valid pair found! + valid_delims.add(opened[delim]) + valid_delims.add(i) + del opened[delim] + + # --- Pass 2: Apply replacements --- delims = set() - is_fixed_width = False - - for i, match in enumerate(re.finditer(MARKDOWN_RE, text)): + + for i, match in enumerate(matches): start, _ = match.span() delim, is_emoji_or_date, text_url, url = match.groups() full = match.group(0) - if delim in FIXED_WIDTH_DELIMS: - is_fixed_width = not is_fixed_width - - if is_fixed_width and delim not in FIXED_WIDTH_DELIMS: - continue - + # 1. Handle Links if not is_emoji_or_date and text_url: text = utils.replace_once(text, full, URL_MARKUP.format(url, text_url), start) continue + # 2. Handle Emojis and Dates if is_emoji_or_date: emoji = text_url - parsed_url = urllib.parse.urlparse(url) # Parse the query parameters into a dictionary-like object query_params = urllib.parse.parse_qs(parsed_url.query) - # Branch 1: Custom Emoji if parsed_url.netloc == "emoji": emoji_id = query_params.get("id", ["0"])[0] text = utils.replace_once(text, full, EMOJI_MARKUP.format(emoji_id, emoji), start) - # Branch 2: Custom Time elif parsed_url.netloc == "time": unix_time = query_params.get("unix", ["0"])[0] @@ -209,39 +241,46 @@ async def parse(self, text: str, strict: bool = False): text = utils.replace_once(text, full, DATE_TIME_MARKUP.format(unix_time, emoji), start) continue - if delim == BOLD_DELIM: - tag = "b" - elif delim == ITALIC_DELIM: - tag = "i" - elif delim == UNDERLINE_DELIM: - tag = "u" - elif delim == STRIKE_DELIM: - tag = "s" - elif delim == CODE_DELIM: - tag = "code" - elif delim == PRE_DELIM: - tag = "pre" - elif delim == SPOILER_DELIM: - tag = "spoiler" - else: - continue + # 3. Handle Formatting Delimiters + if delim: + # If this delimiter is unclosed (or suppressed by a code block), leave it as literal text! + if i not in valid_delims: + continue + + if delim == BOLD_DELIM: + tag = "b" + elif delim == ITALIC_DELIM: + tag = "i" + elif delim == UNDERLINE_DELIM: + tag = "u" + elif delim == STRIKE_DELIM: + tag = "s" + elif delim == CODE_DELIM: + tag = "code" + elif delim == PRE_DELIM: + tag = "pre" + elif delim == SPOILER_DELIM: + tag = "spoiler" + else: + continue - if delim not in delims: - delims.add(delim) - tag = OPENING_TAG.format(tag) - else: - delims.remove(delim) - tag = CLOSING_TAG.format(tag) - - if delim == PRE_DELIM and delim in delims: - delim_and_language = text[text.find(PRE_DELIM) :].split("\n")[0] - language = delim_and_language[len(PRE_DELIM) :] - text = utils.replace_once( - text, delim_and_language, f'
', start
-                )
-                continue
+                if delim not in delims:
+                    delims.add(delim)
+                    tag = OPENING_TAG.format(tag)
+                else:
+                    delims.remove(delim)
+                    tag = CLOSING_TAG.format(tag)
+
+                # Special handling for PRE language definition
+                if delim == PRE_DELIM and delim in delims:
+                    delim_and_language = text[text.find(PRE_DELIM) :].split("\n")[0]
+                    language = delim_and_language[len(PRE_DELIM) :]
+                    text = utils.replace_once(
+                        text, delim_and_language, f'
', start
+                    )
+                    continue
 
-            text = utils.replace_once(text, delim, tag, start)
+                text = utils.replace_once(text, delim, tag, start)
 
         return await self.html.parse(text)
 

From 6d2e38770c75fafa5afd6110650510f2a4d9d941 Mon Sep 17 00:00:00 2001
From: shriMADhav U k 
Date: Sun, 22 Mar 2026 10:34:15 +0100
Subject: [PATCH 11/20] sphinx.ext.linkcode

Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com>
---
 docs/source/conf.py | 55 +++++++++++++++++++++++++++++++--------------
 1 file changed, 38 insertions(+), 17 deletions(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 470175574b..6cd81f3e23 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -16,10 +16,10 @@
 #  You should have received a copy of the GNU Lesser General Public License
 #  along with Pyrogram.  If not, see .
 
+import inspect
 import os
 import subprocess
 import sys
-import inspect
 
 sys.path.insert(0, os.path.abspath("../.."))
 
@@ -34,8 +34,10 @@
 ]).decode("UTF-8").strip()
 
 project_url = "https://github.com/TelegramPlayGround/Pyrogram"
+# --- SETUP: Define your repository root ---
+REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
 project = "pyrotgfork"
-copyright = "2017-present, Dan"
+copyright = "2017-2024, Dan"
 author = "Dan"
 version = f"{__version__} Layer {layer}"
 
@@ -171,22 +173,41 @@ def linkcode_resolve(domain, info):
     if not info["module"]:
         return None
 
-    filename = info["module"].replace(".", "/")
-    
     # Attempt to find the exact line numbers using the inspect module
     module = sys.modules.get(info["module"])
-    if module is not None:
-        obj = module
-        for part in info["fullname"].split("."):
-            obj = getattr(obj, part, None)
-            
-        if obj is not None:
-            try:
-                source, lineno = inspect.getsourcelines(obj)
-                # Returns a link like: https://github.com/user/repo/blob/main/module.py#L10-L25
-                return f"{project_url}/blob/{commit_id}/{filename}.py#L{lineno}-L{lineno + len(source) - 1}"
-            except (TypeError, OSError):
-                pass
-    
+    if module is None:
+        return None
+
+    # Traverse the object tree to find the specific class/function
+    obj = module
+    for part in info["fullname"].split("."):
+        try:
+            obj = getattr(obj, part)
+        except AttributeError:
+            return None
+
+    try:
+        # 1. Get the absolute path to the file locally
+        filepath = inspect.getsourcefile(obj)
+        if filepath is None:
+            return None
+        
+        # 2. Calculate the path relative to the root of your git repository
+        rel_filepath = os.path.relpath(filepath, start=REPO_ROOT)
+        
+        # Ensure forward slashes for the GitHub URL (important for Windows users)
+        rel_filepath = rel_filepath.replace(os.sep, "/")
+        
+        # 3. Get the line numbers
+        source, lineno = inspect.getsourcelines(obj)
+        
+        # Return the perfectly mapped GitHub URL
+        # Returns a link like: https://github.com/user/repo/blob/main/module.py#L10-L25
+        return f"{project_url}/blob/{commit_id}/{rel_filepath}#L{lineno}-L{lineno + len(source) - 1}"
+        
+    except (TypeError, OSError, ValueError):
+        # Fails safely if source cannot be inspected or path calculation fails
+        return None
+
     # Fallback to just linking to the file if line numbers can't be resolved
     return f"{project_url}/blob/{commit_id}/{filename}.py"

From 7320e035885b6eb7bd00f3d81eb0ad44faaa8a51 Mon Sep 17 00:00:00 2001
From: shriMADhav U k 
Date: Sun, 22 Mar 2026 10:49:41 +0100
Subject: [PATCH 12/20] sphinx.ext.linkcode

Co-authored-by: gemini-code-assist[bot] <176961590@users.noreply.github.com>
---
 docs/source/conf.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 6cd81f3e23..ab952dcbd8 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -186,6 +186,12 @@ def linkcode_resolve(domain, info):
         except AttributeError:
             return None
 
+    # --- Unwrap decorators to bypass sync.py wrappers ---
+    try:
+        obj = inspect.unwrap(obj)
+    except:
+        pass # If it can't be unwrapped, just proceed with the original object
+
     try:
         # 1. Get the absolute path to the file locally
         filepath = inspect.getsourcefile(obj)

From 274b5653b39cf7a842db944ade2eabf7c19ee4e5 Mon Sep 17 00:00:00 2001
From: shriMADhav U k 
Date: Sun, 22 Mar 2026 11:04:09 +0100
Subject: [PATCH 13/20] docs

---
 docs/source/start/errors.rst                                 | 2 --
 pyrogram/methods/advanced/invoke.py                          | 2 +-
 pyrogram/methods/advanced/save_file.py                       | 2 +-
 pyrogram/methods/auth/accept_terms_of_service.py             | 2 +-
 pyrogram/methods/auth/check_password.py                      | 2 +-
 pyrogram/methods/auth/get_active_sessions.py                 | 2 +-
 pyrogram/methods/auth/get_password_hint.py                   | 2 +-
 pyrogram/methods/auth/log_out.py                             | 2 +-
 pyrogram/methods/auth/recover_password.py                    | 2 +-
 pyrogram/methods/auth/resend_code.py                         | 2 +-
 pyrogram/methods/auth/send_code.py                           | 2 +-
 pyrogram/methods/auth/sign_in.py                             | 2 +-
 pyrogram/methods/auth/sign_in_bot.py                         | 2 +-
 pyrogram/methods/auth/sign_up.py                             | 2 +-
 pyrogram/methods/auth/terminate_all_other_sessions.py        | 2 +-
 pyrogram/methods/auth/terminate_session.py                   | 2 +-
 pyrogram/methods/bots/answer_callback_query.py               | 2 +-
 pyrogram/methods/bots/answer_inline_query.py                 | 2 +-
 pyrogram/methods/bots/answer_web_app_query.py                | 2 +-
 pyrogram/methods/bots/delete_bot_commands.py                 | 2 +-
 pyrogram/methods/bots/get_bot_commands.py                    | 2 +-
 pyrogram/methods/bots/get_bot_default_privileges.py          | 2 +-
 pyrogram/methods/bots/get_bot_info_description.py            | 2 +-
 pyrogram/methods/bots/get_bot_info_short_description.py      | 2 +-
 pyrogram/methods/bots/get_bot_name.py                        | 2 +-
 pyrogram/methods/bots/get_chat_menu_button.py                | 2 +-
 pyrogram/methods/bots/get_game_high_scores.py                | 2 +-
 pyrogram/methods/bots/get_inline_bot_results.py              | 2 +-
 pyrogram/methods/bots/get_owned_bots.py                      | 2 +-
 pyrogram/methods/bots/get_similar_bots.py                    | 2 +-
 pyrogram/methods/bots/request_callback_answer.py             | 2 +-
 pyrogram/methods/bots/send_game.py                           | 2 +-
 pyrogram/methods/bots/send_inline_bot_result.py              | 2 +-
 pyrogram/methods/bots/send_web_app_custom_request.py         | 2 +-
 pyrogram/methods/bots/set_bot_commands.py                    | 2 +-
 pyrogram/methods/bots/set_bot_default_privileges.py          | 2 +-
 pyrogram/methods/bots/set_bot_info_description.py            | 2 +-
 pyrogram/methods/bots/set_bot_info_short_description.py      | 2 +-
 pyrogram/methods/bots/set_bot_name.py                        | 2 +-
 pyrogram/methods/bots/set_chat_menu_button.py                | 2 +-
 pyrogram/methods/bots/set_game_score.py                      | 2 +-
 pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py | 2 +-
 pyrogram/methods/chats/add_profile_audio.py                  | 2 +-
 pyrogram/methods/chats/set_chat_direct_messages_group.py     | 2 +-
 pyrogram/methods/chats/set_chat_protected_content.py         | 4 ++--
 pyrogram/methods/chats/transfer_chat_ownership.py            | 2 +-
 pyrogram/methods/messages/copy_message.py                    | 2 +-
 pyrogram/methods/messages/download_media.py                  | 2 +-
 pyrogram/methods/messages/forward_messages.py                | 2 +-
 pyrogram/methods/stories/edit_story.py                       | 4 ++--
 pyrogram/methods/stories/hide_my_story_view.py               | 2 +-
 pyrogram/methods/stories/post_story.py                       | 2 +-
 52 files changed, 53 insertions(+), 55 deletions(-)

diff --git a/docs/source/start/errors.rst b/docs/source/start/errors.rst
index d7a47d59fc..f96e91fe02 100644
--- a/docs/source/start/errors.rst
+++ b/docs/source/start/errors.rst
@@ -1,5 +1,3 @@
-.. _handling-errors:
-
 Error Handling
 ==============
 
diff --git a/pyrogram/methods/advanced/invoke.py b/pyrogram/methods/advanced/invoke.py
index ef4bc57fc7..792a01b7e0 100644
--- a/pyrogram/methods/advanced/invoke.py
+++ b/pyrogram/methods/advanced/invoke.py
@@ -68,7 +68,7 @@ async def invoke(
             ``RawType``: The raw type response generated by the query.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         if not self.is_connected:
diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py
index 5e76ca4018..490393b9a5 100644
--- a/pyrogram/methods/advanced/save_file.py
+++ b/pyrogram/methods/advanced/save_file.py
@@ -90,7 +90,7 @@ async def save_file(
             ``InputFile``: On success, the uploaded file is returned in form of an InputFile object.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         if path is None:
diff --git a/pyrogram/methods/auth/accept_terms_of_service.py b/pyrogram/methods/auth/accept_terms_of_service.py
index e2c0e1f1e8..45732008ee 100644
--- a/pyrogram/methods/auth/accept_terms_of_service.py
+++ b/pyrogram/methods/auth/accept_terms_of_service.py
@@ -34,7 +34,7 @@ async def accept_terms_of_service(
                 The terms of service identifier.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         r = await self.invoke(
diff --git a/pyrogram/methods/auth/check_password.py b/pyrogram/methods/auth/check_password.py
index eb3038f5ab..3557251342 100644
--- a/pyrogram/methods/auth/check_password.py
+++ b/pyrogram/methods/auth/check_password.py
@@ -44,7 +44,7 @@ async def check_password(
 
         Raises:
             BadRequest: In case the password is invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         r = await self.invoke(
diff --git a/pyrogram/methods/auth/get_active_sessions.py b/pyrogram/methods/auth/get_active_sessions.py
index 41f4035dd2..5af27f35ca 100644
--- a/pyrogram/methods/auth/get_active_sessions.py
+++ b/pyrogram/methods/auth/get_active_sessions.py
@@ -32,7 +32,7 @@ async def get_active_sessions(
             :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         r = await self.invoke(
diff --git a/pyrogram/methods/auth/get_password_hint.py b/pyrogram/methods/auth/get_password_hint.py
index 2f321cebbd..aa4811dddf 100644
--- a/pyrogram/methods/auth/get_password_hint.py
+++ b/pyrogram/methods/auth/get_password_hint.py
@@ -36,7 +36,7 @@ async def get_password_hint(
             ``str``: On success, the password hint as string is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         return (await self.invoke(raw.functions.account.GetPassword())).hint
diff --git a/pyrogram/methods/auth/log_out.py b/pyrogram/methods/auth/log_out.py
index 4e112da767..22af60bfd5 100644
--- a/pyrogram/methods/auth/log_out.py
+++ b/pyrogram/methods/auth/log_out.py
@@ -39,7 +39,7 @@ async def log_out(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/auth/recover_password.py b/pyrogram/methods/auth/recover_password.py
index 46fbf39ac3..8f7c1a0960 100644
--- a/pyrogram/methods/auth/recover_password.py
+++ b/pyrogram/methods/auth/recover_password.py
@@ -44,7 +44,7 @@ async def recover_password(
 
         Raises:
             BadRequest: In case the recovery code is invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         r = await self.invoke(
diff --git a/pyrogram/methods/auth/resend_code.py b/pyrogram/methods/auth/resend_code.py
index d3b72a590e..f253ec3b46 100644
--- a/pyrogram/methods/auth/resend_code.py
+++ b/pyrogram/methods/auth/resend_code.py
@@ -51,7 +51,7 @@ async def resend_code(
 
         Raises:
             BadRequest: In case the arguments are invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         phone_number = phone_number.strip(" +")
diff --git a/pyrogram/methods/auth/send_code.py b/pyrogram/methods/auth/send_code.py
index 9cb3e3ec14..76762983c6 100644
--- a/pyrogram/methods/auth/send_code.py
+++ b/pyrogram/methods/auth/send_code.py
@@ -46,7 +46,7 @@ async def send_code(
 
         Raises:
             BadRequest: In case the phone number is invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         phone_number = phone_number.strip(" +")
diff --git a/pyrogram/methods/auth/sign_in.py b/pyrogram/methods/auth/sign_in.py
index c1f7c0c694..ed0e4f5915 100644
--- a/pyrogram/methods/auth/sign_in.py
+++ b/pyrogram/methods/auth/sign_in.py
@@ -57,7 +57,7 @@ async def sign_in(
         Raises:
             BadRequest: In case the arguments are invalid.
             SessionPasswordNeeded: In case a password is needed to sign in.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         phone_number = phone_number.strip(" +")
diff --git a/pyrogram/methods/auth/sign_in_bot.py b/pyrogram/methods/auth/sign_in_bot.py
index 50c3f43df6..d6ccf70f6c 100644
--- a/pyrogram/methods/auth/sign_in_bot.py
+++ b/pyrogram/methods/auth/sign_in_bot.py
@@ -45,7 +45,7 @@ async def sign_in_bot(
 
         Raises:
             BadRequest: In case the bot token is invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         while True:
diff --git a/pyrogram/methods/auth/sign_up.py b/pyrogram/methods/auth/sign_up.py
index fce4ecad0e..7038c6af1b 100644
--- a/pyrogram/methods/auth/sign_up.py
+++ b/pyrogram/methods/auth/sign_up.py
@@ -55,7 +55,7 @@ async def sign_up(
 
         Raises:
             BadRequest: In case the arguments are invalid.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         phone_number = phone_number.strip(" +")
diff --git a/pyrogram/methods/auth/terminate_all_other_sessions.py b/pyrogram/methods/auth/terminate_all_other_sessions.py
index ae54f47b6d..cd014503dc 100644
--- a/pyrogram/methods/auth/terminate_all_other_sessions.py
+++ b/pyrogram/methods/auth/terminate_all_other_sessions.py
@@ -32,7 +32,7 @@ async def terminate_all_other_sessions(
             ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         return await self.invoke(
diff --git a/pyrogram/methods/auth/terminate_session.py b/pyrogram/methods/auth/terminate_session.py
index c01de78884..42c382ccea 100644
--- a/pyrogram/methods/auth/terminate_session.py
+++ b/pyrogram/methods/auth/terminate_session.py
@@ -37,7 +37,7 @@ async def terminate_session(
             ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         return await self.invoke(
diff --git a/pyrogram/methods/bots/answer_callback_query.py b/pyrogram/methods/bots/answer_callback_query.py
index 00307cf4e2..c800655e78 100644
--- a/pyrogram/methods/bots/answer_callback_query.py
+++ b/pyrogram/methods/bots/answer_callback_query.py
@@ -59,7 +59,7 @@ async def answer_callback_query(
             ``bool``: True, on success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/answer_inline_query.py b/pyrogram/methods/bots/answer_inline_query.py
index 7b9f493b3e..df5ce00ccd 100644
--- a/pyrogram/methods/bots/answer_inline_query.py
+++ b/pyrogram/methods/bots/answer_inline_query.py
@@ -84,7 +84,7 @@ async def answer_inline_query(
             ``bool``: True, on success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/answer_web_app_query.py b/pyrogram/methods/bots/answer_web_app_query.py
index 4264c2248e..d29311c8c7 100644
--- a/pyrogram/methods/bots/answer_web_app_query.py
+++ b/pyrogram/methods/bots/answer_web_app_query.py
@@ -43,7 +43,7 @@ async def answer_web_app_query(
             :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
diff --git a/pyrogram/methods/bots/delete_bot_commands.py b/pyrogram/methods/bots/delete_bot_commands.py
index 4729bfde38..c739c93f96 100644
--- a/pyrogram/methods/bots/delete_bot_commands.py
+++ b/pyrogram/methods/bots/delete_bot_commands.py
@@ -48,7 +48,7 @@ async def delete_bot_commands(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_bot_commands.py b/pyrogram/methods/bots/get_bot_commands.py
index 27eba39d08..b9a2950c15 100644
--- a/pyrogram/methods/bots/get_bot_commands.py
+++ b/pyrogram/methods/bots/get_bot_commands.py
@@ -48,7 +48,7 @@ async def get_bot_commands(
             List of :obj:`~pyrogram.types.BotCommand`: On success, the list of bot commands is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_bot_default_privileges.py b/pyrogram/methods/bots/get_bot_default_privileges.py
index ec60dbed33..482876f388 100644
--- a/pyrogram/methods/bots/get_bot_default_privileges.py
+++ b/pyrogram/methods/bots/get_bot_default_privileges.py
@@ -41,7 +41,7 @@ async def get_bot_default_privileges(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_bot_info_description.py b/pyrogram/methods/bots/get_bot_info_description.py
index 004a888eaa..57074b8d3d 100644
--- a/pyrogram/methods/bots/get_bot_info_description.py
+++ b/pyrogram/methods/bots/get_bot_info_description.py
@@ -48,7 +48,7 @@ async def get_bot_info_description(
             ``str``: On success, returns the text shown in the chat with a bot if the chat is empty in the given language.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_bot_info_short_description.py b/pyrogram/methods/bots/get_bot_info_short_description.py
index 108999a9a1..b855ed8564 100644
--- a/pyrogram/methods/bots/get_bot_info_short_description.py
+++ b/pyrogram/methods/bots/get_bot_info_short_description.py
@@ -48,7 +48,7 @@ async def get_bot_info_short_description(
             ``str``: On success, returns the text shown on a bot's profile page and sent together with the link when users share the bot in the given language.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_bot_name.py b/pyrogram/methods/bots/get_bot_name.py
index 67e8221a22..8295ce41ac 100644
--- a/pyrogram/methods/bots/get_bot_name.py
+++ b/pyrogram/methods/bots/get_bot_name.py
@@ -45,7 +45,7 @@ async def get_bot_name(
                 The bot should have ``can_be_edited`` property set to True.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Returns:
             ``str``: On success, returns the name of a bot in the given language.
diff --git a/pyrogram/methods/bots/get_chat_menu_button.py b/pyrogram/methods/bots/get_chat_menu_button.py
index e5ac91f5c2..c58bb7adda 100644
--- a/pyrogram/methods/bots/get_chat_menu_button.py
+++ b/pyrogram/methods/bots/get_chat_menu_button.py
@@ -38,7 +38,7 @@ async def get_chat_menu_button(
                 If not specified, default bot's menu button will be returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
diff --git a/pyrogram/methods/bots/get_game_high_scores.py b/pyrogram/methods/bots/get_game_high_scores.py
index 9d2237fa4b..276d5dec23 100644
--- a/pyrogram/methods/bots/get_game_high_scores.py
+++ b/pyrogram/methods/bots/get_game_high_scores.py
@@ -54,7 +54,7 @@ async def get_game_high_scores(
             List of :obj:`~pyrogram.types.GameHighScore`: On success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_inline_bot_results.py b/pyrogram/methods/bots/get_inline_bot_results.py
index a2a7ba2632..e9c82aea6b 100644
--- a/pyrogram/methods/bots/get_inline_bot_results.py
+++ b/pyrogram/methods/bots/get_inline_bot_results.py
@@ -69,7 +69,7 @@ async def get_inline_bot_results(
 
         Raises:
             TimeoutError: In case the bot fails to answer within 10 seconds.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_owned_bots.py b/pyrogram/methods/bots/get_owned_bots.py
index 8d0c4fbfc6..ebda5ce071 100644
--- a/pyrogram/methods/bots/get_owned_bots.py
+++ b/pyrogram/methods/bots/get_owned_bots.py
@@ -32,7 +32,7 @@ async def get_owned_bots(
             List of :obj:`~pyrogram.types.User`: On success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/get_similar_bots.py b/pyrogram/methods/bots/get_similar_bots.py
index 5296053b83..3d108356c1 100644
--- a/pyrogram/methods/bots/get_similar_bots.py
+++ b/pyrogram/methods/bots/get_similar_bots.py
@@ -39,7 +39,7 @@ async def get_similar_bots(
             List of :obj:`~pyrogram.types.User`: On success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/request_callback_answer.py b/pyrogram/methods/bots/request_callback_answer.py
index ce07e31ab2..c6987ee4d9 100644
--- a/pyrogram/methods/bots/request_callback_answer.py
+++ b/pyrogram/methods/bots/request_callback_answer.py
@@ -62,7 +62,7 @@ async def request_callback_answer(
         Raises:
             TimeoutError: In case the bot fails to answer within 10 seconds.
             ValueError: In case of invalid arguments.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/send_game.py b/pyrogram/methods/bots/send_game.py
index 21e569e86c..14f5f23ab3 100644
--- a/pyrogram/methods/bots/send_game.py
+++ b/pyrogram/methods/bots/send_game.py
@@ -100,7 +100,7 @@ async def send_game(
             :obj:`~pyrogram.types.Message`: On success, the sent game message is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/send_inline_bot_result.py b/pyrogram/methods/bots/send_inline_bot_result.py
index 72ae280908..cf6a5e1ecf 100644
--- a/pyrogram/methods/bots/send_inline_bot_result.py
+++ b/pyrogram/methods/bots/send_inline_bot_result.py
@@ -84,7 +84,7 @@ async def send_inline_bot_result(
             :obj:`~pyrogram.types.Message`: On success, the sent message is returned or False if no message was sent.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/send_web_app_custom_request.py b/pyrogram/methods/bots/send_web_app_custom_request.py
index bf5e4a4a46..740e4cc005 100644
--- a/pyrogram/methods/bots/send_web_app_custom_request.py
+++ b/pyrogram/methods/bots/send_web_app_custom_request.py
@@ -48,7 +48,7 @@ async def send_web_app_custom_request(
             ``str``: On success, a JSON-serialized result is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
diff --git a/pyrogram/methods/bots/set_bot_commands.py b/pyrogram/methods/bots/set_bot_commands.py
index ada5112097..9f0f9a7e07 100644
--- a/pyrogram/methods/bots/set_bot_commands.py
+++ b/pyrogram/methods/bots/set_bot_commands.py
@@ -52,7 +52,7 @@ async def set_bot_commands(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/set_bot_default_privileges.py b/pyrogram/methods/bots/set_bot_default_privileges.py
index af4d3c7801..129bcbd882 100644
--- a/pyrogram/methods/bots/set_bot_default_privileges.py
+++ b/pyrogram/methods/bots/set_bot_default_privileges.py
@@ -46,7 +46,7 @@ async def set_bot_default_privileges(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/set_bot_info_description.py b/pyrogram/methods/bots/set_bot_info_description.py
index c6f3117aa5..b696ab2e8b 100644
--- a/pyrogram/methods/bots/set_bot_info_description.py
+++ b/pyrogram/methods/bots/set_bot_info_description.py
@@ -52,7 +52,7 @@ async def set_bot_info_description(
             ``bool``: True on success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/set_bot_info_short_description.py b/pyrogram/methods/bots/set_bot_info_short_description.py
index 474831e7c2..fa99f8befa 100644
--- a/pyrogram/methods/bots/set_bot_info_short_description.py
+++ b/pyrogram/methods/bots/set_bot_info_short_description.py
@@ -52,7 +52,7 @@ async def set_bot_info_short_description(
             ``bool``: True on success.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/bots/set_bot_name.py b/pyrogram/methods/bots/set_bot_name.py
index 5b157bcbe7..81901d65ce 100644
--- a/pyrogram/methods/bots/set_bot_name.py
+++ b/pyrogram/methods/bots/set_bot_name.py
@@ -49,7 +49,7 @@ async def set_bot_name(
                 The bot should have ``can_be_edited`` property set to True.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Returns:
             ``bool``: True on success.
diff --git a/pyrogram/methods/bots/set_chat_menu_button.py b/pyrogram/methods/bots/set_chat_menu_button.py
index 1835c7aff9..4db5fadc0c 100644
--- a/pyrogram/methods/bots/set_chat_menu_button.py
+++ b/pyrogram/methods/bots/set_chat_menu_button.py
@@ -43,7 +43,7 @@ async def set_chat_menu_button(
                 Defaults to :obj:`~pyrogram.types.MenuButtonDefault`.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
diff --git a/pyrogram/methods/bots/set_game_score.py b/pyrogram/methods/bots/set_game_score.py
index ae956b0435..5d5db7c096 100644
--- a/pyrogram/methods/bots/set_game_score.py
+++ b/pyrogram/methods/bots/set_game_score.py
@@ -69,7 +69,7 @@ async def set_game_score(
             message is returned, True otherwise.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py
index ed7cfdfd80..87add6aebe 100644
--- a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py
+++ b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py
@@ -46,7 +46,7 @@ async def toggle_forum_topic_is_pinned(
             ``bool``: On success, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/chats/add_profile_audio.py b/pyrogram/methods/chats/add_profile_audio.py
index d82169cc88..ffafc291b2 100644
--- a/pyrogram/methods/chats/add_profile_audio.py
+++ b/pyrogram/methods/chats/add_profile_audio.py
@@ -40,7 +40,7 @@ async def add_profile_audio(
             ``bool``: On success, True is returned.
         
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/chats/set_chat_direct_messages_group.py b/pyrogram/methods/chats/set_chat_direct_messages_group.py
index d3efa83bd8..4f918c76ec 100644
--- a/pyrogram/methods/chats/set_chat_direct_messages_group.py
+++ b/pyrogram/methods/chats/set_chat_direct_messages_group.py
@@ -50,7 +50,7 @@ async def set_chat_direct_messages_group(
             otherwise, in case a message object couldn't be returned, True is returned.
         
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/chats/set_chat_protected_content.py b/pyrogram/methods/chats/set_chat_protected_content.py
index ffecc89e5c..fa83fc1da3 100644
--- a/pyrogram/methods/chats/set_chat_protected_content.py
+++ b/pyrogram/methods/chats/set_chat_protected_content.py
@@ -49,7 +49,7 @@ async def set_chat_protected_content(
             otherwise, in case a message object couldn't be returned, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         r = await self.invoke(
@@ -95,7 +95,7 @@ async def process_chat_protected_content_disable_request(
             otherwise, in case a message object couldn't be returned, True is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
         
         """
         r = await self.invoke(
diff --git a/pyrogram/methods/chats/transfer_chat_ownership.py b/pyrogram/methods/chats/transfer_chat_ownership.py
index 755fdd6d44..511c3b6e2d 100644
--- a/pyrogram/methods/chats/transfer_chat_ownership.py
+++ b/pyrogram/methods/chats/transfer_chat_ownership.py
@@ -52,7 +52,7 @@ async def transfer_chat_ownership(
 
         Raises:
             ValueError: In case of invalid parameters.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/messages/copy_message.py b/pyrogram/methods/messages/copy_message.py
index 5b4ccaaaca..e86e5e4adf 100644
--- a/pyrogram/methods/messages/copy_message.py
+++ b/pyrogram/methods/messages/copy_message.py
@@ -132,7 +132,7 @@ async def copy_message(
 
         Raises:
             ValueError: In case if an invalid message_id was provided.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/messages/download_media.py b/pyrogram/methods/messages/download_media.py
index a71bf10ac0..920029543d 100644
--- a/pyrogram/methods/messages/download_media.py
+++ b/pyrogram/methods/messages/download_media.py
@@ -119,7 +119,7 @@ async def download_media(
         Raises:
             IndexError: In case of wrong value of ``idx``.
             ValueError: If the message doesn't contain any downloadable media.
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             Download media to file
diff --git a/pyrogram/methods/messages/forward_messages.py b/pyrogram/methods/messages/forward_messages.py
index 70b3f9edbc..0d6c328b85 100644
--- a/pyrogram/methods/messages/forward_messages.py
+++ b/pyrogram/methods/messages/forward_messages.py
@@ -106,7 +106,7 @@ async def forward_messages(
             a list, a single message is returned, otherwise a list of messages is returned.
 
         Raises:
-            :ref:`RPCError `: In case of a Telegram RPC error.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python
diff --git a/pyrogram/methods/stories/edit_story.py b/pyrogram/methods/stories/edit_story.py
index 74f22fe0b5..5e11ba51b3 100644
--- a/pyrogram/methods/stories/edit_story.py
+++ b/pyrogram/methods/stories/edit_story.py
@@ -95,7 +95,7 @@ async def edit_story(
 
         Raises:
             ValueError: In case of invalid arguments.
-            :ref:`RPCError `: In case of Telegram RPCError.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
@@ -256,7 +256,7 @@ async def edit_business_story(
 
         Raises:
             ValueError: In case of invalid arguments.
-            :ref:`RPCError `: In case of Telegram RPCError.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         if not business_connection_id:
diff --git a/pyrogram/methods/stories/hide_my_story_view.py b/pyrogram/methods/stories/hide_my_story_view.py
index 84bfae1dd3..32169a7599 100644
--- a/pyrogram/methods/stories/hide_my_story_view.py
+++ b/pyrogram/methods/stories/hide_my_story_view.py
@@ -49,7 +49,7 @@ async def hide_my_story_view(
                 await app.hide_my_story_view()
 
         Raises:
-            :ref:`RPCError `: In case of Telegram RPCError.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
 
diff --git a/pyrogram/methods/stories/post_story.py b/pyrogram/methods/stories/post_story.py
index af9f18717c..0061b7182e 100644
--- a/pyrogram/methods/stories/post_story.py
+++ b/pyrogram/methods/stories/post_story.py
@@ -124,7 +124,7 @@ async def post_story(
 
         Raises:
             ValueError: In case of invalid arguments.
-            :ref:`RPCError `: In case of Telegram RPCError.
+            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
 
         """
         if business_connection_id:

From 5894798a13a1d3dce05ee7df8d66501dbecac94e Mon Sep 17 00:00:00 2001
From: shriMADhav U k 
Date: Sun, 22 Mar 2026 11:40:03 +0100
Subject: [PATCH 14/20] docs

---
 docs/source/topics/message-identifiers.rst    | 26 ++++++++-----------
 pyrogram/methods/messages/forward_messages.py |  2 +-
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/docs/source/topics/message-identifiers.rst b/docs/source/topics/message-identifiers.rst
index 0029546cd9..e58e6c6497 100644
--- a/docs/source/topics/message-identifiers.rst
+++ b/docs/source/topics/message-identifiers.rst
@@ -40,11 +40,10 @@ Let's look at a concrete example.
 Every account and channel has just been created.
 This means everyone has a message counter of one.
 
-First, User-A will sent a welcome message to both User-B and User-C::
+.. First, User-A will sent a welcome message to both User-B and User-C::
 
-..
-  User-A → User-B: Hey, welcome!
-  User-A → User-C: ¡Bienvenido!
+    User-A → User-B: Hey, welcome!
+    User-A → User-C: ¡Bienvenido!
 
 * For User-A, "Hey, welcome!" will have the message identifier 1. The message with "¡Bienvenido!" will have an ID of 2.
 * For User-B, "Hey, welcome" will have ID 1.
@@ -56,11 +55,11 @@ First, User-A will sent a welcome message to both User-B and User-C::
    "Hey, welcome!", 1, 1, "", "", ""
    "¡Bienvenido!", 2, "", 1, "", ""
 
-Next, User-B and User-C will respond to User-A::
 
-..
-  User-B → User-A: Thanks!
-  User-C → User-A: Gracias :)
+.. Next, User-B and User-C will respond to User-A::
+
+    User-B → User-A: Thanks!
+    User-C → User-A: Gracias :)
 
 .. csv-table:: Message identifiers
    :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M"
@@ -72,10 +71,9 @@ Next, User-B and User-C will respond to User-A::
 
 Notice how for each message, the counter goes up by one, and they are independent.
 
-Let's see what happens when User-B sends a message to Group-S::
+.. Let's see what happens when User-B sends a message to Group-S::
 
-..
-  User-B → Group-S: Nice group
+    User-B → Group-S: Nice group
 
 .. csv-table:: Message identifiers
    :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M"
@@ -90,10 +88,8 @@ While the message was sent to a different chat, the group itself doesn't have a
 The message identifiers are still unique for each account.
 The chat where the message was sent can be completely ignored.
 
-Megagroups behave differently::
-
-..
-  User-C → Group-M: Buen grupo
+.. Megagroups behave differently::
+    User-C → Group-M: Buen grupo
 
 .. csv-table:: Message identifiers
    :header: "Message", "User-A", "User-B", "User-C", "Group-S", "Group-M"
diff --git a/pyrogram/methods/messages/forward_messages.py b/pyrogram/methods/messages/forward_messages.py
index 0d6c328b85..fcf2c0790d 100644
--- a/pyrogram/methods/messages/forward_messages.py
+++ b/pyrogram/methods/messages/forward_messages.py
@@ -106,7 +106,7 @@ async def forward_messages(
             a list, a single message is returned, otherwise a list of messages is returned.
 
         Raises:
-            :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error.
+            :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error.
 
         Example:
             .. code-block:: python

From 20c464d10429a87d195766c8ebb97b82df68c53c Mon Sep 17 00:00:00 2001
From: KurimuzonAkuma 
Date: Sun, 22 Mar 2026 16:13:05 +0100
Subject: [PATCH 15/20] Add test_markdown.py

https://github.com/KurimuzonAkuma/kurigram/raw/8e5c740/tests/parser/test_markdown.py
---
 tests/parser/test_markdown.py | 147 ++++++++++++++++++++++++++++++++++
 1 file changed, 147 insertions(+)
 create mode 100644 tests/parser/test_markdown.py

diff --git a/tests/parser/test_markdown.py b/tests/parser/test_markdown.py
new file mode 100644
index 0000000000..98b7c31fdf
--- /dev/null
+++ b/tests/parser/test_markdown.py
@@ -0,0 +1,147 @@
+#  Pyrogram - Telegram MTProto API Client Library for Python
+#  Copyright (C) 2017-present Dan 
+#
+#  This file is part of Pyrogram.
+#
+#  Pyrogram is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Lesser General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  Pyrogram is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public License
+#  along with Pyrogram.  If not, see .
+
+import pyrogram
+from pyrogram.parser.markdown import Markdown
+
+
+# expected: the expected unparsed Markdown
+# text: original text without entities
+# entities: message entities coming from the server
+
+def test_markdown_unparse_bold():
+    expected = "**bold**"
+    text = "bold"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=4)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_italic():
+    expected = "__italic__"
+    text = "italic"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=0, length=6)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_strike():
+    expected = "~~strike~~"
+    text = "strike"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=0, length=6)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_spoiler():
+    expected = "||spoiler||"
+    text = "spoiler"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=0, length=7)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_url():
+    expected = '[URL](https://pyrogram.org/)'
+    text = "URL"
+    entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.TEXT_LINK,
+                                                                 offset=0, length=3, url='https://pyrogram.org/')])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_emoji():
+    expected = '![🥲](tg://emoji?id=5195264424893488796) im crying'
+    text = "🥲 im crying"
+    entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CUSTOM_EMOJI,
+                                                                 offset=0, length=2, custom_emoji_id=5195264424893488796)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_code():
+    expected = '`code`'
+    text = "code"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=0, length=4)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_pre():
+    expected = """```python
+for i in range(10):
+    print(i)
+```"""
+
+    text = """for i in range(10):
+    print(i)"""
+
+    entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.PRE, offset=0,
+                                                                 length=32, language='python')])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_blockquote():
+    expected = """> Hello
+> from
+
+> pyrogram!"""
+
+    text = """Hello\nfrom\n\npyrogram!"""
+
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=0, length=10),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=12, length=9)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_mixed():
+    expected = "**aaaaaaa__aaabbb**__~~dddddddd||ddeee~~||||eeeeeeefff||ffff`fffggggggg`ggghhhhhhhhhh"
+    text = "aaaaaaaaaabbbddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhh"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=13),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=7, length=6),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=13, length=13),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=21, length=5),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=26, length=10),
+         pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=40, length=10)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+
+def test_markdown_unparse_no_entities():
+    expected = "text"
+    text = "text"
+    entities = []
+
+    assert Markdown.unparse(text=text, entities=entities) == expected
+
+def test_markdown_unparse_html():
+    expected = "__This works, it's ok__ This shouldn't"
+    text = "This works, it's ok This shouldn't"
+    entities = pyrogram.types.List(
+        [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=0, length=19)])
+
+    assert Markdown.unparse(text=text, entities=entities) == expected

From a841430c0d177c6e36727b7c3640225bf92487bf Mon Sep 17 00:00:00 2001
From: shriMADhav U k 
Date: Sun, 22 Mar 2026 16:56:46 +0100
Subject: [PATCH 16/20] fix tests

---
 pyrogram/file_id.py           | 54 ++++++++++-----------
 pyrogram/parser/html.py       |  4 +-
 tests/parser/test_html.py     | 78 +++++++++++++++++++++---------
 tests/parser/test_markdown.py | 89 ++++++++++++++++++++++-------------
 4 files changed, 143 insertions(+), 82 deletions(-)

diff --git a/pyrogram/file_id.py b/pyrogram/file_id.py
index 070b65d4a8..cb7fdecaec 100644
--- a/pyrogram/file_id.py
+++ b/pyrogram/file_id.py
@@ -307,25 +307,25 @@ class FileIdCached:
     _encoded: typing.Optional[str] = None
 
     def __init__(
-            self, *,
-            major: int = MAJOR,
-            minor: int = MINOR,
-            file_type: FileType,
-            dc_id: int,
-            file_reference: bytes = b"",
-            url: str = None,
-            media_id: int = None,
-            access_hash: int = None,
-            volume_id: int = None,
-            thumbnail_source: ThumbnailSource = None,
-            thumbnail_file_type: FileType = None,
-            thumbnail_size: str = "",
-            secret: int = None,
-            local_id: int = None,
-            chat_id: int = None,
-            chat_access_hash: int = None,
-            sticker_set_id: int = None,
-            sticker_set_access_hash: int = None
+        self, *,
+        major: int = MAJOR,
+        minor: int = MINOR,
+        file_type: FileType,
+        dc_id: int,
+        file_reference: bytes = b"",
+        url: str = None,
+        media_id: int = None,
+        access_hash: int = None,
+        volume_id: int = None,
+        thumbnail_source: ThumbnailSource = None,
+        thumbnail_file_type: FileType = None,
+        thumbnail_size: str = "",
+        secret: int = None,
+        local_id: int = None,
+        chat_id: int = None,
+        chat_access_hash: int = None,
+        sticker_set_id: int = None,
+        sticker_set_access_hash: int = None
     ):
         self.major = major
         self.minor = minor
@@ -416,7 +416,7 @@ def encode(self, *, major: int = None, minor: int = None):
         return self._encoded
 
     def __str__(self):
-        return str({k: v for k, v in self.__dict__.items() if v is not None})
+        return str({k: v for k, v in self.__dict__.items() if k != "_encoded" and v is not None})
 
 
 class FileUniqueType(IntEnum):
@@ -477,12 +477,12 @@ class FileUniqueIdCached:
     _encoded: typing.Optional[str] = None
 
     def __init__(
-            self, *,
-            file_unique_type: FileUniqueType,
-            url: str = None,
-            media_id: int = None,
-            volume_id: int = None,
-            local_id: int = None
+        self, *,
+        file_unique_type: FileUniqueType,
+        url: str = None,
+        media_id: int = None,
+        volume_id: int = None,
+        local_id: int = None
     ):
         self.file_unique_type = file_unique_type
         self.url = url
@@ -513,4 +513,4 @@ def encode(self):
         return self._encoded
 
     def __str__(self):
-        return str({k: v for k, v in self.__dict__.items() if v is not None})
+        return str({k: v for k, v in self.__dict__.items() if k != "_encoded" and v is not None})
diff --git a/pyrogram/parser/html.py b/pyrogram/parser/html.py
index 168c3524e2..773775bf9f 100644
--- a/pyrogram/parser/html.py
+++ b/pyrogram/parser/html.py
@@ -210,11 +210,13 @@ def parse_one(entity):
             elif entity_type in (
                 MessageEntityType.CODE,
                 MessageEntityType.BLOCKQUOTE,
-                MessageEntityType.SPOILER,
             ):
                 name = entity_type.name.lower()
                 start_tag = f"<{name}>"
                 end_tag = f""
+            elif entity_type == MessageEntityType.SPOILER:
+                start_tag = ""
+                end_tag = ""
             elif entity_type == MessageEntityType.TEXT_LINK:
                 url = entity.url
                 start_tag = f''
diff --git a/tests/parser/test_html.py b/tests/parser/test_html.py
index b9138f3cf1..08dfbe7485 100644
--- a/tests/parser/test_html.py
+++ b/tests/parser/test_html.py
@@ -61,7 +61,7 @@ def test_html_unparse_strike():
 
 
 def test_html_unparse_spoiler():
-    expected = "spoiler"
+    expected = "spoiler"
     text = "spoiler"
     entities = pyrogram.types.List(
         [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=0, length=7)])
@@ -72,8 +72,25 @@ def test_html_unparse_spoiler():
 def test_html_unparse_url():
     expected = 'URL'
     text = "URL"
-    entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.TEXT_LINK,
-                                                                 offset=0, length=3, url='https://pyrogram.org/')])
+    entities = pyrogram.types.List([
+        pyrogram.types.MessageEntity(
+            type=pyrogram.enums.MessageEntityType.TEXT_LINK,
+            offset=0, length=3,
+            url="https://pyrogram.org/"
+        )
+    ])
+
+    assert HTML.unparse(text=text, entities=entities) == expected
+
+
+def test_html_unparse_emoji():
+    expected = '🥲 im crying'
+    text = "🥲 im crying"
+    entities = pyrogram.types.List([
+        pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CUSTOM_EMOJI,
+        offset=0, length=2,
+        custom_emoji_id=5195264424893488796)
+    ])
 
     assert HTML.unparse(text=text, entities=entities) == expected
 
@@ -88,34 +105,53 @@ def test_html_unparse_code():
 
 
 def test_html_unparse_pre():
-    expected = """
for i in range(10):
-    print(i)
""" + expected = """
for i in range(10):
+    print(i)
""" text = """for i in range(10): print(i)""" - entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.PRE, offset=0, - length=32, language='python')]) + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity( + type=pyrogram.enums.MessageEntityType.PRE, + offset=0, length=32, + language="python" + ) + ]) + + assert HTML.unparse(text=text, entities=entities) == expected + + +def test_html_unparse_blockquote(): + expected = """
Block quotation started\nBlock quotation continued\nThe last line of the block quotation
\n
Expandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation
""" + + text = """Block quotation started\nBlock quotation continued\nThe last line of the block quotation\nExpandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation""" + + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=0, length=86), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.EXPANDABLE_BLOCKQUOTE, offset=87, length=236) + ]) assert HTML.unparse(text=text, entities=entities) == expected def test_html_unparse_mixed(): - expected = "aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd" \ - "eeeeeeeeeeffffffffffgggggggggghhhhhhhhhh" + expected = "aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd" \ + "eeeeeeeeeeffffffffffgggggggggghhhhhhhhhh" text = "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhh" - entities = pyrogram.types.List( - [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=14), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=7, length=7), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=10, length=4), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=14, length=9), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=14, length=9), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=23, length=10), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=30, length=3), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=33, length=10), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=38, length=5), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=43, length=10), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=57, length=10)]) + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=14), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=7, length=7), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=10, length=4), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=14, length=9), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=14, length=9), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=23, length=10), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=30, length=3), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=33, length=10), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=38, length=5), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=43, length=10), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=57, length=10) + ]) assert HTML.unparse(text=text, entities=entities) == expected diff --git a/tests/parser/test_markdown.py b/tests/parser/test_markdown.py index 98b7c31fdf..08f10ca34a 100644 --- a/tests/parser/test_markdown.py +++ b/tests/parser/test_markdown.py @@ -42,6 +42,24 @@ def test_markdown_unparse_italic(): assert Markdown.unparse(text=text, entities=entities) == expected +def test_markdown_unparse_italic_html(): + expected = "__This works, it's ok__ This shouldn't" + text = "This works, it's ok This shouldn't" + entities = pyrogram.types.List( + [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=0, length=19)]) + + assert Markdown.unparse(text=text, entities=entities) == expected + + +def test_markdown_unparse_underline(): + expected = "--underline--" + text = "underline" + entities = pyrogram.types.List( + [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=0, length=9)]) + + assert Markdown.unparse(text=text, entities=entities) == expected + + def test_markdown_unparse_strike(): expected = "~~strike~~" text = "strike" @@ -72,8 +90,11 @@ def test_markdown_unparse_url(): def test_markdown_unparse_emoji(): expected = '![🥲](tg://emoji?id=5195264424893488796) im crying' text = "🥲 im crying" - entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CUSTOM_EMOJI, - offset=0, length=2, custom_emoji_id=5195264424893488796)]) + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CUSTOM_EMOJI, + offset=0, length=2, + custom_emoji_id=5195264424893488796) + ]) assert Markdown.unparse(text=text, entities=entities) == expected @@ -90,43 +111,53 @@ def test_markdown_unparse_code(): def test_markdown_unparse_pre(): expected = """```python for i in range(10): - print(i) -```""" + print(i)```""" text = """for i in range(10): print(i)""" - - entities = pyrogram.types.List([pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.PRE, offset=0, - length=32, language='python')]) + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity( + type=pyrogram.enums.MessageEntityType.PRE, + offset=0, length=32, + language="python" + ) + ]) assert Markdown.unparse(text=text, entities=entities) == expected def test_markdown_unparse_blockquote(): - expected = """> Hello -> from - -> pyrogram!""" - - text = """Hello\nfrom\n\npyrogram!""" - - entities = pyrogram.types.List( - [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=0, length=10), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=12, length=9)]) + expected = """>Block quotation started +>Block quotation continued +>The last line of the block quotation +**>Expandable block quotation started +>Expandable block quotation continued +>Expandable block quotation continued +>Hidden by default part of the block quotation started +>Expandable block quotation continued +>The last line of the block quotation||""" + + text = """Block quotation started\nBlock quotation continued\nThe last line of the block quotation\nExpandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation""" + + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=0, length=86), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.EXPANDABLE_BLOCKQUOTE, offset=87, length=236) + ]) assert Markdown.unparse(text=text, entities=entities) == expected def test_markdown_unparse_mixed(): - expected = "**aaaaaaa__aaabbb**__~~dddddddd||ddeee~~||||eeeeeeefff||ffff`fffggggggg`ggghhhhhhhhhh" + expected = "**aaaaaaa__aaabbb__**~~dddddddd||ddeee||~~||eeeeeeefff||ffff`fffggggggg`ggghhhhhhhhhh" text = "aaaaaaaaaabbbddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhh" - entities = pyrogram.types.List( - [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=13), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=7, length=6), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=13, length=13), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=21, length=5), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=26, length=10), - pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=40, length=10)]) + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=13), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=7, length=6), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=13, length=13), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=21, length=5), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=26, length=10), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=40, length=10) + ]) assert Markdown.unparse(text=text, entities=entities) == expected @@ -137,11 +168,3 @@ def test_markdown_unparse_no_entities(): entities = [] assert Markdown.unparse(text=text, entities=entities) == expected - -def test_markdown_unparse_html(): - expected = "__This works, it's ok__ This shouldn't" - text = "This works, it's ok This shouldn't" - entities = pyrogram.types.List( - [pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=0, length=19)]) - - assert Markdown.unparse(text=text, entities=entities) == expected From 2e1cb4f25c7f4fb0bd389c9dab756abfd8dcca25 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Sun, 22 Mar 2026 17:27:43 +0100 Subject: [PATCH 17/20] fix: custom_emoji_id typo https://github.com/KurimuzonAkuma/kurigram/commit/cd1ba4d --- .../messages/get_custom_emoji_stickers.py | 6 ++--- pyrogram/methods/users/set_emoji_status.py | 3 ++- .../inline_keyboard_button.py | 13 +++++----- .../bots_and_keyboards/keyboard_button.py | 13 +++++----- .../messages_and_media/message_entity.py | 10 +++++--- pyrogram/types/messages_and_media/reaction.py | 25 ++++++++----------- pyrogram/types/user_and_chats/emoji_status.py | 13 +++++----- 7 files changed, 43 insertions(+), 40 deletions(-) diff --git a/pyrogram/methods/messages/get_custom_emoji_stickers.py b/pyrogram/methods/messages/get_custom_emoji_stickers.py index 9968a92347..89931c1f2b 100644 --- a/pyrogram/methods/messages/get_custom_emoji_stickers.py +++ b/pyrogram/methods/messages/get_custom_emoji_stickers.py @@ -23,14 +23,14 @@ class GetCustomEmojiStickers: async def get_custom_emoji_stickers( self: "pyrogram.Client", - custom_emoji_ids: list[int], + custom_emoji_ids: list[str], ) -> list["types.Sticker"]: """Get information about custom emoji stickers by their identifiers. .. include:: /_includes/usable-by/users-bots.rst Parameters: - custom_emoji_ids (List of ``int``): + custom_emoji_ids (List of ``str``): List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. @@ -39,7 +39,7 @@ async def get_custom_emoji_stickers( """ result = await self.invoke( raw.functions.messages.GetCustomEmojiDocuments( - document_id=custom_emoji_ids + document_id=[int(document_id) for document_id in custom_emoji_ids] ) ) diff --git a/pyrogram/methods/users/set_emoji_status.py b/pyrogram/methods/users/set_emoji_status.py index 2d8c77cc02..ffa852af71 100644 --- a/pyrogram/methods/users/set_emoji_status.py +++ b/pyrogram/methods/users/set_emoji_status.py @@ -43,7 +43,8 @@ async def set_emoji_status( from pyrogram import types - await app.set_emoji_status(types.EmojiStatus(custom_emoji_id=1234567890987654321)) + await app.set_emoji_status(types.EmojiStatus(custom_emoji_id="1234567890987654321")) + """ await self.invoke( raw.functions.account.UpdateEmojiStatus( diff --git a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py index 6753ae582b..b3319b8b37 100644 --- a/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/inline_keyboard_button.py @@ -32,7 +32,7 @@ class InlineKeyboardButton(Object): text (``str``): Label text on the button. - icon_custom_emoji_id (``int``, *optional*): + icon_custom_emoji_id (``str``, *optional*): Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.. style (:obj:`~pyrogram.enums.ButtonStyle`, *optional*): @@ -99,7 +99,10 @@ class InlineKeyboardButton(Object): def __init__( self, - text: str, *, + text: str, + icon_custom_emoji_id: Optional[str] = None, + style: Optional["enums.ButtonStyle"] = enums.ButtonStyle.DEFAULT, + *, url: Optional[str] = None, user_id: Optional[int] = None, callback_data: Optional[Union[str, bytes]] = None, @@ -112,8 +115,6 @@ def __init__( callback_game: Optional["types.CallbackGame"] = None, pay: Optional[bool] = None, callback_data_with_password: Optional[bytes] = None, - icon_custom_emoji_id: Optional[int] = None, - style: "enums.ButtonStyle" = enums.ButtonStyle.DEFAULT ): super().__init__() @@ -147,7 +148,7 @@ def read(b: "raw.base.KeyboardButton"): elif raw_style.bg_success: button_style = enums.ButtonStyle.SUCCESS if raw_style.icon: - icon_custom_emoji_id = raw_style.icon + icon_custom_emoji_id = str(raw_style.icon) if isinstance(b, raw.types.KeyboardButtonCallback): # Try decode data to keep it as string, but if fails, fallback to bytes so we don't lose any information, @@ -267,7 +268,7 @@ async def write(self, client: "pyrogram.Client"): bg_primary=self.style == enums.ButtonStyle.PRIMARY, bg_danger=self.style == enums.ButtonStyle.DANGER, bg_success=self.style == enums.ButtonStyle.SUCCESS, - icon=self.icon_custom_emoji_id + icon=int(self.icon_custom_emoji_id) if self.icon_custom_emoji_id else None ) if self.callback_data_with_password is not None: diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button.py b/pyrogram/types/bots_and_keyboards/keyboard_button.py index 787914610e..1a6c4c4638 100644 --- a/pyrogram/types/bots_and_keyboards/keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/keyboard_button.py @@ -34,7 +34,7 @@ class KeyboardButton(Object): Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed. - icon_custom_emoji_id (``int``, *optional*): + icon_custom_emoji_id (``str``, *optional*): Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.. style (:obj:`~pyrogram.enums.ButtonStyle`, *optional*): @@ -70,15 +70,16 @@ class KeyboardButton(Object): def __init__( self, - text: str, *, + text: str, + icon_custom_emoji_id: Optional[str] = None, + style: "enums.ButtonStyle" = enums.ButtonStyle.DEFAULT, + *, request_contact: bool = None, request_location: bool = None, request_poll: "types.KeyboardButtonPollType" = None, web_app: "types.WebAppInfo" = None, request_users: "types.KeyboardButtonRequestUsers" = None, request_chat: "types.KeyboardButtonRequestChat" = None, - icon_custom_emoji_id: Optional[int] = None, - style: "enums.ButtonStyle" = enums.ButtonStyle.DEFAULT ): super().__init__() @@ -106,7 +107,7 @@ def read(b): elif raw_style.bg_success: button_style = enums.ButtonStyle.SUCCESS if raw_style.icon: - icon_custom_emoji_id = raw_style.icon + icon_custom_emoji_id = str(raw_style.icon) if isinstance(b, raw.types.KeyboardButton): return KeyboardButton( @@ -222,7 +223,7 @@ def write(self): bg_primary=self.style == enums.ButtonStyle.PRIMARY, bg_danger=self.style == enums.ButtonStyle.DANGER, bg_success=self.style == enums.ButtonStyle.SUCCESS, - icon=self.icon_custom_emoji_id + icon=int(self.icon_custom_emoji_id) if self.icon_custom_emoji_id else None ) if self.request_contact: diff --git a/pyrogram/types/messages_and_media/message_entity.py b/pyrogram/types/messages_and_media/message_entity.py index 120fd8db99..87bb82d0a0 100644 --- a/pyrogram/types/messages_and_media/message_entity.py +++ b/pyrogram/types/messages_and_media/message_entity.py @@ -48,7 +48,7 @@ class MessageEntity(Object): language (``str``, *optional*): For :obj:`~pyrogram.enums.MessageEntityType.PRE` only, the programming language of the entity text. - custom_emoji_id (``int``, *optional*): + custom_emoji_id (``str``, *optional*): For :obj:`~pyrogram.enums.MessageEntityType.CUSTOM_EMOJI` only, unique identifier of the custom emoji. Use :meth:`~pyrogram.Client.get_custom_emoji_stickers` to get full information about the sticker. @@ -70,7 +70,7 @@ def __init__( url: str = None, user: "types.User" = None, language: str = None, - custom_emoji_id: int = None, + custom_emoji_id: str = None, unix_time: int = None, date_time_format: str = None, ): @@ -131,6 +131,8 @@ def _parse(client, entity: "raw.base.MessageEntity", users: dict) -> Optional["M entity_type = enums.MessageEntityType.UNKNOWN user_id = getattr(entity, "user_id", None) + custom_emoji_id = getattr(entity, "document_id", None) + return MessageEntity( type=entity_type, offset=entity.offset, @@ -138,7 +140,7 @@ def _parse(client, entity: "raw.base.MessageEntity", users: dict) -> Optional["M url=getattr(entity, "url", None), user=types.User._parse(client, users.get(user_id, None)), language=getattr(entity, "language", None), - custom_emoji_id=getattr(entity, "document_id", None), + custom_emoji_id=str(custom_emoji_id) if custom_emoji_id else None, unix_time=unix_time, date_time_format=date_time_format, client=client @@ -164,7 +166,7 @@ async def write(self): args.pop("custom_emoji_id") if self.custom_emoji_id is not None: - args["document_id"] = self.custom_emoji_id + args["document_id"] = int(self.custom_emoji_id) if self.type == enums.MessageEntityType.EXPANDABLE_BLOCKQUOTE: args["collapsed"] = True diff --git a/pyrogram/types/messages_and_media/reaction.py b/pyrogram/types/messages_and_media/reaction.py index b9778981be..06e6ca73a9 100644 --- a/pyrogram/types/messages_and_media/reaction.py +++ b/pyrogram/types/messages_and_media/reaction.py @@ -27,11 +27,8 @@ class Reaction(Object): """Contains information about a reaction. Parameters: - emoji (``str``, *optional*): - Reaction emoji. - - custom_emoji_id (``int``, *optional*): - Custom emoji id. + type (:obj:`~pyrogram.types.ReactionType`, *optional*): + List of chosen reactions. count (``int``, *optional*): Reaction count. @@ -40,9 +37,6 @@ class Reaction(Object): Chosen reaction order. Available for chosen reactions. - is_paid (``bool``, *optional*): - True, if this is a paid reaction. - """ def __init__( @@ -52,7 +46,6 @@ def __init__( type: "types.ReactionType" = None, count: Optional[int] = None, chosen_order: Optional[int] = None, - is_paid: Optional[bool] = None ): super().__init__(client) @@ -77,7 +70,7 @@ def _parse( return Reaction( client=client, type=ReactionTypeCustomEmoji( - custom_emoji_id=reaction.document_id + custom_emoji_id=str(reaction.document_id) ) ) @@ -133,7 +126,7 @@ def _parse( ) elif isinstance(update, raw.types.ReactionCustomEmoji): return ReactionTypeCustomEmoji( - custom_emoji_id=update.document_id + custom_emoji_id=str(update.document_id) ) elif isinstance(update, raw.types.ReactionPaid): return ReactionTypePaid() @@ -148,6 +141,7 @@ class ReactionTypeEmoji(ReactionType): Parameters: emoji (``str``, *optional*): Reaction emoji. + """ def __init__( @@ -172,6 +166,7 @@ class ReactionTypeCustomEmoji(ReactionType): Parameters: custom_emoji_id (``str``, *optional*): Custom emoji id. + """ def __init__( @@ -185,9 +180,11 @@ def __init__( ) def write(self, client: "pyrogram.Client") -> "raw.base.Reaction": - return raw.types.ReactionCustomEmoji( - document_id=self.custom_emoji_id - ) + if self.custom_emoji_id is not None: + return raw.types.ReactionCustomEmoji( + document_id=int(self.custom_emoji_id) + ) + return raw.types.ReactionEmpty() class ReactionTypePaid(ReactionType): diff --git a/pyrogram/types/user_and_chats/emoji_status.py b/pyrogram/types/user_and_chats/emoji_status.py index d997471717..3cc44a634b 100644 --- a/pyrogram/types/user_and_chats/emoji_status.py +++ b/pyrogram/types/user_and_chats/emoji_status.py @@ -29,18 +29,19 @@ class EmojiStatus(Object): """A user emoji status. Parameters: - custom_emoji_id (``int``): + custom_emoji_id (``str``): Custom emoji id. until_date (:py:obj:`~datetime.datetime`, *optional*): Valid until date. + """ def __init__( self, *, client: "pyrogram.Client" = None, - custom_emoji_id: int, + custom_emoji_id: str, until_date: Optional[datetime] = None, _raw: "raw.base.EmojiStatus" = None, ): @@ -55,7 +56,7 @@ def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatu if isinstance(emoji_status, raw.types.EmojiStatus): return EmojiStatus( client=client, - custom_emoji_id=emoji_status.document_id, + custom_emoji_id=str(emoji_status.document_id), until_date=utils.timestamp_to_datetime(emoji_status.until), _raw=emoji_status ) @@ -63,7 +64,7 @@ def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatu if isinstance(emoji_status, raw.types.EmojiStatusCollectible): return EmojiStatus( client=client, - custom_emoji_id=emoji_status.document_id, + custom_emoji_id=str(emoji_status.document_id), until_date=utils.timestamp_to_datetime(emoji_status.until), _raw=emoji_status ) @@ -73,10 +74,10 @@ def _parse(client, emoji_status: "raw.base.EmojiStatus") -> Optional["EmojiStatu def write(self): if self.until_date: return raw.types.EmojiStatusUntil( - document_id=self.custom_emoji_id, + document_id=int(self.custom_emoji_id), until=utils.datetime_to_timestamp(self.until_date) ) return raw.types.EmojiStatus( - document_id=self.custom_emoji_id + document_id=int(self.custom_emoji_id) ) From 87a9cc23dcc2e280c40e4ae2df6282a0c7dfb3d1 Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Mon, 23 Mar 2026 01:26:11 +0100 Subject: [PATCH 18/20] docs --- docs/source/releases/changes-in-this-fork.rst | 1 + pyrogram/methods/advanced/invoke.py | 2 +- pyrogram/methods/advanced/save_file.py | 2 +- .../methods/auth/accept_terms_of_service.py | 2 +- pyrogram/methods/auth/check_password.py | 2 +- pyrogram/methods/auth/get_active_sessions.py | 2 +- pyrogram/methods/auth/get_password_hint.py | 2 +- pyrogram/methods/auth/log_out.py | 2 +- pyrogram/methods/auth/recover_password.py | 2 +- pyrogram/methods/auth/resend_code.py | 2 +- pyrogram/methods/auth/send_code.py | 2 +- pyrogram/methods/auth/sign_in.py | 2 +- pyrogram/methods/auth/sign_in_bot.py | 2 +- pyrogram/methods/auth/sign_up.py | 2 +- .../auth/terminate_all_other_sessions.py | 2 +- pyrogram/methods/auth/terminate_session.py | 2 +- .../methods/bots/answer_callback_query.py | 2 +- pyrogram/methods/bots/answer_inline_query.py | 2 +- pyrogram/methods/bots/answer_web_app_query.py | 2 +- pyrogram/methods/bots/delete_bot_commands.py | 2 +- pyrogram/methods/bots/get_bot_commands.py | 2 +- .../bots/get_bot_default_privileges.py | 2 +- .../methods/bots/get_bot_info_description.py | 2 +- .../bots/get_bot_info_short_description.py | 2 +- pyrogram/methods/bots/get_bot_name.py | 2 +- pyrogram/methods/bots/get_chat_menu_button.py | 2 +- pyrogram/methods/bots/get_game_high_scores.py | 2 +- .../methods/bots/get_inline_bot_results.py | 2 +- pyrogram/methods/bots/get_owned_bots.py | 2 +- pyrogram/methods/bots/get_similar_bots.py | 2 +- .../methods/bots/request_callback_answer.py | 2 +- pyrogram/methods/bots/send_game.py | 2 +- .../methods/bots/send_inline_bot_result.py | 2 +- .../bots/send_web_app_custom_request.py | 2 +- pyrogram/methods/bots/set_bot_commands.py | 2 +- .../bots/set_bot_default_privileges.py | 2 +- .../methods/bots/set_bot_info_description.py | 2 +- .../bots/set_bot_info_short_description.py | 2 +- pyrogram/methods/bots/set_bot_name.py | 2 +- pyrogram/methods/bots/set_chat_menu_button.py | 2 +- pyrogram/methods/bots/set_game_score.py | 2 +- .../toggle_forum_topic_is_pinned.py | 2 +- pyrogram/methods/chats/add_profile_audio.py | 2 +- .../chats/set_chat_direct_messages_group.py | 2 +- .../chats/set_chat_protected_content.py | 4 +-- .../methods/chats/transfer_chat_ownership.py | 2 +- pyrogram/methods/messages/copy_message.py | 2 +- pyrogram/methods/messages/download_media.py | 2 +- pyrogram/methods/stories/edit_story.py | 4 +-- .../methods/stories/hide_my_story_view.py | 2 +- pyrogram/methods/stories/post_story.py | 2 +- .../types/authorization/active_session.py | 2 +- .../bots_and_keyboards/callback_query.py | 12 ++++--- .../types/inline_mode/chosen_inline_result.py | 12 ++++--- .../external_reply_info.py | 2 +- pyrogram/types/messages_and_media/message.py | 3 +- pyrogram/types/messages_and_media/poll.py | 3 +- pyrogram/types/stories/story.py | 8 +++-- pyrogram/types/user_and_chats/chat.py | 33 ++++++++++++------- .../types/user_and_chats/chat_join_request.py | 6 ++-- pyrogram/types/user_and_chats/user.py | 15 ++++++--- 61 files changed, 116 insertions(+), 85 deletions(-) diff --git a/docs/source/releases/changes-in-this-fork.rst b/docs/source/releases/changes-in-this-fork.rst index b3155200e3..257b568820 100644 --- a/docs/source/releases/changes-in-this-fork.rst +++ b/docs/source/releases/changes-in-this-fork.rst @@ -32,6 +32,7 @@ Changes in this Fork | Scheme layer used: 223 | +------------------------+ +- Added the method :meth:`~pyrogram.Client.send_message_draft`, allowing bots to stream partial messages to a user while being generated. (contributed by @sudo-py-dev in `#231 `__). - Added the :obj:`~pyrogram.types.MessageEntity` type :obj:`~pyrogram.enums.MessageEntityType.DATE_TIME`, allowing to show a formatted date and time to the user. - Added the fields ``chat_owner_left``, ``chat_owner_changed``, ``chat_has_protected_content_toggled`` and ``chat_has_protected_content_disable_requested`` to the class :obj:`~pyrogram.types.Message`. - Added the field ``can_edit_tag`` to the class :obj:`~pyrogram.types.ChatPermissions`. diff --git a/pyrogram/methods/advanced/invoke.py b/pyrogram/methods/advanced/invoke.py index 792a01b7e0..de06a0bfb3 100644 --- a/pyrogram/methods/advanced/invoke.py +++ b/pyrogram/methods/advanced/invoke.py @@ -68,7 +68,7 @@ async def invoke( ``RawType``: The raw type response generated by the query. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ if not self.is_connected: diff --git a/pyrogram/methods/advanced/save_file.py b/pyrogram/methods/advanced/save_file.py index 490393b9a5..2b83b294de 100644 --- a/pyrogram/methods/advanced/save_file.py +++ b/pyrogram/methods/advanced/save_file.py @@ -90,7 +90,7 @@ async def save_file( ``InputFile``: On success, the uploaded file is returned in form of an InputFile object. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ if path is None: diff --git a/pyrogram/methods/auth/accept_terms_of_service.py b/pyrogram/methods/auth/accept_terms_of_service.py index 45732008ee..19daf97682 100644 --- a/pyrogram/methods/auth/accept_terms_of_service.py +++ b/pyrogram/methods/auth/accept_terms_of_service.py @@ -34,7 +34,7 @@ async def accept_terms_of_service( The terms of service identifier. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/check_password.py b/pyrogram/methods/auth/check_password.py index 3557251342..e5f0f5efbb 100644 --- a/pyrogram/methods/auth/check_password.py +++ b/pyrogram/methods/auth/check_password.py @@ -44,7 +44,7 @@ async def check_password( Raises: BadRequest: In case the password is invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/get_active_sessions.py b/pyrogram/methods/auth/get_active_sessions.py index 5af27f35ca..53f0f10611 100644 --- a/pyrogram/methods/auth/get_active_sessions.py +++ b/pyrogram/methods/auth/get_active_sessions.py @@ -32,7 +32,7 @@ async def get_active_sessions( :obj:`~pyrogram.types.ActiveSessions`: On success, all the active sessions of the current user is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/get_password_hint.py b/pyrogram/methods/auth/get_password_hint.py index aa4811dddf..1a717a5c90 100644 --- a/pyrogram/methods/auth/get_password_hint.py +++ b/pyrogram/methods/auth/get_password_hint.py @@ -36,7 +36,7 @@ async def get_password_hint( ``str``: On success, the password hint as string is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return (await self.invoke(raw.functions.account.GetPassword())).hint diff --git a/pyrogram/methods/auth/log_out.py b/pyrogram/methods/auth/log_out.py index 22af60bfd5..d28b3c6533 100644 --- a/pyrogram/methods/auth/log_out.py +++ b/pyrogram/methods/auth/log_out.py @@ -39,7 +39,7 @@ async def log_out( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/auth/recover_password.py b/pyrogram/methods/auth/recover_password.py index 8f7c1a0960..d571da8514 100644 --- a/pyrogram/methods/auth/recover_password.py +++ b/pyrogram/methods/auth/recover_password.py @@ -44,7 +44,7 @@ async def recover_password( Raises: BadRequest: In case the recovery code is invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/auth/resend_code.py b/pyrogram/methods/auth/resend_code.py index f253ec3b46..6cc78c2a15 100644 --- a/pyrogram/methods/auth/resend_code.py +++ b/pyrogram/methods/auth/resend_code.py @@ -51,7 +51,7 @@ async def resend_code( Raises: BadRequest: In case the arguments are invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/send_code.py b/pyrogram/methods/auth/send_code.py index 76762983c6..72673b028c 100644 --- a/pyrogram/methods/auth/send_code.py +++ b/pyrogram/methods/auth/send_code.py @@ -46,7 +46,7 @@ async def send_code( Raises: BadRequest: In case the phone number is invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in.py b/pyrogram/methods/auth/sign_in.py index ed0e4f5915..a946d32f78 100644 --- a/pyrogram/methods/auth/sign_in.py +++ b/pyrogram/methods/auth/sign_in.py @@ -57,7 +57,7 @@ async def sign_in( Raises: BadRequest: In case the arguments are invalid. SessionPasswordNeeded: In case a password is needed to sign in. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/sign_in_bot.py b/pyrogram/methods/auth/sign_in_bot.py index d6ccf70f6c..2123eaf239 100644 --- a/pyrogram/methods/auth/sign_in_bot.py +++ b/pyrogram/methods/auth/sign_in_bot.py @@ -45,7 +45,7 @@ async def sign_in_bot( Raises: BadRequest: In case the bot token is invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ while True: diff --git a/pyrogram/methods/auth/sign_up.py b/pyrogram/methods/auth/sign_up.py index 7038c6af1b..d8a551f9f2 100644 --- a/pyrogram/methods/auth/sign_up.py +++ b/pyrogram/methods/auth/sign_up.py @@ -55,7 +55,7 @@ async def sign_up( Raises: BadRequest: In case the arguments are invalid. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ phone_number = phone_number.strip(" +") diff --git a/pyrogram/methods/auth/terminate_all_other_sessions.py b/pyrogram/methods/auth/terminate_all_other_sessions.py index cd014503dc..0aa4a2d043 100644 --- a/pyrogram/methods/auth/terminate_all_other_sessions.py +++ b/pyrogram/methods/auth/terminate_all_other_sessions.py @@ -32,7 +32,7 @@ async def terminate_all_other_sessions( ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self.invoke( diff --git a/pyrogram/methods/auth/terminate_session.py b/pyrogram/methods/auth/terminate_session.py index 42c382ccea..50364e57eb 100644 --- a/pyrogram/methods/auth/terminate_session.py +++ b/pyrogram/methods/auth/terminate_session.py @@ -37,7 +37,7 @@ async def terminate_session( ``bool``: On success, in case the session is destroyed, True is returned. Otherwise, False is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self.invoke( diff --git a/pyrogram/methods/bots/answer_callback_query.py b/pyrogram/methods/bots/answer_callback_query.py index c800655e78..a476488e37 100644 --- a/pyrogram/methods/bots/answer_callback_query.py +++ b/pyrogram/methods/bots/answer_callback_query.py @@ -59,7 +59,7 @@ async def answer_callback_query( ``bool``: True, on success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_inline_query.py b/pyrogram/methods/bots/answer_inline_query.py index df5ce00ccd..c0bb4a96db 100644 --- a/pyrogram/methods/bots/answer_inline_query.py +++ b/pyrogram/methods/bots/answer_inline_query.py @@ -84,7 +84,7 @@ async def answer_inline_query( ``bool``: True, on success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/answer_web_app_query.py b/pyrogram/methods/bots/answer_web_app_query.py index d29311c8c7..c9e2eea6f4 100644 --- a/pyrogram/methods/bots/answer_web_app_query.py +++ b/pyrogram/methods/bots/answer_web_app_query.py @@ -43,7 +43,7 @@ async def answer_web_app_query( :obj:`~pyrogram.types.SentWebAppMessage`: On success the sent web app message is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/delete_bot_commands.py b/pyrogram/methods/bots/delete_bot_commands.py index c739c93f96..562b2d7272 100644 --- a/pyrogram/methods/bots/delete_bot_commands.py +++ b/pyrogram/methods/bots/delete_bot_commands.py @@ -48,7 +48,7 @@ async def delete_bot_commands( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_commands.py b/pyrogram/methods/bots/get_bot_commands.py index b9a2950c15..9249c06e82 100644 --- a/pyrogram/methods/bots/get_bot_commands.py +++ b/pyrogram/methods/bots/get_bot_commands.py @@ -48,7 +48,7 @@ async def get_bot_commands( List of :obj:`~pyrogram.types.BotCommand`: On success, the list of bot commands is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_default_privileges.py b/pyrogram/methods/bots/get_bot_default_privileges.py index 482876f388..5d794442b6 100644 --- a/pyrogram/methods/bots/get_bot_default_privileges.py +++ b/pyrogram/methods/bots/get_bot_default_privileges.py @@ -41,7 +41,7 @@ async def get_bot_default_privileges( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_description.py b/pyrogram/methods/bots/get_bot_info_description.py index 57074b8d3d..f22b4cd948 100644 --- a/pyrogram/methods/bots/get_bot_info_description.py +++ b/pyrogram/methods/bots/get_bot_info_description.py @@ -48,7 +48,7 @@ async def get_bot_info_description( ``str``: On success, returns the text shown in the chat with a bot if the chat is empty in the given language. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_info_short_description.py b/pyrogram/methods/bots/get_bot_info_short_description.py index b855ed8564..7b709e3d33 100644 --- a/pyrogram/methods/bots/get_bot_info_short_description.py +++ b/pyrogram/methods/bots/get_bot_info_short_description.py @@ -48,7 +48,7 @@ async def get_bot_info_short_description( ``str``: On success, returns the text shown on a bot's profile page and sent together with the link when users share the bot in the given language. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_bot_name.py b/pyrogram/methods/bots/get_bot_name.py index 8295ce41ac..6408ecf63a 100644 --- a/pyrogram/methods/bots/get_bot_name.py +++ b/pyrogram/methods/bots/get_bot_name.py @@ -45,7 +45,7 @@ async def get_bot_name( The bot should have ``can_be_edited`` property set to True. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Returns: ``str``: On success, returns the name of a bot in the given language. diff --git a/pyrogram/methods/bots/get_chat_menu_button.py b/pyrogram/methods/bots/get_chat_menu_button.py index c58bb7adda..815b0428b3 100644 --- a/pyrogram/methods/bots/get_chat_menu_button.py +++ b/pyrogram/methods/bots/get_chat_menu_button.py @@ -38,7 +38,7 @@ async def get_chat_menu_button( If not specified, default bot's menu button will be returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/get_game_high_scores.py b/pyrogram/methods/bots/get_game_high_scores.py index 276d5dec23..b581334786 100644 --- a/pyrogram/methods/bots/get_game_high_scores.py +++ b/pyrogram/methods/bots/get_game_high_scores.py @@ -54,7 +54,7 @@ async def get_game_high_scores( List of :obj:`~pyrogram.types.GameHighScore`: On success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_inline_bot_results.py b/pyrogram/methods/bots/get_inline_bot_results.py index e9c82aea6b..cae9f1bf12 100644 --- a/pyrogram/methods/bots/get_inline_bot_results.py +++ b/pyrogram/methods/bots/get_inline_bot_results.py @@ -69,7 +69,7 @@ async def get_inline_bot_results( Raises: TimeoutError: In case the bot fails to answer within 10 seconds. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_owned_bots.py b/pyrogram/methods/bots/get_owned_bots.py index ebda5ce071..4a2a57518f 100644 --- a/pyrogram/methods/bots/get_owned_bots.py +++ b/pyrogram/methods/bots/get_owned_bots.py @@ -32,7 +32,7 @@ async def get_owned_bots( List of :obj:`~pyrogram.types.User`: On success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/get_similar_bots.py b/pyrogram/methods/bots/get_similar_bots.py index 3d108356c1..a8dde77764 100644 --- a/pyrogram/methods/bots/get_similar_bots.py +++ b/pyrogram/methods/bots/get_similar_bots.py @@ -39,7 +39,7 @@ async def get_similar_bots( List of :obj:`~pyrogram.types.User`: On success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/request_callback_answer.py b/pyrogram/methods/bots/request_callback_answer.py index c6987ee4d9..bddba1639e 100644 --- a/pyrogram/methods/bots/request_callback_answer.py +++ b/pyrogram/methods/bots/request_callback_answer.py @@ -62,7 +62,7 @@ async def request_callback_answer( Raises: TimeoutError: In case the bot fails to answer within 10 seconds. ValueError: In case of invalid arguments. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_game.py b/pyrogram/methods/bots/send_game.py index 14f5f23ab3..0633ab0ea8 100644 --- a/pyrogram/methods/bots/send_game.py +++ b/pyrogram/methods/bots/send_game.py @@ -100,7 +100,7 @@ async def send_game( :obj:`~pyrogram.types.Message`: On success, the sent game message is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_inline_bot_result.py b/pyrogram/methods/bots/send_inline_bot_result.py index cf6a5e1ecf..1e00bf6f11 100644 --- a/pyrogram/methods/bots/send_inline_bot_result.py +++ b/pyrogram/methods/bots/send_inline_bot_result.py @@ -84,7 +84,7 @@ async def send_inline_bot_result( :obj:`~pyrogram.types.Message`: On success, the sent message is returned or False if no message was sent. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/send_web_app_custom_request.py b/pyrogram/methods/bots/send_web_app_custom_request.py index 740e4cc005..68b8998478 100644 --- a/pyrogram/methods/bots/send_web_app_custom_request.py +++ b/pyrogram/methods/bots/send_web_app_custom_request.py @@ -48,7 +48,7 @@ async def send_web_app_custom_request( ``str``: On success, a JSON-serialized result is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/set_bot_commands.py b/pyrogram/methods/bots/set_bot_commands.py index 9f0f9a7e07..d5f083f403 100644 --- a/pyrogram/methods/bots/set_bot_commands.py +++ b/pyrogram/methods/bots/set_bot_commands.py @@ -52,7 +52,7 @@ async def set_bot_commands( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_default_privileges.py b/pyrogram/methods/bots/set_bot_default_privileges.py index 129bcbd882..1a3548bdfe 100644 --- a/pyrogram/methods/bots/set_bot_default_privileges.py +++ b/pyrogram/methods/bots/set_bot_default_privileges.py @@ -46,7 +46,7 @@ async def set_bot_default_privileges( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_info_description.py b/pyrogram/methods/bots/set_bot_info_description.py index b696ab2e8b..a59b4090e9 100644 --- a/pyrogram/methods/bots/set_bot_info_description.py +++ b/pyrogram/methods/bots/set_bot_info_description.py @@ -52,7 +52,7 @@ async def set_bot_info_description( ``bool``: True on success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_info_short_description.py b/pyrogram/methods/bots/set_bot_info_short_description.py index fa99f8befa..5661a43354 100644 --- a/pyrogram/methods/bots/set_bot_info_short_description.py +++ b/pyrogram/methods/bots/set_bot_info_short_description.py @@ -52,7 +52,7 @@ async def set_bot_info_short_description( ``bool``: True on success. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/bots/set_bot_name.py b/pyrogram/methods/bots/set_bot_name.py index 81901d65ce..a6195788a6 100644 --- a/pyrogram/methods/bots/set_bot_name.py +++ b/pyrogram/methods/bots/set_bot_name.py @@ -49,7 +49,7 @@ async def set_bot_name( The bot should have ``can_be_edited`` property set to True. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Returns: ``bool``: True on success. diff --git a/pyrogram/methods/bots/set_chat_menu_button.py b/pyrogram/methods/bots/set_chat_menu_button.py index 4db5fadc0c..67bbfe2b7a 100644 --- a/pyrogram/methods/bots/set_chat_menu_button.py +++ b/pyrogram/methods/bots/set_chat_menu_button.py @@ -43,7 +43,7 @@ async def set_chat_menu_button( Defaults to :obj:`~pyrogram.types.MenuButtonDefault`. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/bots/set_game_score.py b/pyrogram/methods/bots/set_game_score.py index 5d5db7c096..4dfbfde392 100644 --- a/pyrogram/methods/bots/set_game_score.py +++ b/pyrogram/methods/bots/set_game_score.py @@ -69,7 +69,7 @@ async def set_game_score( message is returned, True otherwise. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py index 87add6aebe..91ab6a077e 100644 --- a/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py +++ b/pyrogram/methods/chat_topics/toggle_forum_topic_is_pinned.py @@ -46,7 +46,7 @@ async def toggle_forum_topic_is_pinned( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/add_profile_audio.py b/pyrogram/methods/chats/add_profile_audio.py index ffafc291b2..dcff9d7fb3 100644 --- a/pyrogram/methods/chats/add_profile_audio.py +++ b/pyrogram/methods/chats/add_profile_audio.py @@ -40,7 +40,7 @@ async def add_profile_audio( ``bool``: On success, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/set_chat_direct_messages_group.py b/pyrogram/methods/chats/set_chat_direct_messages_group.py index 4f918c76ec..18f250c57e 100644 --- a/pyrogram/methods/chats/set_chat_direct_messages_group.py +++ b/pyrogram/methods/chats/set_chat_direct_messages_group.py @@ -50,7 +50,7 @@ async def set_chat_direct_messages_group( otherwise, in case a message object couldn't be returned, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/chats/set_chat_protected_content.py b/pyrogram/methods/chats/set_chat_protected_content.py index fa83fc1da3..1ac8c7b21a 100644 --- a/pyrogram/methods/chats/set_chat_protected_content.py +++ b/pyrogram/methods/chats/set_chat_protected_content.py @@ -49,7 +49,7 @@ async def set_chat_protected_content( otherwise, in case a message object couldn't be returned, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( @@ -95,7 +95,7 @@ async def process_chat_protected_content_disable_request( otherwise, in case a message object couldn't be returned, True is returned. Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ r = await self.invoke( diff --git a/pyrogram/methods/chats/transfer_chat_ownership.py b/pyrogram/methods/chats/transfer_chat_ownership.py index 511c3b6e2d..be50067f16 100644 --- a/pyrogram/methods/chats/transfer_chat_ownership.py +++ b/pyrogram/methods/chats/transfer_chat_ownership.py @@ -52,7 +52,7 @@ async def transfer_chat_ownership( Raises: ValueError: In case of invalid parameters. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/messages/copy_message.py b/pyrogram/methods/messages/copy_message.py index e86e5e4adf..90b802ebf2 100644 --- a/pyrogram/methods/messages/copy_message.py +++ b/pyrogram/methods/messages/copy_message.py @@ -132,7 +132,7 @@ async def copy_message( Raises: ValueError: In case if an invalid message_id was provided. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: .. code-block:: python diff --git a/pyrogram/methods/messages/download_media.py b/pyrogram/methods/messages/download_media.py index 920029543d..ad9f51ef0d 100644 --- a/pyrogram/methods/messages/download_media.py +++ b/pyrogram/methods/messages/download_media.py @@ -119,7 +119,7 @@ async def download_media( Raises: IndexError: In case of wrong value of ``idx``. ValueError: If the message doesn't contain any downloadable media. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. Example: Download media to file diff --git a/pyrogram/methods/stories/edit_story.py b/pyrogram/methods/stories/edit_story.py index 5e11ba51b3..7947eacc62 100644 --- a/pyrogram/methods/stories/edit_story.py +++ b/pyrogram/methods/stories/edit_story.py @@ -95,7 +95,7 @@ async def edit_story( Raises: ValueError: In case of invalid arguments. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ @@ -256,7 +256,7 @@ async def edit_business_story( Raises: ValueError: In case of invalid arguments. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ if not business_connection_id: diff --git a/pyrogram/methods/stories/hide_my_story_view.py b/pyrogram/methods/stories/hide_my_story_view.py index 32169a7599..69f1b16d9c 100644 --- a/pyrogram/methods/stories/hide_my_story_view.py +++ b/pyrogram/methods/stories/hide_my_story_view.py @@ -49,7 +49,7 @@ async def hide_my_story_view( await app.hide_my_story_view() Raises: - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/methods/stories/post_story.py b/pyrogram/methods/stories/post_story.py index 0061b7182e..a7e7161357 100644 --- a/pyrogram/methods/stories/post_story.py +++ b/pyrogram/methods/stories/post_story.py @@ -124,7 +124,7 @@ async def post_story( Raises: ValueError: In case of invalid arguments. - :doc:`RPCError <../../start/errors>`: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ if business_connection_id: diff --git a/pyrogram/types/authorization/active_session.py b/pyrogram/types/authorization/active_session.py index 7de247e725..fe9092a092 100644 --- a/pyrogram/types/authorization/active_session.py +++ b/pyrogram/types/authorization/active_session.py @@ -174,7 +174,7 @@ async def terminate(self): True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ diff --git a/pyrogram/types/bots_and_keyboards/callback_query.py b/pyrogram/types/bots_and_keyboards/callback_query.py index 05cb7051a5..46db13c200 100644 --- a/pyrogram/types/bots_and_keyboards/callback_query.py +++ b/pyrogram/types/bots_and_keyboards/callback_query.py @@ -239,7 +239,8 @@ async def edit_message_text( message is returned, otherwise True is returned (message sent via the bot, as inline query result). Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: return await self._client.edit_message_text( @@ -294,7 +295,8 @@ async def edit_message_caption( message is returned, otherwise True is returned (message sent via the bot, as inline query result). Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self.edit_message_text( text=caption, @@ -329,7 +331,8 @@ async def edit_message_media( message is returned, otherwise True is returned (message sent via the bot, as inline query result). Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: return await self._client.edit_message_media( @@ -364,7 +367,8 @@ async def edit_message_reply_markup( message is returned, otherwise True is returned (message sent via the bot, as inline query result). Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: return await self._client.edit_message_reply_markup( diff --git a/pyrogram/types/inline_mode/chosen_inline_result.py b/pyrogram/types/inline_mode/chosen_inline_result.py index aa93020eba..b5357e5ade 100644 --- a/pyrogram/types/inline_mode/chosen_inline_result.py +++ b/pyrogram/types/inline_mode/chosen_inline_result.py @@ -128,7 +128,8 @@ async def edit_message_text( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: raise ValueError("Identifier of the inline message is required to edit the message") @@ -171,7 +172,8 @@ async def edit_message_caption( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self.edit_message_text( text=caption, @@ -205,7 +207,8 @@ async def edit_message_media( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: raise ValueError("Identifier of the inline message is required to edit the message") @@ -232,7 +235,8 @@ async def edit_message_reply_markup( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if self.inline_message_id is None: raise ValueError("Identifier of the inline message is required to edit the message") diff --git a/pyrogram/types/input_message_content/external_reply_info.py b/pyrogram/types/input_message_content/external_reply_info.py index cd560d93e2..594867a2ee 100644 --- a/pyrogram/types/input_message_content/external_reply_info.py +++ b/pyrogram/types/input_message_content/external_reply_info.py @@ -433,9 +433,9 @@ async def download( If the message is a :obj:`~pyrogram.types.PaidMediaInfo` with more than one ``paid_media`` containing ``minithumbnail`` and ``idx`` is not specified, then a list of paths or binary file-like objects is returned. Raises: - RPCError: In case of a Telegram RPC error. IndexError: In case of wrong value of ``idx``. ValueError: If the message doesn't contain any downloadable media. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ message = getattr(self, self.media.value, None) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 5a51a7d587..7fa50767a1 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -1740,7 +1740,8 @@ async def reply_text( On success, the sent Message is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( diff --git a/pyrogram/types/messages_and_media/poll.py b/pyrogram/types/messages_and_media/poll.py index 55958913ac..332f283727 100644 --- a/pyrogram/types/messages_and_media/poll.py +++ b/pyrogram/types/messages_and_media/poll.py @@ -271,7 +271,8 @@ async def stop( :obj:`~pyrogram.types.Poll`: On success, the stopped poll with the final results is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.stop_poll( diff --git a/pyrogram/types/stories/story.py b/pyrogram/types/stories/story.py index 043e60e1f0..204655eae6 100644 --- a/pyrogram/types/stories/story.py +++ b/pyrogram/types/stories/story.py @@ -472,7 +472,8 @@ async def react( On success, :obj:`~pyrogram.types.MessageReactions`: is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ sr = None @@ -577,8 +578,9 @@ async def download( Otherwise, in case ``in_memory=True``, a binary file-like object with its attribute ".name" set is returned. Raises: - RPCError: In case of a Telegram RPC error. - ``ValueError``: If the message doesn't contain any downloadable media + ValueError: If the message doesn't contain any downloadable media. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.download_media( message=self, diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py index 37b2314afb..0f06426804 100644 --- a/pyrogram/types/user_and_chats/chat.py +++ b/pyrogram/types/user_and_chats/chat.py @@ -864,7 +864,8 @@ async def archive(self): True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.archive_chats(self.id) @@ -887,7 +888,8 @@ async def unarchive(self): True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.unarchive_chats(self.id) @@ -922,8 +924,9 @@ async def set_title(self, title: str) -> bool: ``bool``: True on success. Raises: - RPCError: In case of Telegram RPC error. ValueError: In case a chat_id belongs to user. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.set_chat_title( @@ -956,8 +959,9 @@ async def set_description(self, description: str) -> bool: ``bool``: True on success. Raises: - RPCError: In case of Telegram RPC error. ValueError: If a chat_id doesn't belong to a supergroup or a channel. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.set_chat_description( @@ -1018,8 +1022,9 @@ async def set_photo( otherwise, in case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPC error. ValueError: if a chat_id belongs to user. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.set_chat_photo( @@ -1105,7 +1110,8 @@ async def ban_member( case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.ban_chat_member( @@ -1144,7 +1150,8 @@ async def unban_member( ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.unban_chat_member( @@ -1196,7 +1203,8 @@ async def restrict_member( :obj:`~pyrogram.types.Chat`: On success, a chat object is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.restrict_chat_member( @@ -1243,7 +1251,8 @@ async def promote_member( ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.promote_chat_member( @@ -1273,7 +1282,8 @@ async def join(self): :obj:`~pyrogram.types.Chat`: On success, a chat object is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.join_chat(self.username or self.id) @@ -1293,7 +1303,8 @@ async def leave(self): await chat.leave() Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.leave_chat(self.id) diff --git a/pyrogram/types/user_and_chats/chat_join_request.py b/pyrogram/types/user_and_chats/chat_join_request.py index 7bc995970a..c03b2fa10c 100644 --- a/pyrogram/types/user_and_chats/chat_join_request.py +++ b/pyrogram/types/user_and_chats/chat_join_request.py @@ -107,7 +107,8 @@ async def approve(self) -> bool: ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.approve_chat_join_request( chat_id=self.chat.id, @@ -135,7 +136,8 @@ async def decline(self) -> bool: ``bool``: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.decline_chat_join_request( chat_id=self.chat.id, diff --git a/pyrogram/types/user_and_chats/user.py b/pyrogram/types/user_and_chats/user.py index ce07c70890..97fed3a6ba 100644 --- a/pyrogram/types/user_and_chats/user.py +++ b/pyrogram/types/user_and_chats/user.py @@ -476,7 +476,8 @@ async def archive(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.archive_chats(self.id) @@ -499,7 +500,8 @@ async def unarchive(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.unarchive_chats(self.id) @@ -522,7 +524,8 @@ async def block(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.block_user(self.id) @@ -545,7 +548,8 @@ async def unblock(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.unblock_user(self.id) @@ -568,7 +572,8 @@ async def get_common_chats(self) -> list["types.Chat"]: List of :obj:`~pyrogram.types.Chat`: On success, a list of the common chats is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.get_common_chats(self.id) From d489638e5a57dc92317821a356f40fa8570d256a Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Mon, 23 Mar 2026 02:35:55 +0100 Subject: [PATCH 19/20] docs --- pyrogram/types/messages_and_media/message.py | 104 ++++++++++++------- 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 7fa50767a1..6ced697547 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -1605,6 +1605,7 @@ def link(self) -> str: if self.chat.is_forum: # If it's a forum but not a specific topic message, it defaults to topic 1 (General) thread_id = self.message_thread_id if self.is_topic_message else 1 + # https://t.me/c/1279877202/31475 return f"https://t.me/{chat_path}/{thread_id}/{self.id}" # 4. Standard message link @@ -1938,7 +1939,8 @@ async def reply_animation( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2125,7 +2127,8 @@ async def reply_audio( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2256,7 +2259,8 @@ async def reply_cached_media( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2338,8 +2342,9 @@ async def reply_chat_action( ``bool``: On success, True is returned. Raises: - RPCError: In case of a Telegram RPC error. ValueError: In case the provided string is not a valid chat action. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.send_chat_action( chat_id=self.chat.id, @@ -2443,7 +2448,8 @@ async def reply_contact( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2619,7 +2625,8 @@ async def reply_document( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2732,7 +2739,8 @@ async def reply_game( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2817,7 +2825,8 @@ async def reply_inline_bot_result( On success, the sent Message is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -2927,7 +2936,8 @@ async def reply_location( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3026,7 +3036,8 @@ async def reply_media_group( List of :obj:`~pyrogram.types.Message`: On success, a list of the sent messages is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3195,7 +3206,8 @@ async def reply_photo( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3389,7 +3401,8 @@ async def reply_poll( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3555,7 +3568,8 @@ async def reply_sticker( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3693,7 +3707,8 @@ async def reply_venue( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -3905,7 +3920,8 @@ async def reply_video( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -4096,7 +4112,8 @@ async def reply_video_note( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -4272,7 +4289,8 @@ async def reply_voice( instead. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -4466,7 +4484,8 @@ async def reply_invoice( On success, the sent :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ reply_to_message_id, reply_parameters = utils._get_reply_to_message_quote_ids( @@ -4564,7 +4583,8 @@ async def edit_text( On success, the edited :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.edit_message_text( chat_id=self.chat.id, @@ -4623,7 +4643,8 @@ async def edit_caption( On success, the edited :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.edit_message_caption( chat_id=self.chat.id, @@ -4673,7 +4694,8 @@ async def edit_media( On success, the edited :obj:`~pyrogram.types.Message` is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.edit_message_media( chat_id=self.chat.id, @@ -4712,7 +4734,8 @@ async def edit_reply_markup(self, reply_markup: "types.InlineKeyboardMarkup" = N :obj:`~pyrogram.types.Message` is returned, otherwise True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.edit_message_reply_markup( chat_id=self.chat.id, @@ -4863,7 +4886,8 @@ async def forward( On success, the forwarded Message is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.forward_messages( from_chat_id=self.chat.id, @@ -4994,8 +5018,8 @@ async def copy( :obj:`~pyrogram.types.Message`: On success, the copied message is returned. Raises: - RPCError: In case of a Telegram RPC error. ValueError: In case if an invalid message was provided. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ if self.service: @@ -5237,7 +5261,8 @@ async def delete(self, revoke: bool = True): ``int``: Amount of affected messages Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.delete_messages( chat_id=self.chat.id, @@ -5325,9 +5350,10 @@ async def click( - A :obj:`~pyrogram.types.User` object in case of a ``KeyboardButtonUserProfile`` button. Raises: - RPCError: In case of a Telegram RPC error. ValueError: In case the provided index or position is out of range or the button label was not found. TimeoutError: In case, after clicking an inline button, the bot fails to answer within the timeout. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ if isinstance(self.reply_markup, types.ReplyKeyboardMarkup): @@ -5509,7 +5535,8 @@ async def react( On success, :obj:`~pyrogram.types.MessageReactions`: is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ sr = None @@ -5572,7 +5599,8 @@ async def retract_vote( :obj:`~pyrogram.types.Poll`: On success, the poll with the retracted vote is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.retract_vote( @@ -5651,9 +5679,9 @@ async def download( If the message is a :obj:`~pyrogram.types.PaidMediaInfo` with more than one ``paid_media`` containing ``minithumbnail`` and ``idx`` is not specified, then a list of paths or binary file-like objects is returned. Raises: - RPCError: In case of a Telegram RPC error. IndexError: In case of wrong value of ``idx``. ValueError: If the message doesn't contain any downloadable media. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self._client.download_media( @@ -5695,7 +5723,8 @@ async def vote( :obj:`~pyrogram.types.Poll`: On success, the poll with the chosen option is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.vote_poll( @@ -5735,7 +5764,8 @@ async def pin(self, disable_notification: bool = False, both_sides: bool = False otherwise, in case a message object couldn't be returned, True is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.pin_chat_message( chat_id=self.chat.id, @@ -5765,7 +5795,8 @@ async def unpin(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.unpin_chat_message( chat_id=self.chat.id, @@ -5854,7 +5885,7 @@ async def read(self) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self._client.read_chat_history( @@ -5887,7 +5918,7 @@ async def view(self, force_read: bool = True) -> bool: True on success. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self._client.view_messages( @@ -5926,7 +5957,7 @@ async def translate( :obj:`~pyrogram.types.TranslatedText`: The translated result is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. """ return await self._client.translate_message_text( @@ -6003,7 +6034,8 @@ async def star( On success, :obj:`~pyrogram.types.MessageReactions`: is returned. Raises: - RPCError: In case of a Telegram RPC error. + :obj:`~pyrogram.errors.RPCError`: In case of a Telegram RPC error. + """ return await self._client.add_paid_message_reaction( chat_id=self.chat.id, From c1ca25bf2a326d09b343c16499cf1f7023d536ed Mon Sep 17 00:00:00 2001 From: shriMADhav U k Date: Thu, 26 Mar 2026 05:55:22 +0100 Subject: [PATCH 20/20] add tests --- tests/parser/test_markdown.py | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/parser/test_markdown.py b/tests/parser/test_markdown.py index 08f10ca34a..70248b01bd 100644 --- a/tests/parser/test_markdown.py +++ b/tests/parser/test_markdown.py @@ -126,6 +126,21 @@ def test_markdown_unparse_pre(): assert Markdown.unparse(text=text, entities=entities) == expected +def test_markdown_unparse_pre_2(): + expected = """```...```""" + + text = """...""" + entities = pyrogram.types.List([ + pyrogram.types.MessageEntity( + type=pyrogram.enums.MessageEntityType.PRE, + offset=0, length=3, + language="" + ) + ]) + + assert Markdown.unparse(text=text, entities=entities) == expected + + def test_markdown_unparse_blockquote(): expected = """>Block quotation started >Block quotation continued @@ -162,6 +177,93 @@ def test_markdown_unparse_mixed(): assert Markdown.unparse(text=text, entities=entities) == expected +def test_markdown_unparse_mixed_2(): + expected = """**bold**, **bold** +__italic__, __italic__ +--underline--, --underline-- +~~strikethrough~~, ~~strikethrough~~, ~~strikethrough~~ +||spoiler||, ||spoiler|| +**bold __italic bold ~~italic bold strikethrough ||italic bold strikethrough spoiler||~~ --underline italic bold--__ bold** +[inline URL](http://www.example.com/) +![👍](tg://emoji?id=5368324170671202286) +![22:45 tomorrow](tg://time?unix=1647531900&format=wDT) +![22:45 tomorrow](tg://time?unix=1647531900&format=t) +![22:45 tomorrow](tg://time?unix=1647531900&format=r) +![22:45 tomorrow](tg://time?unix=1647531900) +`inline fixed-width code` +``` +pre-formatted fixed-width code block``` +```python +pre-formatted fixed-width code block written in the Python programming language``` +>Block quotation started +>Block quotation continued +>The last line of the block quotation +**>Expandable block quotation started +**>Expandable block quotation continued +**>Expandable block quotation continued +**>Hidden by default part of the block quotation started +**>Expandable block quotation continued +**>The last line of the block quotation""" + + text = """bold, bold +italic, italic +underline, underline +strikethrough, strikethrough, strikethrough +spoiler, spoiler +bold italic bold italic bold strikethrough italic bold strikethrough spoiler underline italic bold bold +inline URL +👍 +22:45 tomorrow +22:45 tomorrow +22:45 tomorrow +22:45 tomorrow +inline fixed-width code + +pre-formatted fixed-width code block + +pre-formatted fixed-width code block written in the Python programming language +Block quotation started +Block quotation continued +The last line of the block quotation +Expandable block quotation started +Expandable block quotation continued +Expandable block quotation continued +Hidden by default part of the block quotation started +Expandable block quotation continued +The last line of the block quotation""" + entities = entities = pyrogram.types.List([ + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=0, length=4), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=6, length=4), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=11, length=6), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=19, length=6), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=26, length=9), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=37, length=9), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=47, length=13), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=62, length=13), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=77, length=13), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=91, length=7), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=100, length=7), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BOLD, offset=108, length=103), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.ITALIC, offset=113, length=93), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.STRIKETHROUGH, offset=125, length=59), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.SPOILER, offset=151, length=33), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.UNDERLINE, offset=185, length=21), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.TEXT_LINK, offset=212, length=10, url="http://www.example.com/"), + # TODO + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.DATE_TIME, offset=251, length=14, unix_time=1647531900, date_time_format="wDT"), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.DATE_TIME, offset=266, length=14, unix_time=1647531900, date_time_format="t"), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.DATE_TIME, offset=281, length=14, unix_time=1647531900, date_time_format="r"), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.DATE_TIME, offset=296, length=14, unix_time=1647531900, date_time_format=""), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.CODE, offset=311, length=23), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.PRE, offset=335, length=37, language=""), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.PRE, offset=373, length=80, language="python"), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.BLOCKQUOTE, offset=454, length=86), + pyrogram.types.MessageEntity(type=pyrogram.enums.MessageEntityType.EXPANDABLE_BLOCKQUOTE, offset=541, length=236), + ]) + + assert Markdown.unparse(text=text, entities=entities) == expected + + def test_markdown_unparse_no_entities(): expected = "text" text = "text"