Skip to content

Commit 14c8755

Browse files
committed
Add video_cover and video_start_timestamp to copy_message
- Fix bug in commit bf7491a
1 parent bf7491a commit 14c8755

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

pyrogram/methods/messages/copy_message.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ async def copy_message(
3636
parse_mode: Optional["enums.ParseMode"] = None,
3737
caption_entities: list["types.MessageEntity"] = None,
3838
show_caption_above_media: bool = None,
39+
video_cover: Optional[Union[str, "io.BytesIO"]] = None,
40+
video_start_timestamp: int = None,
3941
disable_notification: bool = None,
4042
reply_parameters: "types.ReplyParameters" = None,
4143
reply_markup: Union[
@@ -89,6 +91,12 @@ async def copy_message(
8991
show_caption_above_media (``bool``, *optional*):
9092
Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified.
9193
94+
video_cover (``str`` | :obj:`io.BytesIO`, *optional*):
95+
New cover for the copied video in the message. Pass None to skip cover uploading and use the existing cover.
96+
97+
video_start_timestamp (``int``, *optional*):
98+
New start timestamp, from which the video playing must start, in seconds for the copied video in the message.
99+
92100
disable_notification (``bool``, *optional*):
93101
Sends the message silently.
94102
Users will receive a notification with no sound.
@@ -154,6 +162,8 @@ async def copy_message(
154162
parse_mode=parse_mode,
155163
caption_entities=caption_entities,
156164
show_caption_above_media=show_caption_above_media,
165+
video_cover=video_cover,
166+
video_start_timestamp=video_start_timestamp,
157167
disable_notification=disable_notification,
158168
reply_parameters=reply_parameters,
159169
reply_markup=reply_markup,

pyrogram/types/messages_and_media/message.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4679,6 +4679,8 @@ async def copy(
46794679
parse_mode: Optional["enums.ParseMode"] = None,
46804680
caption_entities: list["types.MessageEntity"] = None,
46814681
show_caption_above_media: bool = None,
4682+
video_cover: Optional[Union[str, "io.BytesIO"]] = None,
4683+
video_start_timestamp: int = None,
46824684
disable_notification: bool = None,
46834685
reply_parameters: "types.ReplyParameters" = None,
46844686
reply_markup: Union[
@@ -4733,6 +4735,12 @@ async def copy(
47334735
show_caption_above_media (``bool``, *optional*):
47344736
Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified.
47354737
4738+
video_cover (``str`` | :obj:`io.BytesIO`, *optional*):
4739+
New cover for the copied video in the message. Pass None to skip cover uploading and use the existing cover.
4740+
4741+
video_start_timestamp (``int``, *optional*):
4742+
New start timestamp, from which the video playing must start, in seconds for the copied video in the message.
4743+
47364744
disable_notification (``bool``, *optional*):
47374745
Sends the message silently.
47384746
Users will receive a notification with no sound.
@@ -4827,7 +4835,29 @@ async def copy(
48274835
elif self.document:
48284836
file_id = self.document.file_id
48294837
elif self.video:
4830-
file_id = self.video.file_id
4838+
return await self._client.send_video(
4839+
chat_id,
4840+
video=self.video.file_id,
4841+
caption=caption,
4842+
parse_mode=parse_mode,
4843+
caption_entities=caption_entities,
4844+
show_caption_above_media=show_caption_above_media or self.show_caption_above_media,
4845+
cover=video_cover,
4846+
start_timestamp=video_start_timestamp,
4847+
has_spoiler=self.has_media_spoiler,
4848+
disable_notification=disable_notification,
4849+
protect_content=self.has_protected_content if protect_content is None else protect_content,
4850+
allow_paid_broadcast=allow_paid_broadcast,
4851+
message_thread_id=self.message_thread_id if message_thread_id is None else message_thread_id,
4852+
business_connection_id=self.business_connection_id if business_connection_id is None else business_connection_id,
4853+
send_as=send_as,
4854+
message_effect_id=self.effect_id,
4855+
reply_parameters=reply_parameters,
4856+
reply_markup=self.reply_markup if reply_markup is object else reply_markup,
4857+
# TODO
4858+
schedule_date=schedule_date,
4859+
reply_to_message_id=reply_to_message_id
4860+
)
48314861
elif self.animation:
48324862
file_id = self.animation.file_id
48334863
elif self.voice:

pyrogram/types/messages_and_media/video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _parse(
147147
cover=types.Photo._parse(
148148
client,
149149
media.video_cover
150-
) if media.video_cover else None,
151-
start_timestamp=media.video_timestamp,
150+
) if media and media.video_cover else None,
151+
start_timestamp=media.video_timestamp if media else None,
152152
client=client
153153
)

0 commit comments

Comments
 (0)