From df386b2f91dea56cbf41e8e07e331ad3117cf2db Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 25 Jun 2019 05:53:41 +0200 Subject: [PATCH] Make slicing text messages & captions work properly with entity offsets --- pyrogram/client/types/messages_and_media/message.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 52e8f473..34080d7f 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -31,6 +31,7 @@ from ..object import Object from ..update import Update from ..user_and_chats.chat import Chat from ..user_and_chats.user import User +from ...style import utils class Str(str): @@ -58,6 +59,9 @@ class Str(str): def html(self): return self._client.html.unparse(self, self._entities) + def __getitem__(self, item): + return utils.remove_surrogates(utils.add_surrogates(self)[item]) + class Message(Object, Update): """A message.