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:
chrizrobert 2018-06-26 18:37:28 +08:00 committed by GitHub
parent 9971145721
commit fe4ee2c5e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):
"""