From 1eb4af33df6a1b59f76d78df53a0c50242c7d2e5 Mon Sep 17 00:00:00 2001 From: chrizrobert <35618731+chrizrobert@users.noreply.github.com> Date: Tue, 26 Jun 2018 21:58:55 +0800 Subject: [PATCH] Fix get_entities_text with cls (#866) --- telethon/tl/custom/message.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index a7865736..3af124e4 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -604,16 +604,12 @@ class Message: if not self.original_message.entities: return [] - if cls and self.original_message.entities: - texts = get_inner_text( - self.original_message.message, - [c for c in self.original_message.entities - if isinstance(c, cls)] - ) - else: - texts = get_inner_text(self.original_message.message, - self.original_message.entities) - return list(zip(self.original_message.entities, texts)) + ent = self.original_message.entities + if cls and ent: + ent = [c for c in ent if isinstance(c, cls)] + + texts = get_inner_text(self.original_message.message, ent) + return list(zip(ent, texts)) async def click(self, i=None, j=None, *, text=None, filter=None): """