mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-19 21:11:06 +03:00
Create new client.pin_message method
This commit is contained in:
parent
9ea686ab14
commit
5832ab2f31
|
@ -63,6 +63,7 @@ Messages
|
||||||
forward_messages
|
forward_messages
|
||||||
iter_messages
|
iter_messages
|
||||||
get_messages
|
get_messages
|
||||||
|
pin_message
|
||||||
send_read_acknowledge
|
send_read_acknowledge
|
||||||
|
|
||||||
Uploads
|
Uploads
|
||||||
|
|
|
@ -76,6 +76,7 @@ Methods
|
||||||
delete
|
delete
|
||||||
get_reply_message
|
get_reply_message
|
||||||
click
|
click
|
||||||
|
pin
|
||||||
download_media
|
download_media
|
||||||
get_entities_text
|
get_entities_text
|
||||||
get_buttons
|
get_buttons
|
||||||
|
|
|
@ -1121,6 +1121,49 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
async def pin_message(
|
||||||
|
self: 'TelegramClient',
|
||||||
|
entity: 'hints.EntityLike',
|
||||||
|
message: 'typing.Optional[hints.MessageIDLike]',
|
||||||
|
*,
|
||||||
|
notify: bool = False
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Pins or unpins a message in a chat.
|
||||||
|
|
||||||
|
The default behaviour is to *not* notify members, unlike the
|
||||||
|
official applications.
|
||||||
|
|
||||||
|
See also `Message.pin() <telethon.tl.custom.message.Message.pin>`.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
entity (`entity`):
|
||||||
|
The chat where the message should be pinned.
|
||||||
|
|
||||||
|
message (`int` | `Message <telethon.tl.custom.message.Message>`):
|
||||||
|
The message or the message ID to pin. If it's
|
||||||
|
``None``, the message will be unpinned instead.
|
||||||
|
|
||||||
|
notify (`bool`, optional):
|
||||||
|
Whether the pin should notify people or not.
|
||||||
|
|
||||||
|
Example
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Send and pin a message to annoy everyone
|
||||||
|
message = client.send_message(chat, 'Pinotifying is fun!')
|
||||||
|
client.pin_message(chat, message, notify=True)
|
||||||
|
"""
|
||||||
|
if not message:
|
||||||
|
message = 0
|
||||||
|
|
||||||
|
entity = await self.get_input_entity(entity)
|
||||||
|
await self(functions.messages.UpdatePinnedMessageRequest(
|
||||||
|
peer=entity,
|
||||||
|
id=message,
|
||||||
|
silent=not notify
|
||||||
|
))
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
|
@ -854,6 +854,15 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
|
||||||
else:
|
else:
|
||||||
return await self._buttons[i][j].click()
|
return await self._buttons[i][j].click()
|
||||||
|
|
||||||
|
async def pin(self, *, notify=False):
|
||||||
|
"""
|
||||||
|
Pins the message. Shorthand for
|
||||||
|
`telethon.client.messages.MessageMethods.pin_message`
|
||||||
|
with both ``entity`` and ``message`` already set.
|
||||||
|
"""
|
||||||
|
await self._client.pin_message(
|
||||||
|
await self.get_input_chat(), self.id, notify=notify)
|
||||||
|
|
||||||
# endregion Public Methods
|
# endregion Public Methods
|
||||||
|
|
||||||
# region Private Methods
|
# region Private Methods
|
||||||
|
|
Loading…
Reference in New Issue
Block a user