mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add pin/unpin_forum_topic method
This commit is contained in:
parent
22030ece5e
commit
a8a7537b26
@ -224,6 +224,8 @@ def pyrogram_api():
|
||||
set_chat_permissions
|
||||
pin_chat_message
|
||||
unpin_chat_message
|
||||
pin_forum_topic
|
||||
unpin_forum_topic
|
||||
unpin_all_chat_messages
|
||||
get_chat
|
||||
get_chat_member
|
||||
|
@ -52,6 +52,7 @@ from .leave_chat import LeaveChat
|
||||
from .leave_folder import LeaveFolder
|
||||
from .mark_chat_unread import MarkChatUnread
|
||||
from .pin_chat_message import PinChatMessage
|
||||
from .pin_forum_topic import PinForumTopic
|
||||
from .promote_chat_member import PromoteChatMember
|
||||
from .restrict_chat_member import RestrictChatMember
|
||||
from .set_administrator_title import SetAdministratorTitle
|
||||
@ -71,6 +72,7 @@ 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 .unpin_forum_topic import UnpinForumTopic
|
||||
from .update_chat_notifications import UpdateChatNotifications
|
||||
from .update_color import UpdateColor
|
||||
from .update_folder import UpdateFolder
|
||||
@ -96,6 +98,8 @@ class Chats(
|
||||
SetChatDescription,
|
||||
PinChatMessage,
|
||||
UnpinChatMessage,
|
||||
PinForumTopic,
|
||||
UnpinForumTopic,
|
||||
UpdateChatNotifications,
|
||||
UpdateColor,
|
||||
UpdateFolder,
|
||||
|
@ -40,7 +40,7 @@ class CloseForumTopic:
|
||||
Unique identifier (int) of the target forum topic.
|
||||
|
||||
Returns:
|
||||
`bool`: On success, a Boolean is returned.
|
||||
``bool``: On success, True is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
@ -40,7 +40,7 @@ class DeleteForumTopic:
|
||||
Unique identifier (int) of the target forum topic.
|
||||
|
||||
Returns:
|
||||
`bool`: On success, a Boolean is returned.
|
||||
``bool``: On success, True is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
@ -56,7 +56,7 @@ class EditForumTopic:
|
||||
Hide forum topic.
|
||||
|
||||
Returns:
|
||||
`bool`: On success, a Boolean is returned.
|
||||
``bool``: On success, True is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
57
pyrogram/methods/chats/pin_forum_topic.py
Normal file
57
pyrogram/methods/chats/pin_forum_topic.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present 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/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from typing import Union
|
||||
|
||||
|
||||
class PinForumTopic:
|
||||
async def pin_forum_topic(
|
||||
self: "pyrogram.Client",
|
||||
chat_id: Union[int, str],
|
||||
topic_id: int
|
||||
) -> bool:
|
||||
"""Pin a forum topic.
|
||||
|
||||
.. include:: /_includes/usable-by/users-bots.rst
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
topic_id (``int``):
|
||||
Unique identifier (int) of the target forum topic.
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
await app.pin_forum_topic(chat_id, topic_id)
|
||||
"""
|
||||
await self.invoke(
|
||||
raw.functions.channels.UpdatePinnedForumTopic(
|
||||
channel=await self.resolve_peer(chat_id),
|
||||
topic_id=topic_id,
|
||||
pinned=True
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
57
pyrogram/methods/chats/unpin_forum_topic.py
Normal file
57
pyrogram/methods/chats/unpin_forum_topic.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present 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/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram import raw
|
||||
from typing import Union
|
||||
|
||||
|
||||
class UnpinForumTopic:
|
||||
async def unpin_forum_topic(
|
||||
self: "pyrogram.Client",
|
||||
chat_id: Union[int, str],
|
||||
topic_id: int
|
||||
) -> bool:
|
||||
"""Unpin a forum topic.
|
||||
|
||||
.. include:: /_includes/usable-by/users-bots.rst
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
topic_id (``int``):
|
||||
Unique identifier (int) of the target forum topic.
|
||||
|
||||
Returns:
|
||||
``bool``: On success, True is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
await app.unpin_forum_topic(chat_id, topic_id)
|
||||
"""
|
||||
await self.invoke(
|
||||
raw.functions.channels.UpdatePinnedForumTopic(
|
||||
channel=await self.resolve_peer(chat_id),
|
||||
topic_id=topic_id,
|
||||
pinned=False
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
@ -94,7 +94,7 @@ class UserStarGift(Object):
|
||||
entities = None
|
||||
|
||||
if getattr(user_star_gift, "message", None):
|
||||
text = user_star_gift.message.text or None
|
||||
text = user_star_gift.message.text
|
||||
entities = [types.MessageEntity._parse(client, entity, users) for entity in user_star_gift.message.entities]
|
||||
entities = types.List(filter(lambda x: x is not None, entities))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user