Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit f662519

Browse files
committed
Add parameter protect_content to send_* methods
1 parent fb64e14 commit f662519

19 files changed

+100
-4
lines changed

pyrogram/methods/bots/send_game.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ async def send_game(
3030
game_short_name: str,
3131
disable_notification: bool = None,
3232
reply_to_message_id: int = None,
33+
protect_content: bool = None,
3334
reply_markup: Union[
3435
"types.InlineKeyboardMarkup",
3536
"types.ReplyKeyboardMarkup",
@@ -55,6 +56,9 @@ async def send_game(
5556
reply_to_message_id (``int``, *optional*):
5657
If the message is a reply, ID of the original message.
5758
59+
protect_content (``bool``, *optional*):
60+
Protects the contents of the sent message from forwarding and saving.
61+
5862
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
5963
An object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown automatically.
6064
If not empty, the first button must launch the game.
@@ -80,6 +84,7 @@ async def send_game(
8084
silent=disable_notification or None,
8185
reply_to_msg_id=reply_to_message_id,
8286
random_id=self.rnd_id(),
87+
noforwards=protect_content,
8388
reply_markup=await reply_markup.write(self) if reply_markup else None
8489
)
8590
)

pyrogram/methods/messages/copy_message.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async def copy_message(
3737
disable_notification: bool = None,
3838
reply_to_message_id: int = None,
3939
schedule_date: int = None,
40+
protect_content: bool = None,
4041
reply_markup: Union[
4142
"types.InlineKeyboardMarkup",
4243
"types.ReplyKeyboardMarkup",
@@ -88,6 +89,9 @@ async def copy_message(
8889
schedule_date (``int``, *optional*):
8990
Date when the message will be automatically sent. Unix time.
9091
92+
protect_content (``bool``, *optional*):
93+
Protects the contents of the sent message from forwarding and saving.
94+
9195
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
9296
Additional interface options. An object for an inline keyboard, custom reply keyboard,
9397
instructions to remove reply keyboard or to force a reply from the user.
@@ -112,5 +116,6 @@ async def copy_message(
112116
disable_notification=disable_notification,
113117
reply_to_message_id=reply_to_message_id,
114118
schedule_date=schedule_date,
119+
protect_content=protect_content,
115120
reply_markup=reply_markup
116121
)

pyrogram/methods/messages/forward_messages.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ async def forward_messages(
3030
from_chat_id: Union[int, str],
3131
message_ids: Union[int, Iterable[int]],
3232
disable_notification: bool = None,
33-
schedule_date: int = None
33+
schedule_date: int = None,
34+
protect_content: bool = None
3435
) -> Union["types.Message", List["types.Message"]]:
3536
"""Forward messages of any kind.
3637
@@ -56,6 +57,9 @@ async def forward_messages(
5657
schedule_date (``int``, *optional*):
5758
Date when the message will be automatically sent. Unix time.
5859
60+
protect_content (``bool``, *optional*):
61+
Protects the contents of the sent message from forwarding and saving.
62+
5963
Returns:
6064
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was an
6165
integer, the single forwarded message is returned, otherwise, in case *message_ids* was an iterable,
@@ -82,7 +86,8 @@ async def forward_messages(
8286
id=message_ids,
8387
silent=disable_notification or None,
8488
random_id=[self.rnd_id() for _ in message_ids],
85-
schedule_date=schedule_date
89+
schedule_date=schedule_date,
90+
noforwards=protect_content
8691
)
8792
)
8893

pyrogram/methods/messages/send_animation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ async def send_animation(
4646
disable_notification: bool = None,
4747
reply_to_message_id: int = None,
4848
schedule_date: int = None,
49+
protect_content: bool = None,
4950
reply_markup: Union[
5051
"types.InlineKeyboardMarkup",
5152
"types.ReplyKeyboardMarkup",
@@ -116,6 +117,9 @@ async def send_animation(
116117
schedule_date (``int``, *optional*):
117118
Date when the message will be automatically sent. Unix time.
118119
120+
protect_content (``bool``, *optional*):
121+
Protects the contents of the sent message from forwarding and saving.
122+
119123
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
120124
Additional interface options. An object for an inline keyboard, custom reply keyboard,
121125
instructions to remove reply keyboard or to force a reply from the user.
@@ -222,6 +226,7 @@ def progress(current, total):
222226
reply_to_msg_id=reply_to_message_id,
223227
random_id=self.rnd_id(),
224228
schedule_date=schedule_date,
229+
noforwards=protect_content,
225230
reply_markup=await reply_markup.write(self) if reply_markup else None,
226231
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
227232
)

pyrogram/methods/messages/send_audio.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def send_audio(
4545
disable_notification: bool = None,
4646
reply_to_message_id: int = None,
4747
schedule_date: int = None,
48+
protect_content: bool = None,
4849
reply_markup: Union[
4950
"types.InlineKeyboardMarkup",
5051
"types.ReplyKeyboardMarkup",
@@ -113,6 +114,9 @@ async def send_audio(
113114
schedule_date (``int``, *optional*):
114115
Date when the message will be automatically sent. Unix time.
115116
117+
protect_content (``bool``, *optional*):
118+
Protects the contents of the sent message from forwarding and saving.
119+
116120
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
117121
Additional interface options. An object for an inline keyboard, custom reply keyboard,
118122
instructions to remove reply keyboard or to force a reply from the user.
@@ -217,6 +221,7 @@ def progress(current, total):
217221
reply_to_msg_id=reply_to_message_id,
218222
random_id=self.rnd_id(),
219223
schedule_date=schedule_date,
224+
noforwards=protect_content,
220225
reply_markup=await reply_markup.write(self) if reply_markup else None,
221226
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
222227
)

pyrogram/methods/messages/send_contact.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async def send_contact(
3434
disable_notification: bool = None,
3535
reply_to_message_id: int = None,
3636
schedule_date: int = None,
37+
protect_content: bool = None,
3738
reply_markup: Union[
3839
"types.InlineKeyboardMarkup",
3940
"types.ReplyKeyboardMarkup",
@@ -71,6 +72,9 @@ async def send_contact(
7172
schedule_date (``int``, *optional*):
7273
Date when the message will be automatically sent. Unix time.
7374
75+
protect_content (``bool``, *optional*):
76+
Protects the contents of the sent message from forwarding and saving.
77+
7478
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
7579
Additional interface options. An object for an inline keyboard, custom reply keyboard,
7680
instructions to remove reply keyboard or to force a reply from the user.
@@ -97,6 +101,7 @@ async def send_contact(
97101
reply_to_msg_id=reply_to_message_id,
98102
random_id=self.rnd_id(),
99103
schedule_date=schedule_date,
104+
noforwards=protect_content,
100105
reply_markup=await reply_markup.write(self) if reply_markup else None
101106
)
102107
)

pyrogram/methods/messages/send_dice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async def send_dice(
3131
disable_notification: bool = None,
3232
reply_to_message_id: int = None,
3333
schedule_date: int = None,
34+
protect_content: bool = None,
3435
reply_markup: Union[
3536
"types.InlineKeyboardMarkup",
3637
"types.ReplyKeyboardMarkup",
@@ -63,6 +64,9 @@ async def send_dice(
6364
schedule_date (``int``, *optional*):
6465
Date when the message will be automatically sent. Unix time.
6566
67+
protect_content (``bool``, *optional*):
68+
Protects the contents of the sent message from forwarding and saving.
69+
6670
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
6771
Additional interface options. An object for an inline keyboard, custom reply keyboard,
6872
instructions to remove reply keyboard or to force a reply from the user.
@@ -91,6 +95,7 @@ async def send_dice(
9195
reply_to_msg_id=reply_to_message_id,
9296
random_id=self.rnd_id(),
9397
schedule_date=schedule_date,
98+
noforwards=protect_content,
9499
reply_markup=await reply_markup.write(self) if reply_markup else None,
95100
message=""
96101
)

pyrogram/methods/messages/send_document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async def send_document(
4343
disable_notification: bool = None,
4444
reply_to_message_id: int = None,
4545
schedule_date: int = None,
46+
protect_content: bool = None,
4647
reply_markup: Union[
4748
"types.InlineKeyboardMarkup",
4849
"types.ReplyKeyboardMarkup",
@@ -105,6 +106,9 @@ async def send_document(
105106
schedule_date (``int``, *optional*):
106107
Date when the message will be automatically sent. Unix time.
107108
109+
protect_content (``bool``, *optional*):
110+
Protects the contents of the sent message from forwarding and saving.
111+
108112
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
109113
Additional interface options. An object for an inline keyboard, custom reply keyboard,
110114
instructions to remove reply keyboard or to force a reply from the user.
@@ -194,6 +198,7 @@ def progress(current, total):
194198
reply_to_msg_id=reply_to_message_id,
195199
random_id=self.rnd_id(),
196200
schedule_date=schedule_date,
201+
noforwards=protect_content,
197202
reply_markup=await reply_markup.write(self) if reply_markup else None,
198203
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
199204
)

pyrogram/methods/messages/send_location.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async def send_location(
3232
disable_notification: bool = None,
3333
reply_to_message_id: int = None,
3434
schedule_date: int = None,
35+
protect_content: bool = None,
3536
reply_markup: Union[
3637
"types.InlineKeyboardMarkup",
3738
"types.ReplyKeyboardMarkup",
@@ -63,6 +64,9 @@ async def send_location(
6364
schedule_date (``int``, *optional*):
6465
Date when the message will be automatically sent. Unix time.
6566
67+
protect_content (``bool``, *optional*):
68+
Protects the contents of the sent message from forwarding and saving.
69+
6670
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
6771
Additional interface options. An object for an inline keyboard, custom reply keyboard,
6872
instructions to remove reply keyboard or to force a reply from the user.
@@ -89,6 +93,7 @@ async def send_location(
8993
reply_to_msg_id=reply_to_message_id,
9094
random_id=self.rnd_id(),
9195
schedule_date=schedule_date,
96+
noforwards=protect_content,
9297
reply_markup=await reply_markup.write(self) if reply_markup else None
9398
)
9499
)

pyrogram/methods/messages/send_media_group.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def send_media_group(
4444
disable_notification: bool = None,
4545
reply_to_message_id: int = None,
4646
schedule_date: int = None,
47+
protect_content: bool = None,
4748
) -> List["types.Message"]:
4849
"""Send a group of photos or videos as an album.
4950
@@ -66,6 +67,9 @@ async def send_media_group(
6667
schedule_date (``int``, *optional*):
6768
Date when the message will be automatically sent. Unix time.
6869
70+
protect_content (``bool``, *optional*):
71+
Protects the contents of the sent message from forwarding and saving.
72+
6973
Returns:
7074
List of :obj:`~pyrogram.types.Message`: On success, a list of the sent messages is returned.
7175
@@ -377,7 +381,8 @@ async def send_media_group(
377381
multi_media=multi_media,
378382
silent=disable_notification or None,
379383
reply_to_msg_id=reply_to_message_id,
380-
schedule_date=schedule_date
384+
schedule_date=schedule_date,
385+
noforwards=protect_content
381386
),
382387
sleep_threshold=60
383388
)

0 commit comments

Comments
 (0)