Fix sending albums not returning the sent messages (#1151)

This commit is contained in:
Lonami Exo 2019-04-09 16:48:36 +04:00
parent 9598e1877c
commit b32d8307ec

View File

@ -346,11 +346,18 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
result = await self(functions.messages.SendMultiMediaRequest( result = await self(functions.messages.SendMultiMediaRequest(
entity, reply_to_msg_id=reply_to, multi_media=media, silent=silent entity, reply_to_msg_id=reply_to, multi_media=media, silent=silent
)) ))
return [
self._get_response_message(update.id, result, entity) # We never sent a `random_id` for the messages that resulted from
for update in result.updates # the request so we can't pair them up with the `Updates` that we
if isinstance(update, types.UpdateMessageID) # get from Telegram. However, the sent messages have a photo and
] # the photo IDs match with those we did send.
#
# Updates -> {_: message}
messages = self._get_response_message(None, result, entity)
# {_: message} -> {photo ID: message}
messages = {m.photo.id: m for m in messages.values()}
# Sent photo IDs -> messages
return [messages[m.media.id.id] for m in media]
async def upload_file( async def upload_file(
self, file, *, part_size_kb=None, file_name=None, use_cache=None, self, file, *, part_size_kb=None, file_name=None, use_cache=None,