Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: add enum constants#3351

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

Merged
Bibo-Joshi merged 50 commits intomasterfromenums-instead-of-literals-3107
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
50 commits
Select commitHold shift + click to select a range
51023c9
refactor(Bot) add enum constants for `Bot.set_webhook()`
lemontree210Nov 5, 2022
38c7e75
refactor(Bot) add enum constants for `limit` in `Bot.get_updates()`
lemontree210Nov 5, 2022
2014f32
refactor/fix(Bot) add enum constants to `LocationLimit`, fix docstrings
lemontree210Nov 5, 2022
a167414
refactor(Bot) add enum constants for live_period to `LocationLimit`
lemontree210Nov 5, 2022
e2bd7f5
refactor(constants) `paramref`s to constant docstr's (webhook, updates)
lemontree210Nov 5, 2022
89e5b98
fix(constants) ref from constants to params (Location, send_location)
lemontree210Nov 5, 2022
6b1ba23
fix(constants) ref from constants to `Bot.edit_message_live_location()`
lemontree210Nov 5, 2022
9f3c3ca
refactor(Bot.get_user_profile_photos) add constants for `limit`
lemontree210Nov 5, 2022
9de4b44
Merge remote-tracking branch 'origin/master' into enums-instead-of-li…
lemontree210Nov 8, 2022
fcf6e57
refactor: NumberOfUpdatesLimit -> PollingLimit
lemontree210Nov 8, 2022
7c4adcd
fix add links to/from 2 classes and `constants.LocationLimit`
lemontree210Nov 8, 2022
8a74b47
feat: add `ReplyKeyboardMarkupLimit`
lemontree210Nov 8, 2022
5667254
add `:member-order: bysource` to `.rst` file for `constants.py`
lemontree210Nov 8, 2022
32d459f
Merge remote-tracking branch 'origin/master' into enums-instead-of-li…
lemontree210Nov 9, 2022
9fda7a7
feat: new class `DiceLimit`
lemontree210Nov 9, 2022
dbbbc9a
refactor(`Dice`) replace emojis with links to constants in "Note:"
lemontree210Nov 9, 2022
cbe20e6
fix(Dice) create constants in class, link them to `constants.py`
lemontree210Nov 9, 2022
f1e0e4a
fix(`Location` etc) create constants in classes, link to `constants.py`
lemontree210Nov 9, 2022
69e9444
fix(`ReplyKeyboardMarkup`) create constants in class, fix typo
lemontree210Nov 9, 2022
93f5499
remove `bysource` sorting for `Dice`
lemontree210Nov 9, 2022
b90fbfb
remove `bysource` sorting for `constants.py`
lemontree210Nov 10, 2022
8b4ba19
refactor: split max limit constants for different emojis
lemontree210Nov 10, 2022
6391658
refactor: link constants in `send_emoji` to `Dice`, not `constants.py`
lemontree210Nov 10, 2022
82c183d
minor(`constants.WebhookLimit`) remove parentheses
lemontree210Nov 11, 2022
acc8296
feat: add constants for `InlineKeyboardButton` (`callback_data`)
lemontree210Nov 13, 2022
9cd8d59
feat(constants): extend cls for `input_field_placeholder` to `ForceRe…
lemontree210Nov 13, 2022
3ddceec
feat(Bot, ChatInviteLink): add min value for `member_limit`
lemontree210Nov 13, 2022
249c5b9
feat(ChatLocation) add limits for `address` to `LocationLimit`
lemontree210Nov 13, 2022
41df2b2
add sizes for `ChatPhoto`
lemontree210Nov 13, 2022
2677041
add limits for `BotCommand`
lemontree210Nov 13, 2022
f3debaa
add limit for voice notes in `Bot.send_voice`
lemontree210Nov 14, 2022
e630f57
Merge branch 'master' into enums-instead-of-literals-3107
Bibo-JoshiNov 15, 2022
e6efa22
add limit for `vCard` in `Bot.send_contact`
lemontree210Nov 15, 2022
3485d6b
add limits for `Poll`, `PollOption` and `Bot.send_poll()`
lemontree210Nov 15, 2022
1c1e906
add limit for `Bot.set_chat_administrator_custom_title()`
lemontree210Nov 19, 2022
0eca47c
add limit for `Bot.set_chat_title()`
lemontree210Nov 19, 2022
5850221
add `ChatDescriptionLimit`, fix constants in `TitleLimit`
lemontree210Nov 20, 2022
24dc038
add limit for `commands` param of `Bot.set_my_commands()`
lemontree210Nov 20, 2022
687dd53
`TEXT_LENGTH` -> `MAX_TEXT_LENGTH`, add `MIN_TEXT_LENGTH`
lemontree210Nov 20, 2022
26eb73a
add `StickerLimit` for `Bot.create_new_sticker_set()`
lemontree210Nov 20, 2022
72473e3
add constants to `InlineQueryLimit` (and `InlineQuery`)
lemontree210Nov 21, 2022
2235c84
add `InlineQueryResultLimit` for `InlineQueryResult` and subclasses
lemontree210Nov 21, 2022
61d297f
`SendContactLimit` -> `ContactLimit`, add links from 2 classes
lemontree210Nov 21, 2022
cb42bf1
add limit for `InlineQuery.query` to `InlineQueryLimit`
lemontree210Nov 21, 2022
3df54ee
add `.. versionadded:: 20.0` to constants in "target" classes
lemontree210Nov 21, 2022
07d59ca
add references to attributes
lemontree210Nov 21, 2022
390da52
`constants.py`: "length of"->"number of" +"characters"/"bytes"
lemontree210Nov 21, 2022
6f78556
Merge remote-tracking branch 'origin/master' into enums-instead-of-li…
lemontree210Nov 21, 2022
50848bb
Merge branch 'master' into enums-instead-of-literals-3107
Bibo-JoshiNov 22, 2022
44a51fb
Drop TitleLimit in favor of ChatLimit
Bibo-JoshiNov 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletiondocs/source/conf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -295,7 +295,7 @@ class TGConstXRefRole(PyXRefRole):

Example:

:tg-const:`telegram.constants.MessageLimit.TEXT_LENGTH` renders as `4096` but links to the
:tg-const:`telegram.constants.MessageLimit.MAX_TEXT_LENGTH` renders as `4096` but links to the
constant.
"""

Expand Down
2 changes: 1 addition & 1 deletiondocs/source/telegram.dice.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,4 +3,4 @@ telegram.Dice

.. autoclass:: telegram.Dice
:members:
:show-inheritance:
:show-inheritance:
132 changes: 85 additions & 47 deletionstelegram/_bot.py
View file
Open in desktop

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletionstelegram/_botcommand.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,9 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Bot Command."""

from typing import ClassVar

from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict

Expand All@@ -30,9 +33,12 @@ class BotCommand(TelegramObject):
considered equal, if their :attr:`command` and :attr:`description` are equal.

Args:
command (:obj:`str`): Text of the command; 1-32 characters. Can contain only lowercase
command (:obj:`str`): Text of the command; :tg-const:`telegram.BotCommand.MIN_COMMAND`-
:tg-const:`telegram.BotCommand.MAX_COMMAND` characters. Can contain only lowercase
English letters, digits and underscores.
description (:obj:`str`): Description of the command; 1-256 characters.
description (:obj:`str`): Description of the command;
:tg-const:`telegram.BotCommand.MIN_DESCRIPTION`-
:tg-const:`telegram.BotCommand.MAX_DESCRIPTION` characters.

Attributes:
command (:obj:`str`): Text of the command.
Expand All@@ -48,3 +54,24 @@ def __init__(self, command: str, description: str, *, api_kwargs: JSONDict = Non
self.description = description

self._id_attrs = (self.command, self.description)

MIN_COMMAND: ClassVar[int] = constants.BotCommandLimit.MIN_COMMAND
""":const:`telegram.constants.BotCommandLimit.MIN_COMMAND`

.. versionadded:: 20.0
"""
MAX_COMMAND: ClassVar[int] = constants.BotCommandLimit.MAX_COMMAND
""":const:`telegram.constants.BotCommandLimit.MAX_COMMAND`

.. versionadded:: 20.0
"""
MIN_DESCRIPTION: ClassVar[int] = constants.BotCommandLimit.MIN_DESCRIPTION
""":const:`telegram.constants.BotCommandLimit.MIN_DESCRIPTION`

.. versionadded:: 20.0
"""
MAX_DESCRIPTION: ClassVar[int] = constants.BotCommandLimit.MAX_DESCRIPTION
""":const:`telegram.constants.BotCommandLimit.MAX_DESCRIPTION`

.. versionadded:: 20.0
"""
7 changes: 5 additions & 2 deletionstelegram/_chatinvitelink.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,7 +56,8 @@ class ChatInviteLink(TelegramObject):
has been expired.
member_limit (:obj:`int`, optional): Maximum number of users that can be members of the
chat simultaneously after joining the chat via this invite link;
1-:tg-const:`telegram.constants.ChatInviteLinkLimit.MEMBER_LIMIT`.
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
name (:obj:`str`, optional): Invite link name.
0-:tg-const:`telegram.constants.ChatInviteLinkLimit.NAME_LENGTH` characters.

Expand All@@ -78,7 +79,9 @@ class ChatInviteLink(TelegramObject):
expire_date (:class:`datetime.datetime`): Optional. Date when the link will expire or
has been expired.
member_limit (:obj:`int`): Optional. Maximum number of users that can be members
of the chat simultaneously after joining the chat via this invite link; 1-99999.
of the chat simultaneously after joining the chat via this invite link;
:tg-const:`telegram.constants.ChatInviteLinkLimit.MIN_MEMBER_LIMIT`-
:tg-const:`telegram.constants.ChatInviteLinkLimit.MAX_MEMBER_LIMIT`.
name (:obj:`str`): Optional. Invite link name.

.. versionadded:: 13.8
Expand Down
18 changes: 16 additions & 2 deletionstelegram/_chatlocation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,9 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a location to which a chat is connected."""

from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING,ClassVar,Optional

from telegram import constants
from telegram._files.location import Location
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
Expand All@@ -37,7 +38,9 @@ class ChatLocation(TelegramObject):
Args:
location (:class:`telegram.Location`): The location to which the supergroup is connected.
Can't be a live location.
address (:obj:`str`): Location address; 1-64 characters, as defined by the chat owner
address (:obj:`str`): Location address;
:tg-const:`telegram.ChatLocation.MIN_ADDRESS`-
:tg-const:`telegram.ChatLocation.MAX_ADDRESS` characters, as defined by the chat owner
Attributes:
location (:class:`telegram.Location`): The location to which the supergroup is connected.
address (:obj:`str`): Location address, as defined by the chat owner
Expand DownExpand Up@@ -70,3 +73,14 @@ def de_json(cls, data: Optional[JSONDict], bot: "Bot") -> Optional["ChatLocation
data["location"] = Location.de_json(data.get("location"), bot)

return super().de_json(data=data, bot=bot)

MIN_ADDRESS: ClassVar[int] = constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS
""":const:`telegram.constants.LocationLimit.MIN_CHAT_LOCATION_ADDRESS`

.. versionadded:: 20.0
"""
MAX_ADDRESS: ClassVar[int] = constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS
""":const:`telegram.constants.LocationLimit.MAX_CHAT_LOCATION_ADDRESS`

.. versionadded:: 20.0
"""
85 changes: 70 additions & 15 deletionstelegram/_dice.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,30 +34,43 @@ class Dice(TelegramObject):
considered equal, if their :attr:`value` and :attr:`emoji` are equal.

Note:
If :attr:`emoji` is"🎯", a value of 6 currently represents a bullseye, while a value of 1
indicates that the dartboard was missed. However, this behaviour is undocumented and might
be changed by Telegram.
If :attr:`emoji` is:tg-const:`telegram.Dice.DARTS`, a value of 6 currently
represents a bullseye, while a value of 1 indicates that the dartboard was missed.
However, this behaviour is undocumented and mightbe changed by Telegram.

If :attr:`emoji` is"🏀", a value of 4 or 5 currently score a basket, while a value of 1 to
3 indicates that the basket was missed. However, this behaviour is undocumented and might
be changed by Telegram.
If :attr:`emoji` is:tg-const:`telegram.Dice.BASKETBALL`, a value of 4 or 5
currently score a basket, while a value of 1 to3 indicates that the basket was missed.
However, this behaviour is undocumented and mightbe changed by Telegram.

If :attr:`emoji` is"⚽", a value of 4 to 5 currently scores a goal, while a value of 1 to
3 indicates that the goal was missed. However, this behaviour is undocumented and might
be changed by Telegram.
If :attr:`emoji` is:tg-const:`telegram.Dice.FOOTBALL`, a value of 4 to 5
currently scores a goal, while a value of 1 to3 indicates that the goal was missed.
However, this behaviour is undocumented and mightbe changed by Telegram.

If :attr:`emoji` is"🎳", a value of 6 knocks all the pins, while a value of 1 means all
the pins were missed. However, this behaviour is undocumented and might be changed by
Telegram.
If :attr:`emoji` is:tg-const:`telegram.Dice.BOWLING`, a value of 6 knocks
allthe pins, while a value of 1 means all the pins were missed.
However, this behaviour is undocumented and might be changed byTelegram.

If :attr:`emoji` is "🎰", each value corresponds to a unique combination of symbols, which
If :attr:`emoji` is :tg-const:`telegram.Dice.SLOT_MACHINE`, each value
corresponds to a unique combination of symbols, which
can be found at our `wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki\
/Code-snippets#map-a-slot-machine-dice-value-to-the-corresponding-symbols>`_.
However, this behaviour is undocumented and might be changed by Telegram.

