diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index f47e8c42..248c4c0a 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +import html + import pyrogram from pyrogram.api import types from .chat_photo import ChatPhoto @@ -134,6 +136,12 @@ class User(Object): self.photo = photo self.restriction_reason = restriction_reason + def __format__(self, format_spec): + if format_spec == "mention": + return '{1}'.format(self.id, html.escape(self.first_name)) + + return html.escape(str(self)) + @staticmethod def _parse(client, user: types.User) -> "User" or None: if user is None: