Skip to content

Commit 848bc86

Browse files
committed
Add BC parameters to remaining methods
Follow-Up: fb118f9
1 parent 511702d commit 848bc86

23 files changed

+420
-86
lines changed

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Welcome to Pyrogram
44
.. admonition :: A Word of Warning
55
:class: tip
66
7-
We merge changes made to few of pyrogram forks plus changes made by us to this repository. All the features are just customized feature mostly for personal use; there is no guarantee in them being stable, __USE AT YOUR OWN RISK__.
7+
We merge changes made to few of pyrogram forks plus changes made by us to this repository. All the features are just customized feature mostly for personal use; there is no guarantee in them being stable, **USE AT YOUR OWN RISK**.
88
99
1010
.. raw:: html

pyrogram/methods/bots/send_game.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ async def send_game(
3737
"types.ReplyKeyboardMarkup",
3838
"types.ReplyKeyboardRemove",
3939
"types.ForceReply"
40-
] = None
40+
] = None,
41+
reply_to_message_id: int = None
4142
) -> "types.Message":
4243
"""Send a game.
4344
@@ -81,7 +82,20 @@ async def send_game(
8182
await app.send_game(chat_id, "gamename")
8283
"""
8384

84-
reply_to = await utils.get_reply_head_fm(
85+
if reply_to_message_id and reply_parameters:
86+
raise ValueError(
87+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
88+
"exclusive."
89+
)
90+
91+
if reply_to_message_id is not None:
92+
log.warning(
93+
"This property is deprecated. "
94+
"Please use reply_parameters instead"
95+
)
96+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
97+
98+
reply_to = await utils._get_reply_message_parameters(
8599
self,
86100
message_thread_id,
87101
reply_parameters

pyrogram/methods/bots/send_inline_bot_result.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
from typing import Union
2021

2122
import pyrogram
2223
from pyrogram import raw, utils, types
2324

25+
log = logging.getLogger(__name__)
26+
2427

2528
class SendInlineBotResult:
2629
async def send_inline_bot_result(
@@ -30,7 +33,8 @@ async def send_inline_bot_result(
3033
result_id: str,
3134
disable_notification: bool = None,
3235
reply_parameters: "types.ReplyParameters" = None,
33-
message_thread_id: int = None
36+
message_thread_id: int = None,
37+
reply_to_message_id: int = None
3438
) -> "raw.base.Updates":
3539
"""Send an inline bot result.
3640
Bot results can be retrieved using :meth:`~pyrogram.Client.get_inline_bot_results`
@@ -68,7 +72,20 @@ async def send_inline_bot_result(
6872
await app.send_inline_bot_result(chat_id, query_id, result_id)
6973
"""
7074

71-
reply_to = await utils.get_reply_head_fm(
75+
if reply_to_message_id and reply_parameters:
76+
raise ValueError(
77+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
78+
"exclusive."
79+
)
80+
81+
if reply_to_message_id is not None:
82+
log.warning(
83+
"This property is deprecated. "
84+
"Please use reply_parameters instead"
85+
)
86+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
87+
88+
reply_to = await utils._get_reply_message_parameters(
7289
self,
7390
message_thread_id,
7491
reply_parameters

pyrogram/methods/messages/copy_media_group.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
from datetime import datetime
2021
from typing import Union, List
2122

2223
import pyrogram
2324
from pyrogram import types, utils, raw
2425

26+
log = logging.getLogger(__name__)
27+
2528

2629
class CopyMediaGroup:
2730
async def copy_media_group(
@@ -34,6 +37,7 @@ async def copy_media_group(
3437
reply_parameters: "types.ReplyParameters" = None,
3538
message_thread_id: int = None,
3639
schedule_date: datetime = None,
40+
reply_to_message_id: int = None
3741
) -> List["types.Message"]:
3842
"""Copy a media group by providing one of the message ids.
3943
@@ -90,6 +94,19 @@ async def copy_media_group(
9094
captions=["caption 1", None, ""])
9195
"""
9296

97+
if reply_to_message_id and reply_parameters:
98+
raise ValueError(
99+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
100+
"exclusive."
101+
)
102+
103+
if reply_to_message_id is not None:
104+
log.warning(
105+
"This property is deprecated. "
106+
"Please use reply_parameters instead"
107+
)
108+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
109+
93110
media_group = await self.get_media_group(from_chat_id, message_id)
94111
multi_media = []
95112

@@ -118,7 +135,7 @@ async def copy_media_group(
118135
)
119136
)
120137

121-
reply_to = await utils.get_reply_head_fm(
138+
reply_to = await utils._get_reply_message_parameters(
122139
self,
123140
message_thread_id,
124141
reply_parameters

pyrogram/methods/messages/copy_message.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ async def copy_message(
4343
"types.ReplyKeyboardRemove",
4444
"types.ForceReply"
4545
] = None,
46-
schedule_date: datetime = None
46+
schedule_date: datetime = None,
47+
reply_to_message_id: int = None
4748
) -> "types.Message":
4849
"""Copy messages of any kind.
4950
@@ -102,6 +103,20 @@ async def copy_message(
102103
await app.copy_message(to_chat, from_chat, 123)
103104
104105
"""
106+
107+
if reply_to_message_id and reply_parameters:
108+
raise ValueError(
109+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
110+
"exclusive."
111+
)
112+
113+
if reply_to_message_id is not None:
114+
log.warning(
115+
"This property is deprecated. "
116+
"Please use reply_parameters instead"
117+
)
118+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
119+
105120
message: types.Message = await self.get_messages(
106121
chat_id=from_chat_id,
107122
message_ids=message_id

pyrogram/methods/messages/send_animation.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
import os
2021
import re
2122
from datetime import datetime
2223
from typing import Union, BinaryIO, List, Optional, Callable
2324

2425
import pyrogram
25-
from pyrogram import StopTransmission, enums
26-
from pyrogram import raw
27-
from pyrogram import types
28-
from pyrogram import utils
26+
from pyrogram import StopTransmission, enums, raw, types, utils
2927
from pyrogram.errors import FilePartMissing
3028
from pyrogram.file_id import FileType
3129
from .inline_session import get_session
3230

31+
log = logging.getLogger(__name__)
32+
3333

3434
class SendAnimation:
3535
async def send_animation(
@@ -59,6 +59,7 @@ async def send_animation(
5959
"types.ReplyKeyboardRemove",
6060
"types.ForceReply"
6161
] = None,
62+
reply_to_message_id: int = None,
6263
progress: Callable = None,
6364
progress_args: tuple = ()
6465
) -> Optional["types.Message"]:
@@ -191,6 +192,20 @@ async def progress(current, total):
191192
# Send self-destructing animation message
192193
await app.send_animation("me", "animation.gif", ttl_seconds=10)
193194
"""
195+
196+
if reply_to_message_id and reply_parameters:
197+
raise ValueError(
198+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
199+
"exclusive."
200+
)
201+
202+
if reply_to_message_id is not None:
203+
log.warning(
204+
"This property is deprecated. "
205+
"Please use reply_parameters instead"
206+
)
207+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
208+
194209
file = None
195210

196211
try:
@@ -248,7 +263,7 @@ async def progress(current, total):
248263
ttl_seconds=ttl_seconds
249264
)
250265

251-
reply_to = await utils.get_reply_head_fm(
266+
reply_to = await utils._get_reply_message_parameters(
252267
self,
253268
message_thread_id,
254269
reply_parameters

pyrogram/methods/messages/send_audio.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def send_audio(
5656
"types.ReplyKeyboardRemove",
5757
"types.ForceReply"
5858
] = None,
59+
reply_to_message_id: int = None,
5960
progress: Callable = None,
6061
progress_args: tuple = ()
6162
) -> Optional["types.Message"]:
@@ -176,6 +177,20 @@ async def progress(current, total):
176177
177178
await app.send_audio("me", "audio.mp3", progress=progress)
178179
"""
180+
181+
if reply_to_message_id and reply_parameters:
182+
raise ValueError(
183+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
184+
"exclusive."
185+
)
186+
187+
if reply_to_message_id is not None:
188+
log.warning(
189+
"This property is deprecated. "
190+
"Please use reply_parameters instead"
191+
)
192+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
193+
179194
file = None
180195

181196
try:
@@ -221,7 +236,7 @@ async def progress(current, total):
221236
]
222237
)
223238

224-
reply_to = await utils.get_reply_head_fm(
239+
reply_to = await utils._get_reply_message_parameters(
225240
self,
226241
message_thread_id,
227242
reply_parameters

pyrogram/methods/messages/send_cached_media.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
from datetime import datetime
2021
from typing import Union, List, Optional
2122

2223
import pyrogram
23-
from pyrogram import raw, enums
24-
from pyrogram import types
25-
from pyrogram import utils
24+
from pyrogram import raw, enums, types, utils
25+
26+
log = logging.getLogger(__name__)
2627

2728

2829
class SendCachedMedia:
@@ -45,7 +46,8 @@ async def send_cached_media(
4546
"types.ReplyKeyboardMarkup",
4647
"types.ReplyKeyboardRemove",
4748
"types.ForceReply"
48-
] = None
49+
] = None,
50+
reply_to_message_id: int = None
4951
) -> Optional["types.Message"]:
5052
"""Send any media stored on the Telegram servers using a file_id.
5153
@@ -110,7 +112,20 @@ async def send_cached_media(
110112
await app.send_cached_media("me", file_id)
111113
"""
112114

113-
reply_to = await utils.get_reply_head_fm(
115+
if reply_to_message_id and reply_parameters:
116+
raise ValueError(
117+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
118+
"exclusive."
119+
)
120+
121+
if reply_to_message_id is not None:
122+
log.warning(
123+
"This property is deprecated. "
124+
"Please use reply_parameters instead"
125+
)
126+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
127+
128+
reply_to = await utils._get_reply_message_parameters(
114129
self,
115130
message_thread_id,
116131
reply_parameters

pyrogram/methods/messages/send_contact.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import logging
1920
from datetime import datetime
2021
from typing import Union
2122

2223
import pyrogram
23-
from pyrogram import raw, utils
24-
from pyrogram import types
24+
from pyrogram import raw, utils, types
25+
26+
log = logging.getLogger(__name__)
2527

2628

2729
class SendContact:
@@ -43,7 +45,8 @@ async def send_contact(
4345
"types.ReplyKeyboardMarkup",
4446
"types.ReplyKeyboardRemove",
4547
"types.ForceReply"
46-
] = None
48+
] = None,
49+
reply_to_message_id: int = None
4750
) -> "types.Message":
4851
"""Send phone contacts.
4952
@@ -99,7 +102,20 @@ async def send_contact(
99102
await app.send_contact("me", "+1-123-456-7890", "Name")
100103
"""
101104

102-
reply_to = await utils.get_reply_head_fm(
105+
if reply_to_message_id and reply_parameters:
106+
raise ValueError(
107+
"Parameters `reply_to_message_id` and `reply_parameters` are mutually "
108+
"exclusive."
109+
)
110+
111+
if reply_to_message_id is not None:
112+
log.warning(
113+
"This property is deprecated. "
114+
"Please use reply_parameters instead"
115+
)
116+
reply_parameters = types.ReplyParameters(message_id=reply_to_message_id)
117+
118+
reply_to = await utils._get_reply_message_parameters(
103119
self,
104120
message_thread_id,
105121
reply_parameters

0 commit comments

Comments
 (0)