Skip to content
38 changes: 26 additions & 12 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2158,13 +2158,18 @@ async def send_location(
measured in meters;
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
live_period (:obj:`int`, optional): Period in seconds for which the location will be
updated, should be between 60 and 86400.
updated, should be between
:tg-const:`telegram.constants.LocationLimit.MIN_LIVE_PERIOD` and
:tg-const:`telegram.constants.LocationLimit.MAX_LIVE_PERIOD`.
heading (:obj:`int`, optional): For live locations, a direction in which the user is
moving, in degrees. Must be between 1 and
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
moving, in degrees. Must be between
:tg-const:`telegram.constants.LocationLimit.MIN_HEADING` and
:tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
proximity_alert_radius (:obj:`int`, optional): For live locations, a maximum distance
for proximity alerts about approaching another chat member, in meters. Must be
between 1 and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
between :tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
if specified.
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
receive a notification with no sound.
protect_content (:obj:`bool`, optional): Protects the contents of the sent message from
Expand Down Expand Up @@ -2290,10 +2295,13 @@ async def edit_message_live_location(
location, measured in meters;
0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
heading (:obj:`int`, optional): Direction in which the user is moving, in degrees. Must
be between 1 and :tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
be between :tg-const:`telegram.constants.LocationLimit.MIN_HEADING`
and :tg-const:`telegram.constants.LocationLimit.MAX_HEADING` if specified.
proximity_alert_radius (:obj:`int`, optional): Maximum distance for proximity alerts
about approaching another chat member, in meters. Must be between 1 and
:tg-const:`telegram.constants.LocationLimit.HEADING` if specified.
about approaching another chat member, in meters. Must be between
:tg-const:`telegram.constants.LocationLimit.MIN_PROXIMITY_ALERT_RADIUS`
and :tg-const:`telegram.constants.LocationLimit.MAX_PROXIMITY_ALERT_RADIUS`
if specified.
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): An object for a new
inline keyboard.

Expand Down Expand Up @@ -3082,7 +3090,9 @@ async def get_user_profile_photos(
offset (:obj:`int`, optional): Sequential number of the first photo to be returned.
By default, all photos are returned.
limit (:obj:`int`, optional): Limits the number of photos to be retrieved. Values
between 1-100 are accepted. Defaults to ``100``.
between :tg-const:`telegram.constants.UserProfilePhotosLimit.MIN_LIMIT`-
:tg-const:`telegram.constants.UserProfilePhotosLimit.MAX_LIMIT` are accepted.
Defaults to ``100``.

Keyword Args:
read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to
Expand Down Expand Up @@ -3966,7 +3976,9 @@ async def get_updates(
can be specified to retrieve updates starting from -offset update from the end of
the updates queue. All previous updates will forgotten.
limit (:obj:`int`, optional): Limits the number of updates to be retrieved. Values
between 1-100 are accepted. Defaults to ``100``.
between :tg-const:`telegram.constants.NumberOfUpdatesLimit.MIN_LIMIT`-
:tg-const:`telegram.constants.NumberOfUpdatesLimit.MAX_LIMIT` are accepted.
Defaults to ``100``.
timeout (:obj:`int`, optional): Timeout in seconds for long polling. Defaults to ``0``,
i.e. usual short polling. Should be positive, short polling should be used for
testing purposes only.
Expand Down Expand Up @@ -4087,9 +4099,11 @@ async def set_webhook(
ip_address (:obj:`str`, optional): The fixed IP address which will be used to send
webhook requests instead of the IP address resolved through DNS.
max_connections (:obj:`int`, optional): Maximum allowed number of simultaneous HTTPS
connections to the webhook for update delivery, 1-100. Defaults to ``40``. Use
lower values to limit the load on your bot's server, and higher values to increase
your bot's throughput.
connections to the webhook for update delivery,
:tg-const:`telegram.constants.WebhookLimit.MIN_CONNECTIONS_LIMIT`-
:tg-const:`telegram.constants.WebhookLimit.MAX_CONNECTIONS_LIMIT`.
Defaults to ``40``. Use lower values to limit the load on your bot's server,
and higher values to increase your bot's throughput.
allowed_updates (List[:obj:`str`], optional): A list the types of
updates you want your bot to receive. For example, specify ["message",
"edited_channel_post", "callback_query"] to only receive updates of these types.
Expand Down
4 changes: 3 additions & 1 deletion telegram/_files/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Location(TelegramObject):
live_period (:obj:`int`, optional): Time relative to the message sending date, during which
the location can be updated, in seconds. For active live locations only.
heading (:obj:`int`, optional): The direction in which user is moving, in degrees;
1-:tg-const:`telegram.constants.LocationLimit.HEADING`. For active live locations only.
:tg-const:`telegram.constants.LocationLimit.MIN_HEADING`-
:tg-const:`telegram.constants.LocationLimit.MAX_HEADING`.
For active live locations only.
proximity_alert_radius (:obj:`int`, optional): Maximum distance for proximity alerts about
approaching another chat member, in meters. For sent live locations only.

Expand Down
136 changes: 123 additions & 13 deletions telegram/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
"MessageEntityType",
"MessageLimit",
"MessageType",
"NumberOfUpdatesLimit",
"ParseMode",
"PollLimit",
"PollType",
"SUPPORTED_WEBHOOK_PORTS",
"StickerType",
"WebhookLimit",
"UpdateType",
"UserProfilePhotosLimit",
]

import sys
Expand Down Expand Up @@ -486,24 +488,75 @@ class InlineQueryResultType(StringEnum):

class LocationLimit(IntEnum):
"""This enum contains limitations for :class:`telegram.Location`/
:meth:`telegram.Bot.send_location`. The enum members of this enumeration are instances
of :class:`int` and can be treated as such.
:meth:`telegram.Bot.edit_message_live_location`/:meth:`telegram.Bot.send_location`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
"""

__slots__ = ()

HORIZONTAL_ACCURACY = 1500
""":obj:`int`: Maximum radius of uncertainty for the location, measured in meters."""
""":obj:`int`: Maximum value allowed for:

* :paramref:`~telegram.Location.horizontal_accuracy` parameter of :class:`telegram.Location`
* :paramref:`~telegram.Bot.edit_message_live_location.horizontal_accuracy` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.horizontal_accuracy` parameter of
:meth:`telegram.Bot.send_location`
"""

MIN_HEADING = 1
""":obj:`int`: Minimum value allowed for:

* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.heading` parameter of
:meth:`telegram.Bot.send_location`
"""
MAX_HEADING = 360
""":obj:`int`: Maximum value allowed for:

* :paramref:`~telegram.Location.heading` parameter of :class:`telegram.Location`
* :paramref:`~telegram.Bot.edit_message_live_location.heading` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.heading` parameter of
:meth:`telegram.Bot.send_location`
"""

MIN_LIVE_PERIOD = 60
""":obj:`int`: Minimum value allowed for:

* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
:meth:`telegram.Bot.send_location`
"""
MAX_LIVE_PERIOD = 86400
""":obj:`int`: Maximum value allowed for:

* :paramref:`~telegram.Bot.edit_message_live_location.live_period` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.live_period` parameter of
:meth:`telegram.Bot.send_location`
"""

HEADING = 360
""":obj:`int`: Maximum value allowed for the direction in which the user is moving,
in degrees.
MIN_PROXIMITY_ALERT_RADIUS = 1
""":obj:`int`: Minimum value allowed for:

* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.send_location`
"""
PROXIMITY_ALERT_RADIUS = 100000
""":obj:`int`: Maximum distance for proximity alerts about approaching another chat member, in
meters.
MAX_PROXIMITY_ALERT_RADIUS = 100000
""":obj:`int`: Maximum value allowed for:

* :paramref:`~telegram.Bot.edit_message_live_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.edit_message_live_location`
* :paramref:`~telegram.Bot.send_location.proximity_alert_radius` parameter of
:meth:`telegram.Bot.send_location`
"""


Expand Down Expand Up @@ -753,6 +806,25 @@ class MessageType(StringEnum):
""":obj:`str`: Messages with :attr:`telegram.Message.video_chat_participants_invited`."""


class NumberOfUpdatesLimit(IntEnum):
"""This enum contains limitations for :paramref:`telegram.Bot.get_updates.limit`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
"""

__slots__ = ()

MIN_LIMIT = 1
""":obj:`int`: Minimum value allowed for the :paramref:`~telegram.Bot.get_updates.limit`
parameter of :meth:`telegram.Bot.get_updates`.
"""
MAX_LIMIT = 100
""":obj:`int`: Maximum value allowed for the :paramref:`~telegram.Bot.get_updates.limit`
parameter of :meth:`telegram.Bot.get_updates`.
"""


class StickerType(StringEnum):
"""This enum contains the available types of :class:`telegram.Sticker`. The enum
members of this enumeration are instances of :class:`str` and can be treated as such.
Expand Down Expand Up @@ -888,16 +960,54 @@ class InvoiceLimit(IntEnum):
""":obj:`int`: Maximum amount of bytes for the internal payload."""


class UserProfilePhotosLimit(IntEnum):
"""This enum contains limitations for :paramref:`telegram.Bot.get_user_profile_photos.limit`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
"""

__slots__ = ()

MIN_LIMIT = 1
""":obj:`int`: Minimum value allowed for
:paramref:`~telegram.Bot.get_user_profile_photos.limit` parameter of
:meth:`telegram.Bot.get_user_profile_photos`.
"""
MAX_LIMIT = 100
""":obj:`int`: Maximum value allowed for
:paramref:`~telegram.Bot.get_user_profile_photos.limit` parameter of
:meth:`telegram.Bot.get_user_profile_photos`.
"""


class WebhookLimit(IntEnum):
"""This enum contains limitations for :paramref:`telegram.Bot.set_webhook.secret_token`. The
enum members of this enumeration are instances of :class:`int` and can be treated as such.
"""This enum contains limitations for :paramref:`telegram.Bot.set_webhook.max_connections` and
:paramref:`telegram.Bot.set_webhook.secret_token`. The enum members of this enumeration are
instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
"""

__slots__ = ()

MIN_CONNECTIONS_LIMIT = 1
""":obj:`int`: Minimum value allowed for the
:paramref:`~telegram.Bot.set_webhook.max_connections` parameter of
:meth:`telegram.Bot.set_webhook`.
"""
MAX_CONNECTIONS_LIMIT = 100
""":obj:`int`: Maximum value allowed for the
:paramref:`~telegram.Bot.set_webhook.max_connections` parameter of
:meth:`telegram.Bot.set_webhook`.
"""
MIN_SECRET_TOKEN_LENGTH = 1
""":obj:`int`: Minimum length of the secret token."""
""":obj:`int`: Minimum length of the secret token
(:paramref:`~telegram.Bot.set_webhook.secret_token` parameter of
:meth:`telegram.Bot.set_webhook`).
"""
MAX_SECRET_TOKEN_LENGTH = 256
""":obj:`int`: Maximum length of the secret token."""
""":obj:`int`: Maximum length of the secret token
(:paramref:`~telegram.Bot.set_webhook.secret_token` parameter of
:meth:`telegram.Bot.set_webhook`).
"""