mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 03:13:45 +03:00
Support multiple captions when sending albums
This commit is contained in:
parent
2e31a686e8
commit
74bffd2ae3
|
@ -1200,7 +1200,8 @@ class TelegramClient(TelegramBareClient):
|
||||||
if all(utils.is_image(x) for x in file):
|
if all(utils.is_image(x) for x in file):
|
||||||
return self._send_album(
|
return self._send_album(
|
||||||
entity, file, caption=caption,
|
entity, file, caption=caption,
|
||||||
progress_callback=progress_callback, reply_to=reply_to
|
progress_callback=progress_callback, reply_to=reply_to,
|
||||||
|
parse_mode=parse_mode
|
||||||
)
|
)
|
||||||
# Not all are images, so send all the files one by one
|
# Not all are images, so send all the files one by one
|
||||||
return [
|
return [
|
||||||
|
@ -1350,10 +1351,13 @@ class TelegramClient(TelegramBareClient):
|
||||||
# we need to produce right now to send albums (uploadMedia), and
|
# we need to produce right now to send albums (uploadMedia), and
|
||||||
# cache only makes a difference for documents where the user may
|
# cache only makes a difference for documents where the user may
|
||||||
# want the attributes used on them to change.
|
# want the attributes used on them to change.
|
||||||
# TODO Support a different captions for each file
|
|
||||||
entity = self.get_input_entity(entity)
|
entity = self.get_input_entity(entity)
|
||||||
caption = caption or ''
|
if not utils.is_list_like(caption):
|
||||||
caption, msg_entities = self._parse_message_text(caption, parse_mode)
|
caption = (caption,)
|
||||||
|
captions = [
|
||||||
|
self._parse_message_text(caption or '', parse_mode)
|
||||||
|
for caption in reversed(caption) # Pop from the end (so reverse)
|
||||||
|
]
|
||||||
reply_to = self._get_message_id(reply_to)
|
reply_to = self._get_message_id(reply_to)
|
||||||
|
|
||||||
# Need to upload the media first, but only if they're not cached yet
|
# Need to upload the media first, but only if they're not cached yet
|
||||||
|
@ -1367,11 +1371,13 @@ class TelegramClient(TelegramBareClient):
|
||||||
)).photo)
|
)).photo)
|
||||||
self.session.cache_file(fh.md5, fh.size, input_photo)
|
self.session.cache_file(fh.md5, fh.size, input_photo)
|
||||||
fh = input_photo
|
fh = input_photo
|
||||||
media.append(InputSingleMedia(
|
|
||||||
InputMediaPhoto(fh),
|
if captions:
|
||||||
message=caption,
|
caption, msg_entities = captions.pop()
|
||||||
entities=msg_entities
|
else:
|
||||||
))
|
caption, msg_entities = '', None
|
||||||
|
media.append(InputSingleMedia(InputMediaPhoto(fh), message=caption,
|
||||||
|
entities=msg_entities))
|
||||||
|
|
||||||
# Now we can construct the multi-media request
|
# Now we can construct the multi-media request
|
||||||
result = self(SendMultiMediaRequest(
|
result = self(SendMultiMediaRequest(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user