Skip to content

Commit

Permalink
Add message_thread_id to unpin_all_chat_messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Mar 30, 2024
1 parent f887404 commit 3afa71f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ it can take advantage of new goodies!
| Scheme layer used: 176 |
+------------------------+

- Add ``message_thread_id`` parameter to :meth:`~pyrogram.Client.unpin_all_chat_messages`.
- Add :meth:`~pyrogram.Client.create_forum_topic`, :meth:`~pyrogram.Client.edit_forum_topic`, :meth:`~pyrogram.Client.close_forum_topic`, :meth:`~pyrogram.Client.reopen_forum_topic`, :meth:`~pyrogram.Client.hide_forum_topic`, :meth:`~pyrogram.Client.unhide_forum_topic`, :meth:`~pyrogram.Client.delete_forum_topic`.
- Add ``AioSQLiteStorage``, by stealing the following commits:
- `fded06e <https://github.com/KurimuzonAkuma/pyrogram/commit/fded06e7bdf8bb591fb5857d0f126986ccf357c8>`_
Expand Down
19 changes: 12 additions & 7 deletions pyrogram/methods/chats/unpin_all_chat_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class UnpinAllChatMessages:
async def unpin_all_chat_messages(
self: "pyrogram.Client",
chat_id: Union[int, str],
) -> bool:
"""Use this method to clear the list of pinned messages in a chat.
message_thread_id: int = None
) -> int:
"""
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.
Expand All @@ -37,19 +39,22 @@ async def unpin_all_chat_messages(
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
message_thread_id (``int``, *optional*):
Unique identifier for the target message thread of the forum topic
Returns:
``bool``: True on success.
``int``: Amount of affected messages
Example:
.. code-block:: python
# Unpin all chat messages
await app.unpin_all_chat_messages(chat_id)
"""
await self.invoke(
r = await self.invoke(
raw.functions.messages.UnpinAllMessages(
peer=await self.resolve_peer(chat_id)
peer=await self.resolve_peer(chat_id),
top_msg_id=message_thread_id
)
)

return True
return r.pts_count

0 comments on commit 3afa71f

Please sign in to comment.