Add No Forwards chat option (#839)
* Add No Forwards chat option * Fix chat.py
This commit is contained in:
parent
00c91120d8
commit
b283bce262
@ -515,6 +515,7 @@ def pyrogram_api():
|
||||
Chat.join
|
||||
Chat.leave
|
||||
Chat.mark_unread
|
||||
Chat.no_forwards
|
||||
""",
|
||||
user="""
|
||||
User
|
||||
|
@ -56,6 +56,7 @@ from .unban_chat_member import UnbanChatMember
|
||||
from .unpin_all_chat_messages import UnpinAllChatMessages
|
||||
from .unpin_chat_message import UnpinChatMessage
|
||||
from .update_chat_username import UpdateChatUsername
|
||||
from .toggle_no_forwards import ToggleNoForwards
|
||||
|
||||
|
||||
class Chats(
|
||||
@ -98,6 +99,7 @@ class Chats(
|
||||
GetChatEventLog,
|
||||
GetChatOnlineCount,
|
||||
GetSendAsChats,
|
||||
SetSendAsChat
|
||||
SetSendAsChat,
|
||||
ToggleNoForwards
|
||||
):
|
||||
pass
|
||||
|
49
pyrogram/methods/chats/toggle_no_forwards.py
Normal file
49
pyrogram/methods/chats/toggle_no_forwards.py
Normal file
@ -0,0 +1,49 @@
|
||||
# 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 ToggleNoForwards(Scaffold):
|
||||
async def toggle_no_forwards(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
enabled: bool = False
|
||||
) -> bool:
|
||||
"""Toggle no forwards chat option
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
enabled (``bool``, *optional*):
|
||||
Pass True to enable no forwards
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
"""
|
||||
|
||||
return await self.send(
|
||||
functions.messages.ToggleNoForwards(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
enabled=enabled
|
||||
)
|
||||
)
|
@ -1011,3 +1011,26 @@ class Chat(Object):
|
||||
"""
|
||||
|
||||
return await self._client.mark_chat_unread(self.id)
|
||||
|
||||
async def no_forwards(self, enabled: bool = False) -> bool:
|
||||
"""Bound method *toggle_no_forwards* of :obj:`~pyrogram.types.Chat`.
|
||||
|
||||
Use as a shortcut for:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
client.toggle_no_forwards(chat_id, enabled)
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
chat.toggle_no_forwards(True)
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
"""
|
||||
|
||||
return await self._client.toggle_no_forwards(
|
||||
self.id,
|
||||
enabled=enabled
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user