mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Add link
property to Bot
(#1770)
* added link property to bot link property was available in User and Chat objects but not in Bot which was inconsistent. * added 'link' property to Bot object Bot will always have username so it does not require hasattr check * add tests Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
This commit is contained in:
parent
13a641b3d7
commit
28ded6718e
2 changed files with 8 additions and 0 deletions
|
@ -223,6 +223,13 @@ class Bot(TelegramObject):
|
|||
|
||||
return self.bot.username
|
||||
|
||||
@property
|
||||
@info
|
||||
def link(self):
|
||||
""":obj:`str`: Convenience property. Returns the t.me link of the bot."""
|
||||
|
||||
return "https://t.me/{}".format(self.username)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""":obj:`str`: Bot's @username."""
|
||||
|
|
|
@ -87,6 +87,7 @@ class TestBot(object):
|
|||
assert get_me_bot.first_name == bot.first_name
|
||||
assert get_me_bot.last_name == bot.last_name
|
||||
assert get_me_bot.name == bot.name
|
||||
assert 'https://t.me/{}'.format(get_me_bot.username) == bot.link
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.timeout(10)
|
||||
|
|
Loading…
Reference in a new issue