Skip to content
Open
1 change: 1 addition & 0 deletions changes/unreleased/5229.87PBN4GFkuAaDhhgFwCYkY.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ highlights = "Full Support for Bot API 10.0"
pull_requests = [
{ uid = "5229", author_uid = "aelkheir", closes_threads = ["5228"] },
{ uid = "5230", author_uid = "harshil21" },
{ uid = "5235", author_uid = "harshil21" },
]
2 changes: 2 additions & 0 deletions docs/source/inclusions/bot_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
- Used for sending paid media to channels
* - :meth:`~telegram.Bot.send_photo`
- Used for sending photos
* - :meth:`~telegram.Bot.send_live_photo`
- Used for sending live photos
* - :meth:`~telegram.Bot.send_poll`
- Used for sending polls
* - :meth:`~telegram.Bot.send_sticker`
Expand Down
4 changes: 4 additions & 0 deletions docs/source/telegram.at-tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ Available Types
telegram.inputmediaanimation
telegram.inputmediaaudio
telegram.inputmediadocument
telegram.inputmedialivephoto
telegram.inputmediaphoto
telegram.inputmediavideo
telegram.inputpaidmedia
telegram.inputpaidmedialivephoto
telegram.inputpaidmediaphoto
telegram.inputpaidmediavideo
telegram.inputprofilephoto
Expand All @@ -119,6 +121,7 @@ Available Types
telegram.keyboardbuttonrequestmanagedbot
telegram.keyboardbuttonrequestusers
telegram.linkpreviewoptions
telegram.livephoto
telegram.location
telegram.locationaddress
telegram.loginurl
Expand Down Expand Up @@ -146,6 +149,7 @@ Available Types
telegram.ownedgiftunique
telegram.paidmedia
telegram.paidmediainfo
telegram.paidmedialivephoto
telegram.paidmediaphoto
telegram.paidmediapreview
telegram.paidmediapurchased
Expand Down
6 changes: 6 additions & 0 deletions docs/source/telegram.inputmedialivephoto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
InputMediaLivePhoto
===================

.. autoclass:: telegram.InputMediaLivePhoto
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.inputpaidmedialivephoto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
InputPaidMediaLivePhoto
======================

.. autoclass:: telegram.InputPaidMediaLivePhoto
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.livephoto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LivePhoto
=========

.. autoclass:: telegram.LivePhoto
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.paidmedialivephoto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PaidMediaLivePhoto
==================

