mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 06:25:12 +01:00
Add Convenience Property Message.id
(#3077)
This commit is contained in:
parent
67869693a7
commit
42955ecddf
3 changed files with 14 additions and 0 deletions
|
@ -105,8 +105,10 @@ The following wonderful people contributed directly or indirectly to this projec
|
||||||
- `Vorobjev Simon <https://github.com/simonvorobjev>`_
|
- `Vorobjev Simon <https://github.com/simonvorobjev>`_
|
||||||
- `Wagner Macedo <https://github.com/wagnerluis1982>`_
|
- `Wagner Macedo <https://github.com/wagnerluis1982>`_
|
||||||
- `wjt <https://github.com/wjt>`_
|
- `wjt <https://github.com/wjt>`_
|
||||||
|
- `Yaw Danso <https://github.com/dglitxh>`_
|
||||||
- `zeroone2numeral2 <https://github.com/zeroone2numeral2>`_
|
- `zeroone2numeral2 <https://github.com/zeroone2numeral2>`_
|
||||||
- `zeshuaro <https://github.com/zeshuaro>`_
|
- `zeshuaro <https://github.com/zeshuaro>`_
|
||||||
- `zpavloudis <https://github.com/zpavloudis>`_
|
- `zpavloudis <https://github.com/zpavloudis>`_
|
||||||
|
|
||||||
|
|
||||||
Please add yourself here alphabetically when you submit your first pull request.
|
Please add yourself here alphabetically when you submit your first pull request.
|
||||||
|
|
|
@ -572,6 +572,15 @@ class Message(TelegramObject):
|
||||||
""":obj:`int`: Shortcut for :attr:`telegram.Chat.id` for :attr:`chat`."""
|
""":obj:`int`: Shortcut for :attr:`telegram.Chat.id` for :attr:`chat`."""
|
||||||
return self.chat.id
|
return self.chat.id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def id(self) -> int: # pylint: disable=invalid-name
|
||||||
|
"""
|
||||||
|
:obj:`int`: Shortcut for :attr:`message_id`.
|
||||||
|
|
||||||
|
.. versionadded:: 20.0
|
||||||
|
"""
|
||||||
|
return self.message_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link(self) -> Optional[str]:
|
def link(self) -> Optional[str]:
|
||||||
""":obj:`str`: Convenience property. If the chat of the message is not
|
""":obj:`str`: Convenience property. If the chat of the message is not
|
||||||
|
|
|
@ -664,6 +664,9 @@ class TestMessage:
|
||||||
def test_chat_id(self, message):
|
def test_chat_id(self, message):
|
||||||
assert message.chat_id == message.chat.id
|
assert message.chat_id == message.chat.id
|
||||||
|
|
||||||
|
def test_id(self, message):
|
||||||
|
assert message.message_id == message.id
|
||||||
|
|
||||||
@pytest.mark.parametrize("type_", argvalues=[Chat.SUPERGROUP, Chat.CHANNEL])
|
@pytest.mark.parametrize("type_", argvalues=[Chat.SUPERGROUP, Chat.CHANNEL])
|
||||||
def test_link_with_username(self, message, type_):
|
def test_link_with_username(self, message, type_):
|
||||||
message.chat.username = "username"
|
message.chat.username = "username"
|
||||||
|
|
Loading…
Reference in a new issue