mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-07 13:34:59 +03:00
fixing get_entities_text with cls
Currently the entity and text are zipped. If a cls parameter is passed, the text would have been filtered but the entities list would not be filtered, therefore the text would not be correspond with the entity.
This commit is contained in:
parent
9971145721
commit
fe4ee2c5e1
|
@ -617,19 +617,21 @@ class Message:
|
|||
>>> for _, inner_text in m.get_entities_text(MessageEntityCode):
|
||||
>>> print(inner_text)
|
||||
"""
|
||||
entities_list = self.original_message.entities
|
||||
|
||||
if not self.original_message.entities:
|
||||
return []
|
||||
|
||||
if cls and self.original_message.entities:
|
||||
entities_list = [c for c in self.original_message.entities if isinstance(c, cls)]
|
||||
texts = get_inner_text(
|
||||
self.original_message.message,
|
||||
[c for c in self.original_message.entities
|
||||
if isinstance(c, cls)]
|
||||
entities_list
|
||||
)
|
||||
else:
|
||||
texts = get_inner_text(self.original_message.message,
|
||||
texts = get_inner_text(entities_list,
|
||||
self.original_message.entities)
|
||||
return list(zip(self.original_message.entities, texts))
|
||||
return list(zip(entities_list, texts))
|
||||
|
||||
async def click(self, i=None, j=None, *, text=None, filter=None):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user