.. autoclass:: telegram.PaidMediaLivePhoto
:members:
:show-inheritance:
8 changes: 8 additions & 0 deletions src/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@
"InputMediaAnimation",
"InputMediaAudio",
"InputMediaDocument",
"InputMediaLivePhoto",
"InputMediaPhoto",
"InputMediaVideo",
"InputMessageContent",
"InputPaidMedia",
"InputPaidMediaLivePhoto",
"InputPaidMediaPhoto",
"InputPaidMediaVideo",
"InputPollOption",
Expand All @@ -181,6 +183,7 @@
"KeyboardButtonRequestUsers",
"LabeledPrice",
"LinkPreviewOptions",
"LivePhoto",
"Location",
"LocationAddress",
"LoginUrl",
Expand Down Expand Up @@ -210,6 +213,7 @@
"OwnedGifts",
"PaidMedia",
"PaidMediaInfo",
"PaidMediaLivePhoto",
"PaidMediaPhoto",
"PaidMediaPreview",
"PaidMediaPurchased",
Expand Down Expand Up @@ -435,9 +439,11 @@
InputMediaAnimation,
InputMediaAudio,
InputMediaDocument,
InputMediaLivePhoto,
InputMediaPhoto,
InputMediaVideo,
InputPaidMedia,
InputPaidMediaLivePhoto,
InputPaidMediaPhoto,
InputPaidMediaVideo,
)
Expand All @@ -447,6 +453,7 @@
InputProfilePhotoStatic,
)
from ._files.inputsticker import InputSticker
from ._files.livephoto import LivePhoto
from ._files.location import Location
from ._files.photosize import PhotoSize
from ._files.sticker import MaskPosition, Sticker, StickerSet
Expand Down Expand Up @@ -529,6 +536,7 @@
from ._paidmedia import (
PaidMedia,
PaidMediaInfo,
PaidMediaLivePhoto,
PaidMediaPhoto,
PaidMediaPreview,
PaidMediaPurchased,
Expand Down
144 changes: 135 additions & 9 deletions src/telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from telegram._files.document import Document
from telegram._files.file import File
from telegram._files.inputmedia import InputMedia, InputPaidMedia
from telegram._files.livephoto import LivePhoto
from telegram._files.location import Location
from telegram._files.photosize import PhotoSize
from telegram._files.sticker import MaskPosition, Sticker, StickerSet
Expand Down Expand Up @@ -126,6 +127,7 @@
InputFile,
InputMediaAudio,
InputMediaDocument,
InputMediaLivePhoto,
InputMediaPhoto,
InputMediaVideo,
InputProfilePhoto,
Expand Down Expand Up @@ -2839,7 +2841,7 @@ async def send_media_group(
self,
chat_id: int | str,
media: Sequence[
"InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo"
"InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaLivePhoto" # noqa: E501 # pylint: disable=line-too-long
],
disable_notification: ODVInput[bool] = DEFAULT_NONE,
protect_content: ODVInput[bool] = DEFAULT_NONE,
Expand Down Expand Up @@ -2878,8 +2880,8 @@ async def send_media_group(
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
media (Sequence[:class:`telegram.InputMediaAudio`,\
:class:`telegram.InputMediaDocument`, :class:`telegram.InputMediaPhoto`,\
:class:`telegram.InputMediaVideo`]): An array
describing messages to be sent, must include
:class:`telegram.InputMediaVideo`, :class:`telegram.InputMediaLivePhoto`]): An
array describing messages to be sent, must include
:tg-const:`telegram.constants.MediaGroupLimit.MIN_MEDIA_LENGTH`-
:tg-const:`telegram.constants.MediaGroupLimit.MAX_MEDIA_LENGTH` items.

Expand Down Expand Up @@ -4658,12 +4660,12 @@ async def edit_message_media(
api_kwargs: JSONDict | None = None,
) -> "Message | bool":
"""
Use this method to edit animation, audio, document, photo, or video messages, or to add
media to text messages. If a message
Use this method to edit animation, audio, document, live photo, photo, or video messages,
or to add media to text messages. If a message
is part of a message album, then it can be edited only to an audio for audio albums, only
to a document for document albums and to a photo or a video otherwise. When an inline
message is edited, a new file can't be uploaded; use a previously uploaded file via its
:attr:`~telegram.File.file_id` or specify a URL.
to a document for document albums and to a photo, live photo, or a video otherwise.
When an inline message is edited, a new file can't be uploaded; use a previously
uploaded file via its :attr:`~telegram.File.file_id` or specify a URL.

Note:
* |editreplymarkup|
Expand Down Expand Up @@ -12287,6 +12289,129 @@ async def save_prepared_keyboard_button(
self,
)

async def send_live_photo(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we also do Message.reply_live_photo, [Chat,User],send_live_photo to be consistent with other send_media methods

Sorry it seems i bring up this topic too much lately 🫣

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No I did just geniunely forget about those shortcuts, good catch.

self,
chat_id: int | str,
live_photo: "FileInput | LivePhoto",
photo: "FileInput | PhotoSize",
business_connection_id: str | None = None,
message_thread_id: int | None = None,
direct_messages_topic_id: int | None = None,
caption: str | None = None,
parse_mode: ODVInput[str] = DEFAULT_NONE,
caption_entities: Sequence["MessageEntity"] | None = None,
show_caption_above_media: bool | None = None,
has_spoiler: bool | None = None,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
protect_content: ODVInput[bool] = DEFAULT_NONE,
allow_paid_broadcast: bool | None = None,
message_effect_id: str | None = None,
suggested_post_parameters: "SuggestedPostParameters | None" = None,
reply_parameters: "ReplyParameters | None" = None,
reply_markup: "ReplyMarkup | None" = None,
*,
Comment thread
harshil21 marked this conversation as resolved.
filename: str | None = None,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict | None = None,
) -> Message:
"""
Use this method to send live photos.

.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`

.. versionadded:: NEXT.VERSION

Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
live_photo (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | \
:obj:`bytes` | :class:`pathlib.Path` | :class:`telegram.LivePhoto`): Live photo
video to send. Pass a ``file_id`` to send a file that exists on the Telegram
servers (recommended). |uploadinputnopath| Sending live photos by a URL is
currently unsupported. Lastly you can pass an existing
:class:`telegram.LivePhoto` object to send.

Caution:
* The video must be at most 10MB in size.
* The video duration must not exceed 10 seconds.
* If you pass a :class:`telegram.LivePhoto`, its
:attr:`~telegram.LivePhoto.photo` field will not be considered, use
:paramref:`photo` to specify the photo to send.

photo (:obj:`str` | :term:`file object` | :class:`~telegram.InputFile` | :obj:`bytes` \
| :class:`pathlib.Path` | :class:`telegram.PhotoSize`): The static photo to send.
Pass a ``file_id`` to send a file that exists on the Telegram servers (recommended)
. |uploadinputnopath| Sending live photos by a URL is currently unsupported.
Lastly you can pass an existing :class:`telegram.PhotoSize` object to send.
business_connection_id (:obj:`str`, optional): |business_id_str|
message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
direct_messages_topic_id (:obj:`int`, optional): |direct_messages_topic_id|
caption (:obj:`str`, optional): Video caption (may also be used when resending videos
by file_id), 0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH`
characters after entities parsing.
parse_mode (:obj:`str`, optional): |parse_mode|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional):
|caption_entities|
show_caption_above_media (:obj:`bool`, optional): Pass |show_cap_above_med|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True` if the video needs to be covered
with a spoiler animation.
disable_notification (:obj:`bool`, optional): |disable_notification|
protect_content (:obj:`bool`, optional): |protect_content|
allow_paid_broadcast (:obj:`bool`, optional): |allow_paid_broadcast|
message_effect_id (:obj:`str`, optional): |message_effect_id|
suggested_post_parameters (:class:`telegram.SuggestedPostParameters`, optional):
|suggested_post_parameters|
reply_parameters (:class:`telegram.ReplyParameters`, optional): |reply_parameters|
reply_markup (:class:`InlineKeyboardMarkup` | :class:`ReplyKeyboardMarkup` | \
:class:`ReplyKeyboardRemove` | :class:`ForceReply`, optional):
Additional interface options. An object for an inline keyboard, custom reply
keyboard, instructions to remove reply keyboard or to force a reply from the user.

Keyword Args:
filename (:obj:`str`, optional): Custom file name for :paramref:`photo`, when
uploading a new file. Convenience parameter, useful e.g. when sending files
generated by the :obj:`tempfile` module.

Returns:
:class:`telegram.Message`: On success, the sent Message is returned.

Raises:
:class:`telegram.error.TelegramError`

"""
data: JSONDict = {
"chat_id": chat_id,
"live_photo": self._parse_file_input(live_photo, LivePhoto),
"photo": self._parse_file_input(photo, PhotoSize, filename=filename),
"has_spoiler": has_spoiler,
"show_caption_above_media": show_caption_above_media,
}

return await self._send_message(
"sendLivePhoto",
data,
disable_notification=disable_notification,
reply_markup=reply_markup,
protect_content=protect_content,
message_thread_id=message_thread_id,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
reply_parameters=reply_parameters,
read_timeout=read_timeout,
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
business_connection_id=business_connection_id,
message_effect_id=message_effect_id,
allow_paid_broadcast=allow_paid_broadcast,
direct_messages_topic_id=direct_messages_topic_id,
suggested_post_parameters=suggested_post_parameters,
)

async def delete_message_reaction(
self,
chat_id: int | str,
Expand Down Expand Up @@ -12314,7 +12439,6 @@ async def delete_message_reaction(
if the reaction were added by a user.
actor_chat_id (:obj:`int`, optional): Identifier of the chat whose reaction will be
removed, if the reaction were added by a chat.

Returns:
:obj:`bool`: On success, :obj:`True` is returned.

Expand Down Expand Up @@ -12733,6 +12857,8 @@ def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002
"""Alias for :meth:`replace_managed_bot_token`"""
savePreparedKeyboardButton = save_prepared_keyboard_button
"""Alias for :meth:`save_prepared_keyboard_button`"""
sendLivePhoto = send_live_photo
"""Alias for :meth:`send_live_photo`"""
deleteMessageReaction = delete_message_reaction
"""Alias for :meth:`delete_message_reaction`"""
deleteAllMessageReactions = delete_all_message_reactions
Expand Down
3 changes: 2 additions & 1 deletion src/telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
InputChecklist,
InputMediaAudio,
InputMediaDocument,
InputMediaLivePhoto,
InputMediaPhoto,
InputMediaVideo,
InputPaidMedia,
Expand Down Expand Up @@ -1192,7 +1193,7 @@ async def delete_messages(
async def send_media_group(
self,
media: Sequence[
"InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo"
"InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo | InputMediaLivePhoto" # noqa: E501 # pylint: disable=line-too-long
],
disable_notification: ODVInput[bool] = DEFAULT_NONE,
protect_content: ODVInput[bool] = DEFAULT_NONE,
Expand Down
Loading
Loading