pyrofork: Add InputReplyToMessage

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-08 20:06:19 +07:00
parent 730c43f631
commit 92c7b0c883
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
22 changed files with 84 additions and 210 deletions

View file

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

View file

@ -80,17 +80,7 @@ class SendGame:
"""
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -71,17 +71,7 @@ class SendInlineBotResult:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
return await self.invoke(
raw.functions.messages.SendInlineBotResult(

View file

@ -96,17 +96,7 @@ class CopyMediaGroup:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
for i, message in enumerate(media_group):
if message.photo:

View file

@ -182,17 +182,7 @@ class SendAnimation:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(animation, str):

View file

@ -176,17 +176,7 @@ class SendAudio:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(audio, str):

View file

@ -105,17 +105,7 @@ class SendCachedMedia:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -98,17 +98,7 @@ class SendContact:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -97,17 +97,7 @@ class SendDice:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -163,17 +163,7 @@ class SendDocument:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(document, str):

View file

@ -90,17 +90,7 @@ class SendLocation:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -101,17 +101,7 @@ class SendMediaGroup:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
for i in media:
if isinstance(i, types.InputMediaPhoto):

View file

@ -130,17 +130,7 @@ class SendMessage:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMessage(

View file

@ -154,17 +154,7 @@ class SendPhoto:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(photo, str):

View file

@ -140,17 +140,7 @@ class SendPoll:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
solution, solution_entities = (await utils.parse_text_entities(
self, explanation, explanation_parse_mode, explanation_entities

View file

@ -127,17 +127,7 @@ class SendSticker:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(sticker, str):

View file

@ -109,17 +109,7 @@ class SendVenue:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
r = await self.invoke(
raw.functions.messages.SendMedia(

View file

@ -187,17 +187,7 @@ class SendVideo:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(video, str):

View file

@ -141,17 +141,7 @@ class SendVideoNote:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(video_note, str):

View file

@ -146,17 +146,7 @@ class SendVoice:
reply_to = None
if reply_to_message_id or message_thread_id:
reply_to_msg_id = None
top_msg_id = None
if message_thread_id:
if not reply_to_message_id:
reply_to_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
top_msg_id = message_thread_id
else:
reply_to_msg_id = reply_to_message_id
reply_to = raw.types.InputReplyToMessage(reply_to_msg_id=reply_to_msg_id, top_msg_id=top_msg_id)
reply_to = types.InputReplyToMessage(reply_to_message_id=reply_to_message_id, message_thread_id=message_thread_id)
try:
if isinstance(voice, str):

View file

@ -17,8 +17,9 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from .input_message_content import InputMessageContent
from .input_reply_to_message import InputReplyToMessage
from .input_text_message_content import InputTextMessageContent
__all__ = [
"InputMessageContent", "InputTextMessageContent"
"InputMessageContent", "InputReplyToMessage", "InputTextMessageContent"
]

View file

@ -0,0 +1,62 @@
# 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 InputReplyToMessage(Object):
"""Contains information about a target replied message.
Parameters:
reply_to_message_id (``int``, *optional*):
ID of the original message you want to reply.
message_thread_id (``int``, *optional*):
Unique identifier for the target message thread (topic) of the forum.
for forum supergroups only.
"""
def __init__(
self, *,
reply_to_message_id: int = None,
message_thread_id: int = None
):
super().__init__()
self.reply_to_message_id = reply_to_message_id
self.message_thread_id = message_thread_id
def write(self):
reply_to_msg_id = None
top_msg_id = None
if self.reply_to_message_id or self.reply_to_message_id:
if self.message_thread_id:
if not self.reply_to_message_id:
reply_to_msg_id = self.message_thread_id
else:
reply_to_msg_id = self.reply_to_message_id
top_msg_id = self.message_thread_id
else:
reply_to_msg_id = self.reply_to_message_id
return raw.types.InputReplyToMessage(
reply_to_msg_id=reply_to_msg_id,
top_msg_id=top_msg_id
).write()
return None