mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
AIOG-T-76 Added the parameter message_id to the method unpinChatMessage to allow unpinning of the specific pinned message
This commit is contained in:
parent
d92ace6805
commit
aef6fd2c52
3 changed files with 50 additions and 9 deletions
|
|
@ -1483,15 +1483,27 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
|
|||
result = await self.request(api.Methods.PIN_CHAT_MESSAGE, payload)
|
||||
return result
|
||||
|
||||
async def unpin_chat_message(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
|
||||
async def unpin_chat_message(self,
|
||||
chat_id: typing.Union[base.Integer, base.String],
|
||||
message_id: typing.Optional[base.Integer] = None,
|
||||
) -> base.Boolean:
|
||||
"""
|
||||
Use this method to unpin a message in a supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
Use this method to remove a message from 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#unpinchatmessage
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target supergroup
|
||||
: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]`
|
||||
|
||||
:param message_id: Identifier of a message to unpin. If not specified, the
|
||||
most recent pinned message (by sending date) will be unpinned.
|
||||
:type message_id: :obj:`typing.Optional[base.Integer]`
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -385,17 +385,29 @@ class Chat(base.TelegramObject):
|
|||
"""
|
||||
return await self.bot.pin_chat_message(self.id, message_id, disable_notification)
|
||||
|
||||
async def unpin_message(self) -> base.Boolean:
|
||||
async def unpin_message(self,
|
||||
message_id: typing.Optional[base.Integer] = None,
|
||||
) -> base.Boolean:
|
||||
"""
|
||||
Use this method to unpin a message in a supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
Use this method to remove a message from 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#unpinchatmessage
|
||||
|
||||
:return: Returns True on success.
|
||||
:param message_id: Identifier of a message to unpin. If not specified, the
|
||||
most recent pinned message (by sending date) will be unpinned.
|
||||
:type message_id: :obj:`typing.Optional[base.Integer]`
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
return await self.bot.unpin_chat_message(self.id)
|
||||
return await self.bot.unpin_chat_message(
|
||||
chat_id=self.id,
|
||||
message_id=message_id,
|
||||
)
|
||||
|
||||
async def leave(self) -> base.Boolean:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2118,6 +2118,23 @@ class Message(base.TelegramObject):
|
|||
"""
|
||||
return await self.chat.pin_message(self.message_id, disable_notification)
|
||||
|
||||
async def unpin(self) -> base.Boolean:
|
||||
"""
|
||||
Use this method to remove a message from 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#unpinchatmessage
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
return await self.chat.unpin_message(
|
||||
message_id=self.message_id,
|
||||
)
|
||||
|
||||
async def send_copy(
|
||||
self: Message,
|
||||
chat_id: typing.Union[str, int],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue