mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Fix message entity parsing and serialization
This commit is contained in:
parent
f6e0e58f86
commit
ed008dd3bb
@ -159,7 +159,7 @@ class SendMessage:
|
||||
entities=[
|
||||
types.MessageEntity._parse(None, entity, {})
|
||||
for entity in entities
|
||||
],
|
||||
] if entities else None,
|
||||
client=self
|
||||
)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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}"')
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user