mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
parent
74bced75b4
commit
c43e2a0a3a
|
@ -131,7 +131,14 @@ class MessageParseMethods:
|
|||
elif isinstance(update, (
|
||||
types.UpdateNewChannelMessage, types.UpdateNewMessage)):
|
||||
update.message._finish_init(self, entities, input_chat)
|
||||
id_to_message[update.message.id] = update.message
|
||||
|
||||
# Pinning a message with `updatePinnedMessage` seems to
|
||||
# always produce a service message we can't map so return
|
||||
# it directly.
|
||||
if hasattr(request, 'random_id'):
|
||||
id_to_message[update.message.id] = update.message
|
||||
else:
|
||||
return update.message
|
||||
|
||||
elif (isinstance(update, types.UpdateEditMessage)
|
||||
and helpers._entity_type(request.peer) != helpers._EntityType.CHANNEL):
|
||||
|
|
|
@ -1246,11 +1246,24 @@ class MessageMethods:
|
|||
"""
|
||||
message = utils.get_message_id(message) or 0
|
||||
entity = await self.get_input_entity(entity)
|
||||
await self(functions.messages.UpdatePinnedMessageRequest(
|
||||
request = functions.messages.UpdatePinnedMessageRequest(
|
||||
peer=entity,
|
||||
id=message,
|
||||
silent=not notify
|
||||
))
|
||||
)
|
||||
result = await self(request)
|
||||
|
||||
# Unpinning does not produce a service message, and technically
|
||||
# users can pass negative IDs which seem to behave as unpinning too.
|
||||
if message <= 0:
|
||||
return
|
||||
|
||||
# Pinning in User chats (just with yourself really) does not produce a service message
|
||||
if helpers._entity_type(entity) == helpers._EntityType.USER:
|
||||
return
|
||||
|
||||
# Pinning a message that doesn't exist would RPC-error earlier
|
||||
return self._get_response_message(request, result, entity)
|
||||
|
||||
# endregion
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ class Album(EventBuilder):
|
|||
`telethon.client.messages.MessageMethods.pin_message`
|
||||
with both ``entity`` and ``message`` already set.
|
||||
"""
|
||||
await self.messages[0].pin(notify=notify)
|
||||
return await self.messages[0].pin(notify=notify)
|
||||
|
||||
def __len__(self):
|
||||
"""
|
||||
|
|
|
@ -898,7 +898,7 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
|
|||
# maybe just make it illegal to call messages from raw API?
|
||||
# That or figure out a way to always set it directly.
|
||||
if self._client:
|
||||
await self._client.pin_message(
|
||||
return await self._client.pin_message(
|
||||
await self.get_input_chat(), self.id, notify=notify)
|
||||
|
||||
# endregion Public Methods
|
||||
|
|
Loading…
Reference in New Issue
Block a user