pyrofork/pyrogram/methods/chats/unpin_all_chat_messages.py
Yasir Aris M bd46ff3977 pyrofork: Add message_thread_id parameter to unpin_all_chat_messages()
Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
2024-12-21 00:30:11 +00:00

61 lines
2.3 KiB
Python

# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from typing import Union
import pyrogram
from pyrogram import raw
class UnpinAllChatMessages:
async def unpin_all_chat_messages(
self: "pyrogram.Client",
chat_id: Union[int, str],
message_thread_id: int = None,
) -> 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.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
message_thread_id (``int``, *optional*):
Unique identifier for the target message thread of the forum topic
Returns:
``bool``: True on success.
Example:
.. code-block:: python
# Unpin all chat messages
await app.unpin_all_chat_messages(chat_id)
"""
r = await self.invoke(
raw.functions.messages.UnpinAllMessages(
peer=await self.resolve_peer(chat_id),
top_msg_id=message_thread_id
)
)
return r.pts_count