L
L
lemonlimelike2020-02-02 04:40:24
Python
lemonlimelike, 2020-02-02 04:40:24

How to send multiple photos using sendMediaGroup method in Telegram?

Good morning everyone! I can't figure out how to send multiple photos in one message. Help guys.

There is a class that __init__has a variable in the constructor self.multiPhoto = []. In the method, I fill this variable like this:

for img in item['attachments']:
    self.multiPhoto.append(img['photo']['sizes'][-1]['url'])

From the docks, I realized that you need to use the sendMediaGroup method with the chat_id and media parameters. The media should have a json string.

Here is how I do it:
media = json.dumps({'type':'photo','media':self.multiPhoto,'caption':self.text})

And this is how I send a message to telegram: self.telegram.send_media_group(self.chanel,media)

Here is the error:
5e36282f9884e786146030.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question