mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add new method unpin_all_chat_messages
This commit is contained in:
parent
c7e4e55607
commit
ebf2d68386
@ -197,6 +197,7 @@ def pyrogram_api():
|
||||
set_chat_permissions
|
||||
pin_chat_message
|
||||
unpin_chat_message
|
||||
unpin_all_chat_messages
|
||||
get_chat
|
||||
get_chat_member
|
||||
get_chat_members
|
||||
|
@ -49,6 +49,7 @@ from .set_chat_title import SetChatTitle
|
||||
from .set_slow_mode import SetSlowMode
|
||||
from .unarchive_chats import UnarchiveChats
|
||||
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
|
||||
|
||||
@ -88,6 +89,7 @@ class Chats(
|
||||
GetNearbyChats,
|
||||
SetAdministratorTitle,
|
||||
SetSlowMode,
|
||||
DeleteUserHistory
|
||||
DeleteUserHistory,
|
||||
UnpinAllChatMessages
|
||||
):
|
||||
pass
|
||||
|
53
pyrogram/methods/chats/unpin_all_chat_messages.py
Normal file
53
pyrogram/methods/chats/unpin_all_chat_messages.py
Normal file
@ -0,0 +1,53 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2020 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 import raw
|
||||
from pyrogram.scaffold import Scaffold
|
||||
|
||||
|
||||
class UnpinAllChatMessages(Scaffold):
|
||||
async def unpin_all_chat_messages(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
) -> bool:
|
||||
"""Use this method to clear the list of pinned messages in a chat.
|
||||
If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have
|
||||
the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel.
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
Returns:
|
||||
``bool``: True on success.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
# Unpin all chat messages
|
||||
app.unpin_all_chat_messages(chat_id)
|
||||
"""
|
||||
await self.send(
|
||||
raw.functions.messages.UnpinAllMessages(
|
||||
peer=await self.resolve_peer(chat_id)
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
@ -26,7 +26,7 @@ class UnpinChatMessage(Scaffold):
|
||||
async def unpin_chat_message(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
message_id: int
|
||||
message_id: int = 0
|
||||
) -> bool:
|
||||
"""Unpin a message in a group, channel or your own chat.
|
||||
You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin
|
||||
@ -36,8 +36,9 @@ class UnpinChatMessage(Scaffold):
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
message_id (``int``):
|
||||
message_id (``int``, *optional*):
|
||||
Identifier of a message to unpin.
|
||||
If not specified, the most recent pinned message (by sending date) will be unpinned.
|
||||
|
||||
Returns:
|
||||
``bool``: True on success.
|
||||
|
Loading…
Reference in New Issue
Block a user