From 6ba49eea29c18d28d8b0f421b6b481ab6236f854 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Sun, 13 Aug 2023 01:52:24 +0700 Subject: [PATCH] Pyrofork: Add InputReplyToStory Signed-off-by: wulan17 --- compiler/docs/compiler.py | 1 + pyrogram/methods/messages/send_animation.py | 7 +++ pyrogram/methods/messages/send_audio.py | 7 +++ .../methods/messages/send_cached_media.py | 7 +++ pyrogram/methods/messages/send_dice.py | 7 +++ pyrogram/methods/messages/send_document.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_sticker.py | 7 +++ pyrogram/methods/messages/send_video.py | 7 +++ pyrogram/methods/messages/send_video_note.py | 9 +++- pyrogram/methods/messages/send_voice.py | 10 ++++ .../types/input_message_content/__init__.py | 3 +- .../input_reply_to_story.py | 49 +++++++++++++++++++ 15 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 pyrogram/types/input_message_content/input_reply_to_story.py diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 24bc6317..b183af50 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -523,6 +523,7 @@ def pyrogram_api(): InputMessageContent InputMessageContent InputReplyToMessage + InputReplyToStory InputTextMessageContent """, authorization=""" diff --git a/pyrogram/methods/messages/send_animation.py b/pyrogram/methods/messages/send_animation.py index 002d76f4..3bb462cb 100644 --- a/pyrogram/methods/messages/send_animation.py +++ b/pyrogram/methods/messages/send_animation.py @@ -48,6 +48,7 @@ class SendAnimation: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -122,6 +123,9 @@ class SendAnimation: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -183,6 +187,9 @@ class SendAnimation: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(animation, str): diff --git a/pyrogram/methods/messages/send_audio.py b/pyrogram/methods/messages/send_audio.py index d1df3271..551768ab 100644 --- a/pyrogram/methods/messages/send_audio.py +++ b/pyrogram/methods/messages/send_audio.py @@ -46,6 +46,7 @@ class SendAudio: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -115,6 +116,9 @@ class SendAudio: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -177,6 +181,9 @@ class SendAudio: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(audio, str): diff --git a/pyrogram/methods/messages/send_cached_media.py b/pyrogram/methods/messages/send_cached_media.py index c17c27d5..4d045578 100644 --- a/pyrogram/methods/messages/send_cached_media.py +++ b/pyrogram/methods/messages/send_cached_media.py @@ -37,6 +37,7 @@ class SendCachedMedia: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -87,6 +88,9 @@ class SendCachedMedia: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -110,6 +114,9 @@ class SendCachedMedia: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) media = utils.get_input_media_from_file_id(file_id) media.spoiler = has_spoiler diff --git a/pyrogram/methods/messages/send_dice.py b/pyrogram/methods/messages/send_dice.py index 2b752fc4..08ca09f8 100644 --- a/pyrogram/methods/messages/send_dice.py +++ b/pyrogram/methods/messages/send_dice.py @@ -32,6 +32,7 @@ class SendDice: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -68,6 +69,9 @@ class SendDice: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -98,6 +102,9 @@ class SendDice: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) r = await self.invoke( raw.functions.messages.SendMedia( diff --git a/pyrogram/methods/messages/send_document.py b/pyrogram/methods/messages/send_document.py index 44cbee99..7599974c 100644 --- a/pyrogram/methods/messages/send_document.py +++ b/pyrogram/methods/messages/send_document.py @@ -44,6 +44,7 @@ class SendDocument: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -107,6 +108,9 @@ class SendDocument: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -164,6 +168,9 @@ class SendDocument: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(document, str): diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py index 9783cc77..b761a175 100644 --- a/pyrogram/methods/messages/send_media_group.py +++ b/pyrogram/methods/messages/send_media_group.py @@ -47,6 +47,7 @@ class SendMediaGroup: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, ) -> List["types.Message"]: @@ -73,6 +74,9 @@ class SendMediaGroup: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -102,6 +106,9 @@ class SendMediaGroup: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) for i in media: if isinstance(i, types.InputMediaPhoto): diff --git a/pyrogram/methods/messages/send_message.py b/pyrogram/methods/messages/send_message.py index 0fd7cdbe..b126191f 100644 --- a/pyrogram/methods/messages/send_message.py +++ b/pyrogram/methods/messages/send_message.py @@ -35,6 +35,7 @@ class SendMessage: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -77,6 +78,9 @@ class SendMessage: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -131,6 +135,9 @@ class SendMessage: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) r = await self.invoke( raw.functions.messages.SendMessage( diff --git a/pyrogram/methods/messages/send_photo.py b/pyrogram/methods/messages/send_photo.py index 85dd91d8..8dc695c2 100644 --- a/pyrogram/methods/messages/send_photo.py +++ b/pyrogram/methods/messages/send_photo.py @@ -42,6 +42,7 @@ class SendPhoto: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -98,6 +99,9 @@ class SendPhoto: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -155,6 +159,9 @@ class SendPhoto: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(photo, str): diff --git a/pyrogram/methods/messages/send_sticker.py b/pyrogram/methods/messages/send_sticker.py index 283560ba..e8696224 100644 --- a/pyrogram/methods/messages/send_sticker.py +++ b/pyrogram/methods/messages/send_sticker.py @@ -38,6 +38,7 @@ class SendSticker: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -76,6 +77,9 @@ class SendSticker: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -128,6 +132,9 @@ class SendSticker: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(sticker, str): diff --git a/pyrogram/methods/messages/send_video.py b/pyrogram/methods/messages/send_video.py index dac03ba7..ed0745c9 100644 --- a/pyrogram/methods/messages/send_video.py +++ b/pyrogram/methods/messages/send_video.py @@ -49,6 +49,7 @@ class SendVideo: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -128,6 +129,9 @@ class SendVideo: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -188,6 +192,9 @@ class SendVideo: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(video, str): diff --git a/pyrogram/methods/messages/send_video_note.py b/pyrogram/methods/messages/send_video_note.py index 9d0aa3a5..1a0f81a1 100644 --- a/pyrogram/methods/messages/send_video_note.py +++ b/pyrogram/methods/messages/send_video_note.py @@ -40,6 +40,7 @@ class SendVideoNote: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -89,7 +90,10 @@ class SendVideoNote: for forum supergroups only. reply_to_message_id (``int``, *optional*): - If the message is a reply, ID of the original message + If the message is a reply, ID of the original message. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -142,6 +146,9 @@ class SendVideoNote: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(video_note, str): diff --git a/pyrogram/methods/messages/send_voice.py b/pyrogram/methods/messages/send_voice.py index 83bcb633..5e81a8bc 100644 --- a/pyrogram/methods/messages/send_voice.py +++ b/pyrogram/methods/messages/send_voice.py @@ -42,6 +42,7 @@ class SendVoice: disable_notification: bool = None, message_thread_id: int = None, reply_to_message_id: int = None, + reply_to_story_id: int = None, schedule_date: datetime = None, protect_content: bool = None, reply_markup: Union[ @@ -93,6 +94,12 @@ class SendVoice: reply_to_message_id (``int``, *optional*): If the message is a reply, ID of the original message + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. + + reply_to_story_id (``int``, *optional*): + Unique identifier for the target story. schedule_date (:py:obj:`~datetime.datetime`, *optional*): Date when the message will be automatically sent. @@ -147,6 +154,9 @@ class SendVoice: reply_to = None if reply_to_message_id or message_thread_id: reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id) + if reply_to_story_id: + user_id = await self.resolve_peer(chat_id) + reply_to = types.InputReplyToStory(user_id=user_id, story_id=reply_to_story_id) try: if isinstance(voice, str): diff --git a/pyrogram/types/input_message_content/__init__.py b/pyrogram/types/input_message_content/__init__.py index 91b5dfbb..4936aaff 100644 --- a/pyrogram/types/input_message_content/__init__.py +++ b/pyrogram/types/input_message_content/__init__.py @@ -18,8 +18,9 @@ from .input_message_content import InputMessageContent from .input_reply_to_message import InputReplyToMessage +from .input_reply_to_story import InputReplyToStory from .input_text_message_content import InputTextMessageContent __all__ = [ - "InputMessageContent", "InputReplyToMessage", "InputTextMessageContent" + "InputMessageContent", "InputReplyToMessage", "InputReplyToStory", "InputTextMessageContent" ] diff --git a/pyrogram/types/input_message_content/input_reply_to_story.py b/pyrogram/types/input_message_content/input_reply_to_story.py new file mode 100644 index 00000000..c521e4b0 --- /dev/null +++ b/pyrogram/types/input_message_content/input_reply_to_story.py @@ -0,0 +1,49 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrofork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrofork. If not, see . + +from pyrogram import raw +from ..object import Object + + +class InputReplyToStory(Object): + """Contains information about a target replied story. + + + Parameters: + user_id (:obj:`~pyrogram.raw.types.InputUser`): + An InputUser. + + story_id (``int``): + Unique identifier for the target story. + """ + + def __init__( + self, *, + user_id: "raw.types.InputUser" = None, + story_id: int = None + ): + super().__init__() + + self.user_id = user_id + self.story_id = story_id + + def write(self): + return raw.types.InputReplyToStory( + user_id=self.user_id, + story_id=self.story_id + ).write()