Add parameter protect_content to send_* methods

This commit is contained in:
Dan 2022-01-03 11:12:24 +01:00
parent fb64e143b6
commit f6625192d0
19 changed files with 100 additions and 4 deletions

View File

@ -30,6 +30,7 @@ class SendGame(Scaffold):
game_short_name: str,
disable_notification: bool = None,
reply_to_message_id: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -55,6 +56,9 @@ class SendGame(Scaffold):
reply_to_message_id (``int``, *optional*):
If the message is a reply, ID of the original message.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
An object for an inline keyboard. If empty, one Play game_title button will be shown automatically.
If not empty, the first button must launch the game.
@ -80,6 +84,7 @@ class SendGame(Scaffold):
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
)

View File

@ -37,6 +37,7 @@ class CopyMessage(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -88,6 +89,9 @@ class CopyMessage(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -112,5 +116,6 @@ class CopyMessage(Scaffold):
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
schedule_date=schedule_date,
protect_content=protect_content,
reply_markup=reply_markup
)

View File

@ -30,7 +30,8 @@ class ForwardMessages(Scaffold):
from_chat_id: Union[int, str],
message_ids: Union[int, Iterable[int]],
disable_notification: bool = None,
schedule_date: int = None
schedule_date: int = None,
protect_content: bool = None
) -> Union["types.Message", List["types.Message"]]:
"""Forward messages of any kind.
@ -56,6 +57,9 @@ class ForwardMessages(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
Returns:
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was an
integer, the single forwarded message is returned, otherwise, in case *message_ids* was an iterable,
@ -82,7 +86,8 @@ class ForwardMessages(Scaffold):
id=message_ids,
silent=disable_notification or None,
random_id=[self.rnd_id() for _ in message_ids],
schedule_date=schedule_date
schedule_date=schedule_date,
noforwards=protect_content
)
)

View File

@ -46,6 +46,7 @@ class SendAnimation(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -116,6 +117,9 @@ class SendAnimation(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -222,6 +226,7 @@ class SendAnimation(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -45,6 +45,7 @@ class SendAudio(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -113,6 +114,9 @@ class SendAudio(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -217,6 +221,7 @@ class SendAudio(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -34,6 +34,7 @@ class SendContact(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -71,6 +72,9 @@ class SendContact(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -97,6 +101,7 @@ class SendContact(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
)

View File

@ -31,6 +31,7 @@ class SendDice(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -63,6 +64,9 @@ class SendDice(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -91,6 +95,7 @@ class SendDice(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
message=""
)

View File

@ -43,6 +43,7 @@ class SendDocument(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -105,6 +106,9 @@ class SendDocument(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -194,6 +198,7 @@ class SendDocument(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -32,6 +32,7 @@ class SendLocation(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -63,6 +64,9 @@ class SendLocation(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -89,6 +93,7 @@ class SendLocation(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
)

View File

@ -44,6 +44,7 @@ class SendMediaGroup(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
) -> List["types.Message"]:
"""Send a group of photos or videos as an album.
@ -66,6 +67,9 @@ class SendMediaGroup(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
Returns:
List of :obj:`~pyrogram.types.Message`: On success, a list of the sent messages is returned.
@ -377,7 +381,8 @@ class SendMediaGroup(Scaffold):
multi_media=multi_media,
silent=disable_notification or None,
reply_to_msg_id=reply_to_message_id,
schedule_date=schedule_date
schedule_date=schedule_date,
noforwards=protect_content
),
sleep_threshold=60
)

View File

@ -34,6 +34,7 @@ class SendMessage(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -75,6 +76,9 @@ class SendMessage(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -132,7 +136,8 @@ class SendMessage(Scaffold):
schedule_date=schedule_date,
reply_markup=await reply_markup.write(self) if reply_markup else None,
message=message,
entities=entities
entities=entities,
noforwards=protect_content
)
)

View File

@ -41,6 +41,7 @@ class SendPhoto(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -93,6 +94,9 @@ class SendPhoto(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -172,6 +176,7 @@ class SendPhoto(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -36,6 +36,7 @@ class SendPoll(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -83,6 +84,9 @@ class SendPoll(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -117,6 +121,7 @@ class SendPoll(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
)

View File

@ -37,6 +37,7 @@ class SendSticker(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -71,6 +72,9 @@ class SendSticker(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -150,6 +154,7 @@ class SendSticker(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
message=""
)

View File

@ -36,6 +36,7 @@ class SendVenue(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -80,6 +81,9 @@ class SendVenue(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -113,6 +117,7 @@ class SendVenue(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
)

View File

@ -47,6 +47,7 @@ class SendVideo(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -122,6 +123,9 @@ class SendVideo(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -228,6 +232,7 @@ class SendVideo(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -39,6 +39,7 @@ class SendVideoNote(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -85,6 +86,9 @@ class SendVideoNote(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -174,6 +178,7 @@ class SendVideoNote(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
message=""
)

View File

@ -41,6 +41,7 @@ class SendVoice(Scaffold):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -91,6 +92,9 @@ class SendVoice(Scaffold):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -178,6 +182,7 @@ class SendVoice(Scaffold):
reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(),
schedule_date=schedule_date,
noforwards=protect_content,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
)

View File

@ -2924,6 +2924,7 @@ class Message(Object, Update):
disable_notification: bool = None,
reply_to_message_id: int = None,
schedule_date: int = None,
protect_content: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
@ -2979,6 +2980,9 @@ class Message(Object, Update):
schedule_date (``int``, *optional*):
Date when the message will be automatically sent. Unix time.
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
@ -3008,6 +3012,7 @@ class Message(Object, Update):
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
schedule_date=schedule_date,
protect_content=protect_content,
reply_markup=self.reply_markup if reply_markup is object else reply_markup
)
elif self.media:
@ -3017,6 +3022,7 @@ class Message(Object, Update):
disable_notification=disable_notification,
reply_to_message_id=reply_to_message_id,
schedule_date=schedule_date,
protect_content=protect_content,
reply_markup=self.reply_markup if reply_markup is object else reply_markup
)