Merge branch 'set-chat-protected-content'
This commit is contained in:
commit
80d0966691
@ -226,6 +226,7 @@ def pyrogram_api():
|
||||
get_chat_online_count
|
||||
get_send_as_chats
|
||||
set_send_as_chat
|
||||
set_chat_protected_content
|
||||
""",
|
||||
users="""
|
||||
Users
|
||||
@ -515,6 +516,7 @@ def pyrogram_api():
|
||||
Chat.join
|
||||
Chat.leave
|
||||
Chat.mark_unread
|
||||
Chat.set_protected_content
|
||||
""",
|
||||
user="""
|
||||
User
|
||||
|
@ -48,6 +48,7 @@ from .set_administrator_title import SetAdministratorTitle
|
||||
from .set_chat_description import SetChatDescription
|
||||
from .set_chat_permissions import SetChatPermissions
|
||||
from .set_chat_photo import SetChatPhoto
|
||||
from .set_chat_protected_content import SetChatProtectedContent
|
||||
from .set_chat_title import SetChatTitle
|
||||
from .set_send_as_chat import SetSendAsChat
|
||||
from .set_slow_mode import SetSlowMode
|
||||
@ -98,6 +99,7 @@ class Chats(
|
||||
GetChatEventLog,
|
||||
GetChatOnlineCount,
|
||||
GetSendAsChats,
|
||||
SetSendAsChat
|
||||
SetSendAsChat,
|
||||
SetChatProtectedContent
|
||||
):
|
||||
pass
|
||||
|
51
pyrogram/methods/chats/set_chat_protected_content.py
Normal file
51
pyrogram/methods/chats/set_chat_protected_content.py
Normal file
@ -0,0 +1,51 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2021 Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Union
|
||||
|
||||
from pyrogram.raw import functions
|
||||
from pyrogram.scaffold import Scaffold
|
||||
|
||||
|
||||
class SetChatProtectedContent(Scaffold):
|
||||
async def set_chat_protected_content(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
enabled: bool
|
||||
) -> bool:
|
||||
"""Set the chat protected content setting.
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
enabled (``bool``):
|
||||
Pass True to enable the protected content setting, False to disable.
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
"""
|
||||
|
||||
await self.send(
|
||||
functions.messages.ToggleNoForwards(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
enabled=enabled
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
@ -331,7 +331,7 @@ class Chat(Object):
|
||||
send_as_raw = users[default_send_as.user_id]
|
||||
else:
|
||||
send_as_raw = chats[default_send_as.channel_id]
|
||||
|
||||
|
||||
parsed_chat.send_as_chat = Chat._parse_chat(client, send_as_raw)
|
||||
|
||||
if full_chat.pinned_msg_id:
|
||||
@ -1019,3 +1019,30 @@ class Chat(Object):
|
||||
"""
|
||||
|
||||
return await self._client.mark_chat_unread(self.id)
|
||||
|
||||
async def set_protected_content(self, enabled: bool) -> bool:
|
||||
"""Bound method *set_protected_content* of :obj:`~pyrogram.types.Chat`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
client.set_chat_protected_content(chat_id, enabled)
|
||||
|
||||
Parameters:
|
||||
enabled (``bool``):
|
||||
Pass True to enable the protected content setting, False to disable.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
chat.set_protected_content(enabled)
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
"""
|
||||
|
||||
return await self._client.set_chat_protected_content(
|
||||
self.id,
|
||||
enabled=enabled
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user