..
In args, some links for limits of `value` intentionally point to constants for only
one emoji of a group to avoid duplication. For example, maximum value for Dice, Darts and
Bowling is linked to a constant for Bowling.

Args:
value (:obj:`int`): Value of the dice. 1-6 for dice, darts and bowling balls, 1-5 for
basketball and football/soccer ball, 1-64 for slot machine.
value (:obj:`int`): Value of the dice.
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BOWLING`
for :tg-const:`telegram.Dice.DICE`, :tg-const:`telegram.Dice.DARTS` and
:tg-const:`telegram.Dice.BOWLING` base emoji,
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_BASKETBALL`
for :tg-const:`telegram.Dice.BASKETBALL` and :tg-const:`telegram.Dice.FOOTBALL`
base emoji,
:tg-const:`telegram.Dice.MIN_VALUE`-:tg-const:`telegram.Dice.MAX_VALUE_SLOT_MACHINE`
for :tg-const:`telegram.Dice.SLOT_MACHINE` base emoji.
emoji (:obj:`str`): Emoji on which the dice throw animation is based.

Attributes:
Expand DownExpand Up@@ -93,3 +106,45 @@ def __init__(self, value: int, emoji: str, *, api_kwargs: JSONDict = None):
"""
Copy link
MemberAuthor

@lemontree210lemontree210Nov 21, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This comment is about the lines above this one. I didn't add any.. versionadded to class constants that I didn't create, though I think this needs to be done. I also think that the version marking in the line immediately above this one (forBOWLING) might be wrong: a bowling emoji was added in 13.4, but the constant itself is being introduced in 20.0. So maybe all constants referring toDiceEmoji should also get the20.0 marking.

(Since I wasn't changing those lines, I couldn't add a comment to them directly)

ALL_EMOJI: ClassVar[List[str]] = list(constants.DiceEmoji)
"""List[:obj:`str`]: A list of all available dice emoji."""

MIN_VALUE: ClassVar[int] = constants.DiceLimit.MIN_VALUE
""":const:`telegram.constants.DiceLimit.MIN_VALUE`

