mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
AIOG-T-75 Added the ability to pin messages in private chats (docs update)
This commit is contained in:
parent
0d19644616
commit
d92ace6805
3 changed files with 43 additions and 21 deletions
|
|
@ -1450,21 +1450,31 @@ class Bot(BaseBot, DataMixin, ContextInstanceMixin):
|
|||
result = await self.request(api.Methods.SET_CHAT_DESCRIPTION, payload)
|
||||
return result
|
||||
|
||||
async def pin_chat_message(self, chat_id: typing.Union[base.Integer, base.String], message_id: base.Integer,
|
||||
disable_notification: typing.Union[base.Boolean, None] = None) -> base.Boolean:
|
||||
async def pin_chat_message(self,
|
||||
chat_id: typing.Union[base.Integer, base.String],
|
||||
message_id: base.Integer,
|
||||
disable_notification: typing.Optional[base.Boolean] = None,
|
||||
) -> base.Boolean:
|
||||
"""
|
||||
Use this method to pin a message in a supergroup.
|
||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
Use this method to add a message to 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#pinchatmessage
|
||||
|
||||
: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 pin
|
||||
:type message_id: :obj:`base.Integer`
|
||||
:param disable_notification: Pass True, if it is not necessary to send a notification to
|
||||
all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
|
||||
|
||||
:param disable_notification: Pass True, if it is not necessary to send a
|
||||
notification to all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -360,19 +360,27 @@ class Chat(base.TelegramObject):
|
|||
return await self.bot.set_chat_administrator_custom_title(chat_id=self.id, user_id=user_id,
|
||||
custom_title=custom_title)
|
||||
|
||||
async def pin_message(self, message_id: base.Integer, disable_notification: base.Boolean = False) -> base.Boolean:
|
||||
async def pin_message(self,
|
||||
message_id: base.Integer,
|
||||
disable_notification: typing.Optional[base.Boolean] = False,
|
||||
) -> base.Boolean:
|
||||
"""
|
||||
Use this method to pin a message in a supergroup.
|
||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
Use this method to add a message to 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#pinchatmessage
|
||||
|
||||
:param message_id: Identifier of a message to pin
|
||||
:type message_id: :obj:`base.Integer`
|
||||
:param disable_notification: Pass True, if it is not necessary to send a notification to
|
||||
all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
|
||||
:return: Returns True on success.
|
||||
|
||||
:param disable_notification: Pass True, if it is not necessary to send a
|
||||
notification to all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
return await self.bot.pin_chat_message(self.id, message_id, disable_notification)
|
||||
|
|
|
|||
|
|
@ -2098,17 +2098,21 @@ class Message(base.TelegramObject):
|
|||
return await self.bot.delete_message(self.chat.id, self.message_id)
|
||||
|
||||
async def pin(
|
||||
self, disable_notification: typing.Union[base.Boolean, None] = None
|
||||
self, disable_notification: typing.Optional[base.Boolean] = None,
|
||||
) -> base.Boolean:
|
||||
"""
|
||||
Use this method to pin a message in a supergroup.
|
||||
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||
Use this method to add a message to 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#pinchatmessage
|
||||
|
||||
:param disable_notification: Pass True, if it is not necessary to send a notification to
|
||||
all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
|
||||
:param disable_notification: Pass True, if it is not necessary to send a
|
||||
notification to all group members about the new pinned message
|
||||
:type disable_notification: :obj:`typing.Optional[base.Boolean]`
|
||||
|
||||
:return: Returns True on success
|
||||
:rtype: :obj:`base.Boolean`
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue