From 9b92492553b965b1dea00200eda8ea3de1d75069 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sat, 12 Nov 2022 23:05:33 +0700 Subject: [PATCH] Pyrogram: Add message_thread_id parameter to send_{animation,audio,cached_media,contact,dice,document,location,media_group,message,photo,poll,sticker,venue,video,video_note,voice} methods Signed-off-by: wulan17 --- pyrogram/methods/messages/send_animation.py | 7 ++++++- pyrogram/methods/messages/send_audio.py | 7 ++++++- pyrogram/methods/messages/send_cached_media.py | 7 ++++++- pyrogram/methods/messages/send_contact.py | 7 ++++++- pyrogram/methods/messages/send_dice.py | 7 ++++++- pyrogram/methods/messages/send_document.py | 7 ++++++- pyrogram/methods/messages/send_location.py | 7 ++++++- pyrogram/methods/messages/send_media_group.py | 7 ++++++- pyrogram/methods/messages/send_message.py | 7 ++++++- pyrogram/methods/messages/send_photo.py | 7 ++++++- pyrogram/methods/messages/send_poll.py | 7 ++++++- pyrogram/methods/messages/send_sticker.py | 7 ++++++- pyrogram/methods/messages/send_venue.py | 7 ++++++- pyrogram/methods/messages/send_video.py | 7 ++++++- pyrogram/methods/messages/send_video_note.py | 7 ++++++- pyrogram/methods/messages/send_voice.py | 7 ++++++- 16 files changed, 96 insertions(+), 16 deletions(-) diff --git a/pyrogram/methods/messages/send_animation.py b/pyrogram/methods/messages/send_animation.py index ec85dc05..5952138e 100644 --- a/pyrogram/methods/messages/send_animation.py +++ b/pyrogram/methods/messages/send_animation.py @@ -45,6 +45,7 @@ class SendAnimation: thumb: Union[str, BinaryIO] = None, file_name: str = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -111,6 +112,10 @@ class SendAnimation: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -223,7 +228,7 @@ class SendAnimation: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_audio.py b/pyrogram/methods/messages/send_audio.py index 7a81df01..1cdc6d5a 100644 --- a/pyrogram/methods/messages/send_audio.py +++ b/pyrogram/methods/messages/send_audio.py @@ -44,6 +44,7 @@ class SendAudio: thumb: Union[str, BinaryIO] = None, file_name: str = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -108,6 +109,10 @@ class SendAudio: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -217,7 +222,7 @@ class SendAudio: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_cached_media.py b/pyrogram/methods/messages/send_cached_media.py index 5a9e2e1f..beaf19db 100644 --- a/pyrogram/methods/messages/send_cached_media.py +++ b/pyrogram/methods/messages/send_cached_media.py @@ -34,6 +34,7 @@ class SendCachedMedia: parse_mode: Optional["enums.ParseMode"] = None, caption_entities: List["types.MessageEntity"] = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -76,6 +77,10 @@ class SendCachedMedia: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -103,7 +108,7 @@ class SendCachedMedia: peer=await self.resolve_peer(chat_id), media=utils.get_input_media_from_file_id(file_id), silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_contact.py b/pyrogram/methods/messages/send_contact.py index 30f7abd3..32b46835 100644 --- a/pyrogram/methods/messages/send_contact.py +++ b/pyrogram/methods/messages/send_contact.py @@ -33,6 +33,7 @@ class SendContact: last_name: str = None, vcard: str = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -69,6 +70,10 @@ class SendContact: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -101,7 +106,7 @@ class SendContact: ), message="", silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_dice.py b/pyrogram/methods/messages/send_dice.py index c657d85d..f9f7a4d5 100644 --- a/pyrogram/methods/messages/send_dice.py +++ b/pyrogram/methods/messages/send_dice.py @@ -30,6 +30,7 @@ class SendDice: chat_id: Union[int, str], emoji: str = "🎲", disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -61,6 +62,10 @@ class SendDice: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -95,7 +100,7 @@ class SendDice: peer=await self.resolve_peer(chat_id), media=raw.types.InputMediaDice(emoticon=emoji), silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_document.py b/pyrogram/methods/messages/send_document.py index b0a4a531..e0f4288e 100644 --- a/pyrogram/methods/messages/send_document.py +++ b/pyrogram/methods/messages/send_document.py @@ -42,6 +42,7 @@ class SendDocument: file_name: str = None, force_document: bool = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -100,6 +101,10 @@ class SendDocument: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -195,7 +200,7 @@ class SendDocument: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_location.py b/pyrogram/methods/messages/send_location.py index 2bd17681..dd6079ec 100644 --- a/pyrogram/methods/messages/send_location.py +++ b/pyrogram/methods/messages/send_location.py @@ -31,6 +31,7 @@ class SendLocation: latitude: float, longitude: float, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -61,6 +62,10 @@ class SendLocation: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message @@ -93,7 +98,7 @@ class SendLocation: ), message="", silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py index 0dfbbaa2..cc7ab770 100644 --- a/pyrogram/methods/messages/send_media_group.py +++ b/pyrogram/methods/messages/send_media_group.py @@ -43,6 +43,7 @@ class SendMediaGroup: "types.InputMediaDocument" ]], disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -64,6 +65,10 @@ class SendMediaGroup: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -383,7 +388,7 @@ class SendMediaGroup: peer=await self.resolve_peer(chat_id), multi_media=multi_media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content ), diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py index ad73f9a1..ffc32dd1 100644 --- a/pyrogram/methods/messages/send_message.py +++ b/pyrogram/methods/messages/send_message.py @@ -33,6 +33,7 @@ class SendMessage: entities: List["types.MessageEntity"] = None, disable_web_page_preview: bool = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -70,6 +71,10 @@ class SendMessage: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -128,7 +133,7 @@ class SendMessage: peer=await self.resolve_peer(chat_id), no_webpage=disable_web_page_preview or None, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), reply_markup=await reply_markup.write(self) if reply_markup else None, diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py index 994f0c93..dfdea312 100644 --- a/pyrogram/methods/messages/send_photo.py +++ b/pyrogram/methods/messages/send_photo.py @@ -39,6 +39,7 @@ class SendPhoto: caption_entities: List["types.MessageEntity"] = None, ttl_seconds: int = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -87,6 +88,10 @@ class SendPhoto: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -172,7 +177,7 @@ class SendPhoto: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_poll.py b/pyrogram/methods/messages/send_poll.py index 267dcb6d..106177d7 100644 --- a/pyrogram/methods/messages/send_poll.py +++ b/pyrogram/methods/messages/send_poll.py @@ -42,6 +42,7 @@ class SendPoll: is_closed: bool = None, disable_notification: bool = None, protect_content: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, reply_markup: Union[ @@ -114,6 +115,10 @@ class SendPoll: protect_content (``bool``, *optional*): Protects the contents of the sent message from forwarding and saving. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -161,7 +166,7 @@ class SendPoll: ), message="", silent=disable_notification, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py index ccfaada5..6b6d0090 100644 --- a/pyrogram/methods/messages/send_sticker.py +++ b/pyrogram/methods/messages/send_sticker.py @@ -36,6 +36,7 @@ class SendSticker: chat_id: Union[int, str], sticker: Union[str, BinaryIO], disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -69,6 +70,10 @@ class SendSticker: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -154,7 +159,7 @@ class SendSticker: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_venue.py b/pyrogram/methods/messages/send_venue.py index 4d3167bf..ff3b5920 100644 --- a/pyrogram/methods/messages/send_venue.py +++ b/pyrogram/methods/messages/send_venue.py @@ -35,6 +35,7 @@ class SendVenue: foursquare_id: str = "", foursquare_type: str = "", disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -78,6 +79,10 @@ class SendVenue: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message @@ -117,7 +122,7 @@ class SendVenue: ), message="", silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py index c2053064..01917c6a 100644 --- a/pyrogram/methods/messages/send_video.py +++ b/pyrogram/methods/messages/send_video.py @@ -46,6 +46,7 @@ class SendVideo: file_name: str = None, supports_streaming: bool = True, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -117,6 +118,10 @@ class SendVideo: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. @@ -229,7 +234,7 @@ class SendVideo: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_video_note.py b/pyrogram/methods/messages/send_video_note.py index 9c615d31..1348d3fe 100644 --- a/pyrogram/methods/messages/send_video_note.py +++ b/pyrogram/methods/messages/send_video_note.py @@ -38,6 +38,7 @@ class SendVideoNote: length: int = 1, thumb: Union[str, BinaryIO] = None, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -83,6 +84,10 @@ class SendVideoNote: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message @@ -178,7 +183,7 @@ class SendVideoNote: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content, diff --git a/pyrogram/methods/messages/send_voice.py b/pyrogram/methods/messages/send_voice.py index 266702fd..a623711c 100644 --- a/pyrogram/methods/messages/send_voice.py +++ b/pyrogram/methods/messages/send_voice.py @@ -40,6 +40,7 @@ class SendVoice: caption_entities: List["types.MessageEntity"] = None, duration: int = 0, disable_notification: bool = None, + message_thread_id: int = None, reply_to_message_id: int = None, schedule_date: datetime = None, protect_content: bool = None, @@ -86,6 +87,10 @@ class SendVoice: Sends the message silently. Users will receive a notification with no sound. + message_thread_id (``int``, *optional*): + Unique identifier for the target message thread (topic) of the forum. + for forum supergroups only. + reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message @@ -179,7 +184,7 @@ class SendVoice: peer=await self.resolve_peer(chat_id), media=media, silent=disable_notification or None, - reply_to_msg_id=reply_to_message_id, + reply_to_msg_id=reply_to_message_id or message_thread_id, random_id=self.rnd_id(), schedule_date=utils.datetime_to_timestamp(schedule_date), noforwards=protect_content,