mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +00:00
Get mention in private chats.
This commit is contained in:
parent
c8349112d0
commit
62417da6a7
1 changed files with 15 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
from aiogram.utils.markdown import hlink, link
|
||||||
from .base import Deserializable
|
from .base import Deserializable
|
||||||
from .chat_photo import ChatPhoto
|
from .chat_photo import ChatPhoto
|
||||||
from ..utils.helper import Helper, HelperMode, Item
|
from ..utils.helper import Helper, HelperMode, Item
|
||||||
|
|
@ -65,6 +66,20 @@ class Chat(Deserializable):
|
||||||
return self.full_name
|
return self.full_name
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_url(self):
|
||||||
|
if self.type != ChatType.PRIVATE:
|
||||||
|
raise TypeError('This property available only in private chats.')
|
||||||
|
|
||||||
|
return f"tg://user?id={self.id}"
|
||||||
|
|
||||||
|
def get_mention(self, name=None, as_html=False):
|
||||||
|
if name is None:
|
||||||
|
name = self.mention
|
||||||
|
if as_html:
|
||||||
|
return hlink(name, self.user_url)
|
||||||
|
return link(name, self.user_url)
|
||||||
|
|
||||||
async def set_photo(self, photo):
|
async def set_photo(self, photo):
|
||||||
return await self.bot.set_chat_photo(self.id, photo)
|
return await self.bot.set_chat_photo(self.id, photo)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue