Skip to content

Commit 20edfc7

Browse files
SpEcHiDemoshe-coh
authored andcommitted
api: Update API schema to Layer 160 and adapt senders
Co-Authored-By: Moshe <62907797+moshe-coh@users.noreply.github.com>
1 parent f1aa465 commit 20edfc7

22 files changed

Lines changed: 263 additions & 59 deletions

compiler/api/source/main_api.tl

Lines changed: 91 additions & 29 deletions
Large diffs are not rendered by default.

pyrogram/methods/bots/send_game.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
from typing import Union
2020

2121
import pyrogram
22-
from pyrogram import raw
23-
from pyrogram import types
22+
from pyrogram import raw, utils, types
2423

2524

2625
class SendGame:
@@ -30,6 +29,7 @@ async def send_game(
3029
game_short_name: str,
3130
disable_notification: bool = None,
3231
reply_to_message_id: int = None,
32+
message_thread_id: int = None,
3333
protect_content: bool = None,
3434
reply_markup: Union[
3535
"types.InlineKeyboardMarkup",
@@ -58,6 +58,9 @@ async def send_game(
5858
reply_to_message_id (``int``, *optional*):
5959
If the message is a reply, ID of the original message.
6060
61+
message_thread_id (``int``, *optional*):
62+
If the message is in a thread, ID of the original message.
63+
6164
protect_content (``bool``, *optional*):
6265
Protects the contents of the sent message from forwarding and saving.
6366
@@ -73,6 +76,9 @@ async def send_game(
7376
7477
await app.send_game(chat_id, "gamename")
7578
"""
79+
80+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
81+
7682
r = await self.invoke(
7783
raw.functions.messages.SendMedia(
7884
peer=await self.resolve_peer(chat_id),
@@ -84,7 +90,7 @@ async def send_game(
8490
),
8591
message="",
8692
silent=disable_notification or None,
87-
reply_to_msg_id=reply_to_message_id,
93+
reply_to=reply_to,
8894
random_id=self.rnd_id(),
8995
noforwards=protect_content,
9096
reply_markup=await reply_markup.write(self) if reply_markup else None

pyrogram/methods/bots/send_inline_bot_result.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from typing import Union
2020

2121
import pyrogram
22-
from pyrogram import raw
22+
from pyrogram import raw, utils
2323

2424

2525
class SendInlineBotResult:
@@ -29,7 +29,8 @@ async def send_inline_bot_result(
2929
query_id: int,
3030
result_id: str,
3131
disable_notification: bool = None,
32-
reply_to_message_id: int = None
32+
reply_to_message_id: int = None,
33+
message_thread_id: int = None
3334
) -> "raw.base.Updates":
3435
"""Send an inline bot result.
3536
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
@@ -52,9 +53,12 @@ async def send_inline_bot_result(
5253
Sends the message silently.
5354
Users will receive a notification with no sound.
5455
55-
reply_to_message_id (``bool``, *optional*):
56+
reply_to_message_id (``int``, *optional*):
5657
If the message is a reply, ID of the original message.
5758
59+
message_thread_id (``int``, *optional*):
60+
If the message is in a thread, ID of the original message.
61+
5862
Returns:
5963
:obj:`~pyrogram.raw.base.Updates`: Currently, on success, a raw result is returned.
6064
@@ -63,13 +67,16 @@ async def send_inline_bot_result(
6367
6468
await app.send_inline_bot_result(chat_id, query_id, result_id)
6569
"""
70+
71+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
72+
6673
return await self.invoke(
6774
raw.functions.messages.SendInlineBotResult(
6875
peer=await self.resolve_peer(chat_id),
6976
query_id=query_id,
7077
id=result_id,
7178
random_id=self.rnd_id(),
7279
silent=disable_notification or None,
73-
reply_to_msg_id=reply_to_message_id
80+
reply_to=reply_to
7481
)
7582
)

pyrogram/methods/messages/copy_media_group.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async def copy_media_group(
3232
captions: Union[List[str], str] = None,
3333
disable_notification: bool = None,
3434
reply_to_message_id: int = None,
35+
message_thread_id: int = None,
3536
schedule_date: datetime = None,
3637
) -> List["types.Message"]:
3738
"""Copy a media group by providing one of the message ids.
@@ -68,6 +69,9 @@ async def copy_media_group(
6869
reply_to_message_id (``int``, *optional*):
6970
If the message is a reply, ID of the original message.
7071
72+
message_thread_id (``int``, *optional*):
73+
If the message is in a thread, ID of the original message.
74+
7175
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
7276
Date when the message will be automatically sent.
7377
@@ -114,12 +118,14 @@ async def copy_media_group(
114118
)
115119
)
116120

121+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
122+
117123
r = await self.invoke(
118124
raw.functions.messages.SendMultiMedia(
119125
peer=await self.resolve_peer(chat_id),
120126
multi_media=multi_media,
121127
silent=disable_notification or None,
122-
reply_to_msg_id=reply_to_message_id,
128+
reply_to=reply_to,
123129
schedule_date=utils.datetime_to_timestamp(schedule_date)
124130
),
125131
sleep_threshold=60

pyrogram/methods/messages/send_animation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async def send_animation(
4747
file_name: str = None,
4848
disable_notification: bool = None,
4949
reply_to_message_id: int = None,
50+
message_thread_id: int = None,
5051
schedule_date: datetime = None,
5152
protect_content: bool = None,
5253
reply_markup: Union[
@@ -118,6 +119,9 @@ async def send_animation(
118119
reply_to_message_id (``int``, *optional*):
119120
If the message is a reply, ID of the original message.
120121
122+
message_thread_id (``int``, *optional*):
123+
If the message is in a thread, ID of the original message.
124+
121125
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
122126
Date when the message will be automatically sent.
123127
@@ -223,14 +227,16 @@ async def progress(current, total):
223227
]
224228
)
225229

230+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
231+
226232
while True:
227233
try:
228234
r = await self.invoke(
229235
raw.functions.messages.SendMedia(
230236
peer=await self.resolve_peer(chat_id),
231237
media=media,
232238
silent=disable_notification or None,
233-
reply_to_msg_id=reply_to_message_id,
239+
reply_to=reply_to,
234240
random_id=self.rnd_id(),
235241
schedule_date=utils.datetime_to_timestamp(schedule_date),
236242
noforwards=protect_content,

pyrogram/methods/messages/send_audio.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def send_audio(
4545
file_name: str = None,
4646
disable_notification: bool = None,
4747
reply_to_message_id: int = None,
48+
message_thread_id: int = None,
4849
schedule_date: datetime = None,
4950
protect_content: bool = None,
5051
reply_markup: Union[
@@ -111,6 +112,9 @@ async def send_audio(
111112
reply_to_message_id (``int``, *optional*):
112113
If the message is a reply, ID of the original message.
113114
115+
message_thread_id (``int``, *optional*):
116+
If the message is in a thread, ID of the original message.
117+
114118
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
115119
Date when the message will be automatically sent.
116120
@@ -210,14 +214,16 @@ async def progress(current, total):
210214
]
211215
)
212216

217+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
218+
213219
while True:
214220
try:
215221
r = await self.invoke(
216222
raw.functions.messages.SendMedia(
217223
peer=await self.resolve_peer(chat_id),
218224
media=media,
219225
silent=disable_notification or None,
220-
reply_to_msg_id=reply_to_message_id,
226+
reply_to=reply_to,
221227
random_id=self.rnd_id(),
222228
schedule_date=utils.datetime_to_timestamp(schedule_date),
223229
noforwards=protect_content,

pyrogram/methods/messages/send_cached_media.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async def send_cached_media(
3535
caption_entities: List["types.MessageEntity"] = None,
3636
disable_notification: bool = None,
3737
reply_to_message_id: int = None,
38+
message_thread_id: int = None,
3839
schedule_date: datetime = None,
3940
protect_content: bool = None,
4041
reply_markup: Union[
@@ -79,6 +80,9 @@ async def send_cached_media(
7980
reply_to_message_id (``int``, *optional*):
8081
If the message is a reply, ID of the original message.
8182
83+
message_thread_id (``int``, *optional*):
84+
If the message is in a thread, ID of the original message.
85+
8286
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
8387
Date when the message will be automatically sent.
8488
@@ -98,12 +102,14 @@ async def send_cached_media(
98102
await app.send_cached_media("me", file_id)
99103
"""
100104

105+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
106+
101107
r = await self.invoke(
102108
raw.functions.messages.SendMedia(
103109
peer=await self.resolve_peer(chat_id),
104110
media=utils.get_input_media_from_file_id(file_id),
105111
silent=disable_notification or None,
106-
reply_to_msg_id=reply_to_message_id,
112+
reply_to=reply_to,
107113
random_id=self.rnd_id(),
108114
schedule_date=utils.datetime_to_timestamp(schedule_date),
109115
noforwards=protect_content,

pyrogram/methods/messages/send_contact.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async def send_contact(
3434
vcard: str = None,
3535
disable_notification: bool = None,
3636
reply_to_message_id: int = None,
37+
message_thread_id: int = None,
3738
schedule_date: datetime = None,
3839
protect_content: bool = None,
3940
reply_markup: Union[
@@ -72,6 +73,9 @@ async def send_contact(
7273
reply_to_message_id (``int``, *optional*):
7374
If the message is a reply, ID of the original message.
7475
76+
message_thread_id (``int``, *optional*):
77+
If the message is in a thread, ID of the original message.
78+
7579
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
7680
Date when the message will be automatically sent.
7781
@@ -90,6 +94,9 @@ async def send_contact(
9094
9195
await app.send_contact("me", "+1-123-456-7890", "Name")
9296
"""
97+
98+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
99+
93100
r = await self.invoke(
94101
raw.functions.messages.SendMedia(
95102
peer=await self.resolve_peer(chat_id),
@@ -101,7 +108,7 @@ async def send_contact(
101108
),
102109
message="",
103110
silent=disable_notification or None,
104-
reply_to_msg_id=reply_to_message_id,
111+
reply_to=reply_to,
105112
random_id=self.rnd_id(),
106113
schedule_date=utils.datetime_to_timestamp(schedule_date),
107114
noforwards=protect_content,

pyrogram/methods/messages/send_dice.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async def send_dice(
3131
emoji: str = "🎲",
3232
disable_notification: bool = None,
3333
reply_to_message_id: int = None,
34+
message_thread_id: int = None,
3435
schedule_date: datetime = None,
3536
protect_content: bool = None,
3637
reply_markup: Union[
@@ -64,6 +65,9 @@ async def send_dice(
6465
reply_to_message_id (``int``, *optional*):
6566
If the message is a reply, ID of the original message.
6667
68+
message_thread_id (``int``, *optional*):
69+
If the message is in a thread, ID of the original message.
70+
6771
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
6872
Date when the message will be automatically sent.
6973
@@ -90,12 +94,14 @@ async def send_dice(
9094
await app.send_dice(chat_id, "🏀")
9195
"""
9296

97+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
98+
9399
r = await self.invoke(
94100
raw.functions.messages.SendMedia(
95101
peer=await self.resolve_peer(chat_id),
96102
media=raw.types.InputMediaDice(emoticon=emoji),
97103
silent=disable_notification or None,
98-
reply_to_msg_id=reply_to_message_id,
104+
reply_to=reply_to,
99105
random_id=self.rnd_id(),
100106
schedule_date=utils.datetime_to_timestamp(schedule_date),
101107
noforwards=protect_content,

pyrogram/methods/messages/send_document.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async def send_document(
4343
force_document: bool = None,
4444
disable_notification: bool = None,
4545
reply_to_message_id: int = None,
46+
message_thread_id: int = None,
4647
schedule_date: datetime = None,
4748
protect_content: bool = None,
4849
reply_markup: Union[
@@ -103,6 +104,9 @@ async def send_document(
103104
reply_to_message_id (``int``, *optional*):
104105
If the message is a reply, ID of the original message.
105106
107+
message_thread_id (``int``, *optional*):
108+
If the message is in a thread, ID of the original message.
109+
106110
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
107111
Date when the message will be automatically sent.
108112
@@ -188,14 +192,16 @@ async def progress(current, total):
188192
]
189193
)
190194

195+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
196+
191197
while True:
192198
try:
193199
r = await self.invoke(
194200
raw.functions.messages.SendMedia(
195201
peer=await self.resolve_peer(chat_id),
196202
media=media,
197203
silent=disable_notification or None,
198-
reply_to_msg_id=reply_to_message_id,
204+
reply_to=reply_to,
199205
random_id=self.rnd_id(),
200206
schedule_date=utils.datetime_to_timestamp(schedule_date),
201207
noforwards=protect_content,

0 commit comments

Comments
 (0)