Skip to content

Commit 19f5c05

Browse files
committed
Fix allow_sending_without_reply in reply_to
1 parent aacfc9e commit 19f5c05

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

telebot/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,7 @@ def ban_chat_member(
34723472
less than 30 seconds from the current time they are considered to be banned forever
34733473
:type until_date: :obj:`int` or :obj:`datetime`
34743474
3475-
:param revoke_messages: Bool: Pass True to delete all messages from the chat for the user that is being removed.
3475+
:param revoke_messages: Pass True to delete all messages from the chat for the user that is being removed.
34763476
If False, the user will be able to see messages in the group that were sent before the user was removed.
34773477
Always True for supergroups and channels.
34783478
:type revoke_messages: :obj:`bool`
@@ -3545,7 +3545,7 @@ def restrict_chat_member(
35453545
:param until_date: Date when restrictions will be lifted for the user, unix time.
35463546
If user is restricted for more than 366 days or less than 30 seconds from the current time,
35473547
they are considered to be restricted forever
3548-
:type until_date: :obj:`int` or :obj:`datetime`
3548+
:type until_date: :obj:`int` or :obj:`datetime`, optional
35493549
35503550
:param can_send_messages: deprecated
35513551
:type can_send_messages: :obj:`bool`
@@ -3571,10 +3571,11 @@ def restrict_chat_member(
35713571
:param can_pin_messages: deprecated
35723572
:type can_pin_messages: :obj:`bool`
35733573
3574-
:param use_independent_chat_permissions: Optional Pass True if chat permissions are set independently.
3574+
:param use_independent_chat_permissions: Pass True if chat permissions are set independently.
35753575
Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages,
35763576
can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes
35773577
permissions; the can_send_polls permission will imply the can_send_messages permission.
3578+
:type use_independent_chat_permissions: :obj:`bool`, optional
35783579
35793580
:param permissions: ChatPermissions object defining permissions.
35803581
:type permissions: :class:`telebot.types.ChatPermissions`
@@ -5251,14 +5252,16 @@ def reply_to(self, message: types.Message, text: str, **kwargs) -> types.Message
52515252
"""
52525253
if kwargs:
52535254
reply_parameters = kwargs.pop("reply_parameters", None)
5255+
if "allow_sending_without_reply" in kwargs:
5256+
logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.")
52545257
else:
52555258
reply_parameters = None
5256-
if not reply_parameters:
5257-
reply_parameters = types.ReplyParameters(message.message_id)
52585259

5259-
if "allow_sending_without_reply" in kwargs:
5260-
logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.")
5261-
reply_parameters.allow_sending_without_reply = kwargs.pop("allow_sending_without_reply")
5260+
if not reply_parameters:
5261+
reply_parameters = types.ReplyParameters(
5262+
message.message_id,
5263+
allow_sending_without_reply=kwargs.pop("allow_sending_without_reply", None) if kwargs else None
5264+
)
52625265

52635266
return self.send_message(message.chat.id, text, reply_parameters=reply_parameters, **kwargs)
52645267

telebot/async_telebot.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4606,7 +4606,7 @@ async def restrict_chat_member(
46064606
:param until_date: Date when restrictions will be lifted for the user, unix time.
46074607
If user is restricted for more than 366 days or less than 30 seconds from the current time,
46084608
they are considered to be restricted forever
4609-
:type until_date: :obj:`int` or :obj:`datetime`
4609+
:type until_date: :obj:`int` or :obj:`datetime`, optional
46104610
46114611
:param can_send_messages: deprecated
46124612
:type can_send_messages: :obj:`bool`
@@ -4632,10 +4632,11 @@ async def restrict_chat_member(
46324632
:param can_pin_messages: deprecated
46334633
:type can_pin_messages: :obj:`bool`
46344634
4635-
:param use_independent_chat_permissions: Optional Pass True if chat permissions are set independently.
4635+
:param use_independent_chat_permissions: Pass True if chat permissions are set independently.
46364636
Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages,
46374637
can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes
46384638
permissions; the can_send_polls permission will imply the can_send_messages permission.
4639+
:type use_independent_chat_permissions: :obj:`bool`, optional
46394640
46404641
:param permissions: Pass ChatPermissions object to set all permissions at once. Use this parameter instead of
46414642
passing all boolean parameters to avoid backward compatibility problems in future.
@@ -6234,14 +6235,16 @@ async def reply_to(self, message: types.Message, text: str, **kwargs) -> types.M
62346235
"""
62356236
if kwargs:
62366237
reply_parameters = kwargs.pop("reply_parameters", None)
6238+
if "allow_sending_without_reply" in kwargs:
6239+
logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.")
62376240
else:
62386241
reply_parameters = None
6239-
if not reply_parameters:
6240-
reply_parameters = types.ReplyParameters(message.message_id)
62416242

6242-
if "allow_sending_without_reply" in kwargs:
6243-
logger.warning("The parameter 'allow_sending_without_reply' is deprecated. Use 'reply_parameters' instead.")
6244-
reply_parameters.allow_sending_without_reply = kwargs.pop("allow_sending_without_reply")
6243+
if not reply_parameters:
6244+
reply_parameters = types.ReplyParameters(
6245+
message.message_id,
6246+
allow_sending_without_reply=kwargs.pop("allow_sending_without_reply", None) if kwargs else None
6247+
)
62456248

62466249
return await self.send_message(message.chat.id, text, reply_parameters=reply_parameters, **kwargs)
62476250

0 commit comments

Comments
 (0)