- Notifications
You must be signed in to change notification settings - Fork5.7k
refactor: add enum constants#3336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Closed
lemontree210 wants to merge8 commits intopython-telegram-bot:masterfromlemontree210:enums-instead-of-literals-3107
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
51023c9
refactor(Bot) add enum constants for `Bot.set_webhook()`
lemontree21038c7e75
refactor(Bot) add enum constants for `limit` in `Bot.get_updates()`
lemontree2102014f32
refactor/fix(Bot) add enum constants to `LocationLimit`, fix docstrings
lemontree210a167414
refactor(Bot) add enum constants for live_period to `LocationLimit`
lemontree210e2bd7f5
refactor(constants) `paramref`s to constant docstr's (webhook, updates)
lemontree21089e5b98
fix(constants) ref from constants to params (Location, send_location)
lemontree2106b1ba23
fix(constants) ref from constants to `Bot.edit_message_live_location()`
lemontree2109f3c3ca
refactor(Bot.get_user_profile_photos) add constants for `limit`
lemontree210File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
38 changes: 26 additions & 12 deletionstelegram/_bot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletiontelegram/_files/location.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
136 changes: 123 additions & 13 deletionstelegram/constants.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -57,13 +57,15 @@ | ||
"MessageEntityType", | ||
"MessageLimit", | ||
"MessageType", | ||
"NumberOfUpdatesLimit", | ||
"ParseMode", | ||
"PollLimit", | ||
"PollType", | ||
"SUPPORTED_WEBHOOK_PORTS", | ||
"StickerType", | ||
"WebhookLimit", | ||
"UpdateType", | ||
"UserProfilePhotosLimit", | ||
] | ||
import sys | ||
@@ -486,24 +488,75 @@ class InlineQueryResultType(StringEnum): | ||
class LocationLimit(IntEnum): | ||
"""This enum contains limitations for :class:`telegram.Location`/ | ||
:meth:`telegram.Bot.edit_message_live_location`/:meth:`telegram.Bot.send_location`. | ||
The enum members of this enumeration are instancesof :class:`int` and can be treated as such. | ||
.. versionadded:: 20.0 | ||
""" | ||
__slots__ = () | ||
HORIZONTAL_ACCURACY = 1500 | ||
""":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` | ||
""" | ||
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` | ||
""" | ||
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` | ||
""" | ||
@@ -753,6 +806,25 @@ class MessageType(StringEnum): | ||
""":obj:`str`: Messages with :attr:`telegram.Message.video_chat_participants_invited`.""" | ||
class NumberOfUpdatesLimit(IntEnum): | ||
lemontree210 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
"""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. | ||
@@ -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.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 | ||
(: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 | ||
(:paramref:`~telegram.Bot.set_webhook.secret_token` parameter of | ||
:meth:`telegram.Bot.set_webhook`). | ||
""" |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.