From b3a13ab6b5cea428fd0362f83edefd172c10ec0e Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Fri, 19 May 2017 23:22:29 +0300 Subject: [PATCH] Update Chat. Add full_name and mention --- aiogram/types/chat.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/aiogram/types/chat.py b/aiogram/types/chat.py index 69962f37..6396f154 100644 --- a/aiogram/types/chat.py +++ b/aiogram/types/chat.py @@ -43,6 +43,23 @@ class Chat(Deserializable): async def send_message(self, text): self.bot.send_message(self.id, text) + @property + def full_name(self): + if self.type == ChatType.PRIVATE: + full_name = self.first_name + if self.last_name: + full_name += ' ' + self.last_name + return full_name + return self.title + + @property + def mention(self): + if self.username: + return '@' + self.username + if self.type == ChatType.PRIVATE: + return self.full_name + return None + class ChatType: PRIVATE = 'private'