Add Message/Chat.has_protected_content

This commit is contained in:
Dan 2021-12-22 14:49:28 +01:00
parent 2024b3c120
commit a138b46668
2 changed files with 13 additions and 0 deletions

View File

@ -128,6 +128,9 @@ class Message(Object, Update):
Signature of the post author for messages in channels, or the custom title of an anonymous group Signature of the post author for messages in channels, or the custom title of an anonymous group
administrator. administrator.
has_protected_content (``str``, *optional*):
True, if the message can't be forwarded.
text (``str``, *optional*): text (``str``, *optional*):
For text messages, the actual UTF-8 text of the message, 0-4096 characters. For text messages, the actual UTF-8 text of the message, 0-4096 characters.
If the message contains entities (bold, italic, ...) you can access *text.markdown* or If the message contains entities (bold, italic, ...) you can access *text.markdown* or
@ -312,6 +315,7 @@ class Message(Object, Update):
edit_date: int = None, edit_date: int = None,
media_group_id: str = None, media_group_id: str = None,
author_signature: str = None, author_signature: str = None,
has_protected_content: bool = None,
text: Str = None, text: Str = None,
entities: List["types.MessageEntity"] = None, entities: List["types.MessageEntity"] = None,
caption_entities: List["types.MessageEntity"] = None, caption_entities: List["types.MessageEntity"] = None,
@ -382,6 +386,7 @@ class Message(Object, Update):
self.edit_date = edit_date self.edit_date = edit_date
self.media_group_id = media_group_id self.media_group_id = media_group_id
self.author_signature = author_signature self.author_signature = author_signature
self.has_protected_content = has_protected_content
self.text = text self.text = text
self.entities = entities self.entities = entities
self.caption_entities = caption_entities self.caption_entities = caption_entities
@ -743,6 +748,7 @@ class Message(Object, Update):
else None else None
), ),
author_signature=message.post_author, author_signature=message.post_author,
has_protected_content=message.noforwards,
forward_from=forward_from, forward_from=forward_from,
forward_sender_name=forward_sender_name, forward_sender_name=forward_sender_name,
forward_from_chat=forward_from_chat, forward_from_chat=forward_from_chat,

View File

@ -83,6 +83,9 @@ class Chat(Object):
It is accurate only in case the owner has set the chat photo, otherwise the dc_id will be the one assigned It is accurate only in case the owner has set the chat photo, otherwise the dc_id will be the one assigned
to the administrator who set the current chat photo. to the administrator who set the current chat photo.
has_protected_content (``bool``, *optional*):
True, if messages from the chat can't be forwarded to other chats.
invite_link (``str``, *optional*): invite_link (``str``, *optional*):
Chat invite link, for groups, supergroups and channels. Chat invite link, for groups, supergroups and channels.
Returned only in :meth:`~pyrogram.Client.get_chat`. Returned only in :meth:`~pyrogram.Client.get_chat`.
@ -139,6 +142,7 @@ class Chat(Object):
bio: str = None, bio: str = None,
description: str = None, description: str = None,
dc_id: int = None, dc_id: int = None,
has_protected_content: bool = None,
invite_link: str = None, invite_link: str = None,
pinned_message=None, pinned_message=None,
sticker_set_name: str = None, sticker_set_name: str = None,
@ -167,6 +171,7 @@ class Chat(Object):
self.bio = bio self.bio = bio
self.description = description self.description = description
self.dc_id = dc_id self.dc_id = dc_id
self.has_protected_content = has_protected_content
self.invite_link = invite_link self.invite_link = invite_link
self.pinned_message = pinned_message self.pinned_message = pinned_message
self.sticker_set_name = sticker_set_name self.sticker_set_name = sticker_set_name
@ -211,6 +216,7 @@ class Chat(Object):
permissions=types.ChatPermissions._parse(getattr(chat, "default_banned_rights", None)), permissions=types.ChatPermissions._parse(getattr(chat, "default_banned_rights", None)),
members_count=getattr(chat, "participants_count", None), members_count=getattr(chat, "participants_count", None),
dc_id=getattr(getattr(chat, "photo", None), "dc_id", None), dc_id=getattr(getattr(chat, "photo", None), "dc_id", None),
has_protected_content=chat.noforwards,
client=client client=client
) )
@ -234,6 +240,7 @@ class Chat(Object):
permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)), permissions=types.ChatPermissions._parse(getattr(channel, "default_banned_rights", None)),
members_count=getattr(channel, "participants_count", None), members_count=getattr(channel, "participants_count", None),
dc_id=getattr(getattr(channel, "photo", None), "dc_id", None), dc_id=getattr(getattr(channel, "photo", None), "dc_id", None),
has_protected_content=channel.noforwards,
client=client client=client
) )