.. versionadded:: 20.0
"""

MAX_VALUE_BOWLING: ClassVar[int] = constants.DiceLimit.MAX_VALUE_BOWLING
""":const:`telegram.constants.DiceLimit.MAX_VALUE_BOWLING`

.. versionadded:: 20.0
"""

MAX_VALUE_DARTS: ClassVar[int] = constants.DiceLimit.MAX_VALUE_DARTS
""":const:`telegram.constants.DiceLimit.MAX_VALUE_DARTS`

.. versionadded:: 20.0
"""

MAX_VALUE_DICE: ClassVar[int] = constants.DiceLimit.MAX_VALUE_DICE
""":const:`telegram.constants.DiceLimit.MAX_VALUE_DICE`

.. versionadded:: 20.0
"""

MAX_VALUE_BASKETBALL: ClassVar[int] = constants.DiceLimit.MAX_VALUE_BASKETBALL
""":const:`telegram.constants.DiceLimit.MAX_VALUE_BASKETBALL`

.. versionadded:: 20.0
"""

MAX_VALUE_FOOTBALL: ClassVar[int] = constants.DiceLimit.MAX_VALUE_FOOTBALL
""":const:`telegram.constants.DiceLimit.MAX_VALUE_FOOTBALL`

.. versionadded:: 20.0
"""

MAX_VALUE_SLOT_MACHINE: ClassVar[int] = constants.DiceLimit.MAX_VALUE_SLOT_MACHINE
""":const:`telegram.constants.DiceLimit.MAX_VALUE_SLOT_MACHINE`

