mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-23 23:34:28 +00:00
Rename methods and add proper docs
This commit is contained in:
parent
b283bce262
commit
ac3d2b8d7a
@ -226,6 +226,7 @@ def pyrogram_api():
|
|||||||
get_chat_online_count
|
get_chat_online_count
|
||||||
get_send_as_chats
|
get_send_as_chats
|
||||||
set_send_as_chat
|
set_send_as_chat
|
||||||
|
set_chat_protected_content
|
||||||
""",
|
""",
|
||||||
users="""
|
users="""
|
||||||
Users
|
Users
|
||||||
@ -515,7 +516,7 @@ def pyrogram_api():
|
|||||||
Chat.join
|
Chat.join
|
||||||
Chat.leave
|
Chat.leave
|
||||||
Chat.mark_unread
|
Chat.mark_unread
|
||||||
Chat.no_forwards
|
Chat.set_protected_content
|
||||||
""",
|
""",
|
||||||
user="""
|
user="""
|
||||||
User
|
User
|
||||||
|
@ -48,6 +48,7 @@ from .set_administrator_title import SetAdministratorTitle
|
|||||||
from .set_chat_description import SetChatDescription
|
from .set_chat_description import SetChatDescription
|
||||||
from .set_chat_permissions import SetChatPermissions
|
from .set_chat_permissions import SetChatPermissions
|
||||||
from .set_chat_photo import SetChatPhoto
|
from .set_chat_photo import SetChatPhoto
|
||||||
|
from .set_chat_protected_content import SetChatProtectedContent
|
||||||
from .set_chat_title import SetChatTitle
|
from .set_chat_title import SetChatTitle
|
||||||
from .set_send_as_chat import SetSendAsChat
|
from .set_send_as_chat import SetSendAsChat
|
||||||
from .set_slow_mode import SetSlowMode
|
from .set_slow_mode import SetSlowMode
|
||||||
@ -56,7 +57,6 @@ from .unban_chat_member import UnbanChatMember
|
|||||||
from .unpin_all_chat_messages import UnpinAllChatMessages
|
from .unpin_all_chat_messages import UnpinAllChatMessages
|
||||||
from .unpin_chat_message import UnpinChatMessage
|
from .unpin_chat_message import UnpinChatMessage
|
||||||
from .update_chat_username import UpdateChatUsername
|
from .update_chat_username import UpdateChatUsername
|
||||||
from .toggle_no_forwards import ToggleNoForwards
|
|
||||||
|
|
||||||
|
|
||||||
class Chats(
|
class Chats(
|
||||||
@ -100,6 +100,6 @@ class Chats(
|
|||||||
GetChatOnlineCount,
|
GetChatOnlineCount,
|
||||||
GetSendAsChats,
|
GetSendAsChats,
|
||||||
SetSendAsChat,
|
SetSendAsChat,
|
||||||
ToggleNoForwards
|
SetChatProtectedContent
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
@ -22,28 +22,30 @@ from pyrogram.raw import functions
|
|||||||
from pyrogram.scaffold import Scaffold
|
from pyrogram.scaffold import Scaffold
|
||||||
|
|
||||||
|
|
||||||
class ToggleNoForwards(Scaffold):
|
class SetChatProtectedContent(Scaffold):
|
||||||
async def toggle_no_forwards(
|
async def set_chat_protected_content(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
enabled: bool = False
|
enabled: bool
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Toggle no forwards chat option
|
"""Set the chat protected content setting.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
chat_id (``int`` | ``str``):
|
chat_id (``int`` | ``str``):
|
||||||
Unique identifier (int) or username (str) of the target chat.
|
Unique identifier (int) or username (str) of the target chat.
|
||||||
|
|
||||||
enabled (``bool``, *optional*):
|
enabled (``bool``):
|
||||||
Pass True to enable no forwards
|
Pass True to enable the protected content setting, False to disable.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self.send(
|
await self.send(
|
||||||
functions.messages.ToggleNoForwards(
|
functions.messages.ToggleNoForwards(
|
||||||
peer=await self.resolve_peer(chat_id),
|
peer=await self.resolve_peer(chat_id),
|
||||||
enabled=enabled
|
enabled=enabled
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return True
|
@ -325,7 +325,7 @@ class Chat(Object):
|
|||||||
send_as_raw = users[default_send_as.user_id]
|
send_as_raw = users[default_send_as.user_id]
|
||||||
else:
|
else:
|
||||||
send_as_raw = chats[default_send_as.channel_id]
|
send_as_raw = chats[default_send_as.channel_id]
|
||||||
|
|
||||||
parsed_chat.send_as_chat = Chat._parse_chat(client, send_as_raw)
|
parsed_chat.send_as_chat = Chat._parse_chat(client, send_as_raw)
|
||||||
|
|
||||||
if full_chat.pinned_msg_id:
|
if full_chat.pinned_msg_id:
|
||||||
@ -1012,25 +1012,29 @@ class Chat(Object):
|
|||||||
|
|
||||||
return await self._client.mark_chat_unread(self.id)
|
return await self._client.mark_chat_unread(self.id)
|
||||||
|
|
||||||
async def no_forwards(self, enabled: bool = False) -> bool:
|
async def set_protected_content(self, enabled: bool) -> bool:
|
||||||
"""Bound method *toggle_no_forwards* of :obj:`~pyrogram.types.Chat`.
|
"""Bound method *set_protected_content* of :obj:`~pyrogram.types.Chat`.
|
||||||
|
|
||||||
Use as a shortcut for:
|
Use as a shortcut for:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
client.toggle_no_forwards(chat_id, enabled)
|
client.set_chat_protected_content(chat_id, enabled)
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
enabled (``bool``):
|
||||||
|
Pass True to enable the protected content setting, False to disable.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
chat.toggle_no_forwards(True)
|
chat.set_protected_content(enabled)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``bool``: On success, True is returned.
|
``bool``: On success, True is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return await self._client.toggle_no_forwards(
|
return await self._client.set_chat_protected_content(
|
||||||
self.id,
|
self.id,
|
||||||
enabled=enabled
|
enabled=enabled
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user