Pyrofork: Add InputReplyToStory

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-13 01:52:24 +07:00
parent fe39c6e879
commit 6ba49eea29
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
15 changed files with 140 additions and 2 deletions

View file

@ -523,6 +523,7 @@ def pyrogram_api():
InputMessageContent
InputMessageContent
InputReplyToMessage
InputReplyToStory
InputTextMessageContent
""",
authorization="""

View file

@ -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):

View file

@ -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):

View file

@ -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

View file

@ -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(

View file

@ -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):

View file

@ -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):

View file

@ -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(

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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"
]

View file

@ -0,0 +1,49 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.
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()