diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py index 0a7ab6d1..b365880e 100644 --- a/pyrogram/methods/messages/send_message.py +++ b/pyrogram/methods/messages/send_message.py @@ -159,7 +159,7 @@ class SendMessage: entities=[ types.MessageEntity._parse(None, entity, {}) for entity in entities - ], + ] if entities else None, client=self ) diff --git a/pyrogram/methods/messages/send_poll.py b/pyrogram/methods/messages/send_poll.py index c5b606f1..207cff9f 100644 --- a/pyrogram/methods/messages/send_poll.py +++ b/pyrogram/methods/messages/send_poll.py @@ -155,7 +155,7 @@ class SendPoll: ), correct_answers=[bytes([correct_option_id])] if correct_option_id is not None else None, solution=solution, - solution_entities=solution_entities + solution_entities=solution_entities or [] ), message="", silent=disable_notification, diff --git a/pyrogram/parser/html.py b/pyrogram/parser/html.py index 29c8c4a6..dee8a49d 100644 --- a/pyrogram/parser/html.py +++ b/pyrogram/parser/html.py @@ -149,7 +149,7 @@ class HTML: return { "message": utils.remove_surrogates(parser.text), - "entities": sorted(entities, key=lambda e: e.offset) + "entities": sorted(entities, key=lambda e: e.offset) or None } @staticmethod diff --git a/pyrogram/parser/parser.py b/pyrogram/parser/parser.py index 16701b39..0ce2b237 100644 --- a/pyrogram/parser/parser.py +++ b/pyrogram/parser/parser.py @@ -49,7 +49,7 @@ class Parser: return await self.html.parse(text) if mode == enums.ParseMode.DISABLED: - return {"message": text, "entities": []} + return {"message": text, "entities": None} raise ValueError(f'Invalid parse mode "{mode}"') diff --git a/pyrogram/types/authorization/terms_of_service.py b/pyrogram/types/authorization/terms_of_service.py index 7e1376ea..3c5ffa6c 100644 --- a/pyrogram/types/authorization/terms_of_service.py +++ b/pyrogram/types/authorization/terms_of_service.py @@ -52,5 +52,5 @@ class TermsOfService(Object): entities=[ types.MessageEntity._parse(None, entity, {}) for entity in terms_of_service.entities - ] + ] if terms_of_service.entities else None ) diff --git a/pyrogram/utils.py b/pyrogram/utils.py index b6a8d6bf..f7fe5970 100644 --- a/pyrogram/utils.py +++ b/pyrogram/utils.py @@ -349,7 +349,7 @@ async def parse_text_entities( for entity in entities: entity._client = client - text, entities = text, [await entity.write() for entity in entities] + text, entities = text, [await entity.write() for entity in entities] or None else: text, entities = (await client.parser.parse(text, parse_mode)).values()