Skip to content

Commit

Permalink
Attempt 3) at fixing bug with message_thread_id
Browse files Browse the repository at this point in the history
Follow-Up: 15acd9c

Also, rename nosound_video to disable_content_type_detection, in one more PLACe!
  • Loading branch information
SpEcHiDe committed Mar 22, 2024
1 parent 8464420 commit ad26117
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/source/topics/message-identifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ Megagroups behave differently::

The group has its own message counter.
Each user won't get a copy of the message with their own identifier, but rather everyone sees the same message.

# TODO

Things get even messier in Scheduled Messages history section. todo blah blah, try to copy documentation from somewhere..
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/edit_inline_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ async def edit_inline_media(
),
raw.types.DocumentAttributeAnimated()
] + filename_attribute,
nosound_video=True
nosound_video=True,
force_file=False
)
elif is_external_url:
media = raw.types.InputMediaDocumentExternal(
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/messages/edit_message_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ async def edit_message_media(
file_name=file_name or os.path.basename(media.media)
)
],
force_file=media.nosound_video or None,
nosound_video=not media.disable_content_type_detection,
force_file=media.disable_content_type_detection or None,
)
)
)
Expand Down
6 changes: 4 additions & 2 deletions pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ async def send_media_group(
media=raw.types.InputMediaUploadedDocument(
file=await self.save_file(i.media),
thumb=await self.save_file(i.thumb),
nosound_video=i.nosound_video,
nosound_video=i.disable_content_type_detection,
force_file=not i.disable_content_type_detection or None,
spoiler=i.has_spoiler,
mime_type=self.guess_mime_type(i.media) or "video/mp4",
attributes=[
Expand Down Expand Up @@ -223,7 +224,8 @@ async def send_media_group(
media=raw.types.InputMediaUploadedDocument(
file=await self.save_file(i.media),
thumb=await self.save_file(i.thumb),
nosound_video=i.nosound_video,
nosound_video=i.disable_content_type_detection,
force_file=not i.disable_content_type_detection or None,
spoiler=i.has_spoiler,
mime_type=self.guess_mime_type(getattr(i.media, "name", "video.mp4")) or "video/mp4",
attributes=[
Expand Down
7 changes: 4 additions & 3 deletions pyrogram/types/input_media/input_media_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class InputMediaVideo(InputMedia):
has_spoiler (``bool``, *optional*):
Pass True if the photo needs to be covered with a spoiler animation.
nosound_video (``bool``, *optional*):
disable_content_type_detection (``bool``, *optional*):
Pass True, if the uploaded video is a video message with no sound.
Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album.
"""

def __init__(
Expand All @@ -83,7 +84,7 @@ def __init__(
duration: int = 0,
supports_streaming: bool = True,
has_spoiler: bool = None,
nosound_video: bool = None,
disable_content_type_detection: bool = None,
):
super().__init__(media, caption, parse_mode, caption_entities)

Expand All @@ -93,4 +94,4 @@ def __init__(
self.duration = duration
self.supports_streaming = supports_streaming
self.has_spoiler = has_spoiler
self.nosound_video = nosound_video
self.disable_content_type_detection = disable_content_type_detection
4 changes: 2 additions & 2 deletions pyrogram/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ async def get_reply_head_fm(
if not reply_parameters:
if message_thread_id:
reply_to = raw.types.InputReplyToMessage(
reply_to_msg_id=0
reply_to_msg_id=message_thread_id,
top_msg_id=message_thread_id
)
reply_to.top_msg_id = message_thread_id
return reply_to
if (
reply_parameters and
Expand Down

0 comments on commit ad26117

Please sign in to comment.