.. versionadded:: 20.0
"""
63 changes: 43 additions & 20 deletionstelegram/_files/chatphoto.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,9 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram ChatPhoto."""
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, ClassVar

from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._utils.defaultvalue import DEFAULT_NONE
from telegram._utils.types import JSONDict, ODVInput
Expand All@@ -35,30 +36,39 @@ class ChatPhoto(TelegramObject):
equal.

Args:
small_file_id (:obj:`str`): Unique file identifier of small (160x160) chat photo. This
file_id can be used only for photo download and only for as long
small_file_id (:obj:`str`): Unique file identifier of small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
chat photo. This file_id can be used only for photo download and only for as long
as the photo is not changed.
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
which is supposed to be the same over time and for different bots.
small_file_unique_id (:obj:`str`): Unique file identifier of small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
chat photo, which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
big_file_id (:obj:`str`): Unique file identifier of big (640x640) chat photo. This file_id
can be used only for photo download and only for as long as the photo is not changed.
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
which is supposed to be the same over time and for different bots.
big_file_id (:obj:`str`): Unique file identifier of big
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
chat photo. This file_id can be used only for photo download and only for as long as
the photo is not changed.
big_file_unique_id (:obj:`str`): Unique file identifier of big
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
chat photo, which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.

Attributes:
small_file_id (:obj:`str`): File identifier of small (160x160) chat photo.
This file_id can be used only for photo download and only for as long
small_file_id (:obj:`str`): File identifier of small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
chat photo. This file_id can be used only for photo download and only for as long
as the photo is not changed.
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
which is supposed to be the same over time and for different bots.
small_file_unique_id (:obj:`str`): Unique file identifier of small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
chat photo, which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
big_file_id (:obj:`str`): File identifier of big (640x640) chat photo.
This file_id can be used only for photo download and only for as long as
big_file_id (:obj:`str`): File identifier of big
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
chat photo. This file_id can be used only for photo download and only for as long as
the photo is not changed.
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
which is supposed to be the same over time and for different bots.
big_file_unique_id (:obj:`str`): Unique file identifier of big
(:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
chat photo, which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.

"""
Expand DownExpand Up@@ -99,8 +109,9 @@ async def get_small_file(
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict = None,
) -> "File":
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
small (160x160) chat photo
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the small
(:tg-const:`telegram.ChatPhoto.SIZE_SMALL` x :tg-const:`telegram.ChatPhoto.SIZE_SMALL`)
chat photo

For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.

Expand DownExpand Up@@ -130,7 +141,8 @@ async def get_big_file(
api_kwargs: JSONDict = None,
) -> "File":
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
big (640x640) chat photo
big (:tg-const:`telegram.ChatPhoto.SIZE_BIG` x :tg-const:`telegram.ChatPhoto.SIZE_BIG`)
chat photo

For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.

Expand All@@ -149,3 +161,14 @@ async def get_big_file(
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
)

SIZE_SMALL: ClassVar[int] = constants.ChatPhotoSize.SMALL
""":const:`telegram.constants.ChatPhotoSize.SMALL`

.. versionadded:: 20.0
"""
SIZE_BIG: ClassVar[int] = constants.ChatPhotoSize.BIG
""":const:`telegram.constants.ChatPhotoSize.BIG`

.. versionadded:: 20.0
"""
24 changes: 22 additions & 2 deletionstelegram/_files/location.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,9 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Location."""

from typing import ClassVar

from telegram import constants
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict

Expand All@@ -32,11 +35,12 @@ class Location(TelegramObject):
longitude (:obj:`float`): Longitude as defined by sender.
latitude (:obj:`float`): Latitude as defined by sender.
horizontal_accuracy (:obj:`float`, optional): The radius of uncertainty for the location,
measured in meters; 0-:tg-const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`.
measured in meters; 0-:tg-const:`telegram.Location.HORIZONTAL_ACCURACY`.
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.Location.MIN_HEADING`-:tg-const:`telegram.Location.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 DownExpand Up@@ -88,3 +92,19 @@ def __init__(
)

self._id_attrs = (self.longitude, self.latitude)

HORIZONTAL_ACCURACY: ClassVar[int] = constants.LocationLimit.HORIZONTAL_ACCURACY
""":const:`telegram.constants.LocationLimit.HORIZONTAL_ACCURACY`

.. versionadded:: 20.0
"""
MIN_HEADING: ClassVar[int] = constants.LocationLimit.MIN_HEADING
""":const:`telegram.constants.LocationLimit.MIN_HEADING`

.. versionadded:: 20.0
"""
MAX_HEADING: ClassVar[int] = constants.LocationLimit.MAX_HEADING
""":const:`telegram.constants.LocationLimit.MAX_HEADING`

.. versionadded:: 20.0
"""
Loading

[8]ページ先頭

©2009-2025 Movatter.jp