AIOG-T-77 Added the method unpinAllChatMessages, which can be used to unpin all pinned messages in a chat.

This commit is contained in:
Oleg A 2020-11-05 18:45:10 +03:00
parent aef6fd2c52
commit 3328979f28
3 changed files with 40 additions and 0 deletions

View file

@ -200,6 +200,7 @@ class Methods(Helper):
SET_CHAT_DESCRIPTION = Item() # setChatDescription
PIN_CHAT_MESSAGE = Item() # pinChatMessage
UNPIN_CHAT_MESSAGE = Item() # unpinChatMessage
UNPIN_ALL_CHAT_MESSAGES = Item() # unpinAllChatMessages
LEAVE_CHAT = Item() # leaveChat
GET_CHAT = Item() # getChat
GET_CHAT_ADMINISTRATORS = Item() # getChatAdministrators

View file

@ -1512,6 +1512,29 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
result = await self.request(api.Methods.UNPIN_CHAT_MESSAGE, payload)
return result
async def unpin_all_chat_messages(self,
chat_id: typing.Union[base.Integer, base.String],
) -> base.Boolean:
"""
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. Returns True on success.
Source: https://core.telegram.org/bots/api#unpinallchatmessages
:param chat_id: Unique identifier for the target chat or username of the
target channel (in the format @channelusername)
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:return: Returns True on success
:rtype: :obj:`base.Boolean`
"""
payload = generate_payload(**locals())
result = await self.request(api.Methods.UNPIN_ALL_CHAT_MESSAGES, payload)
return result
async def leave_chat(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
"""
Use this method for your bot to leave a group, supergroup or channel.

View file

@ -409,6 +409,22 @@ class Chat(base.TelegramObject):
message_id=message_id,
)
async def unpin_all_messages(self):
"""
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. Returns True on success.
Source: https://core.telegram.org/bots/api#unpinallchatmessages
:return: Returns True on success
:rtype: :obj:`base.Boolean`
"""
return await self.bot.unpin_all_chat_messages(
chat_id=self.id,
)
async def leave(self) -> base.Boolean:
"""
Use this method for your bot to leave a group, supergroup or channel.