Answer the question
In order to leave comments, you need to log in
How to implement the bot sending an album of photos in telegram?
There was a difficulty with sending a photo in a telegram bot. Here is my code:
@bot.message_handler(regexp='Скинь мне фото!')
def photo_album(message):
ph1 = open('\Temp\KL.py\photo_2021-06-13_13-54-47.jpg', 'rb')
bot.send_photo(message.chat.id, ph1)
ph2 = open('\Temp\KL.py\photo_2021-06-13_13-54-49.jpg', 'rb')
bot.send_photo(message.chat.id, ph2)
ph3 = open('\Temp\KL.py\photo_2021-06-13_13-54-43.jpg', 'rb')
bot.send_photo(message.chat.id, ph3)
ph4 = open('\Temp\KL.py\photo_2021-06-13_13-54-45.jpg', 'rb')
bot.send_photo(message.chat.id, ph4)
ph5 = open('\Temp\KL.py\photo_2021-06-13_13-54-46.jpg', 'rb')
bot.send_photo(message.chat.id, ph5)
ph6 = open('\Temp\KL.py\photo_2021-06-13_13-54-50.jpg', 'rb')
bot.send_photo(message.chat.id, ph6)
ph7 = open('\Temp\KL.py\photo_2021-06-13_13-54-52.jpg', 'rb')
bot.send_photo(message.chat.id, ph7)
Answer the question
In order to leave comments, you need to log in
media = types.MediaGroup()
media.attach_photo(types.InputFile('путь_к_файлу'), 'название,которое будет отображаться')# повторяеете этот метод столько раз , сколько фоток будет в альбоме
await bot.send_media_group(message.from_user.id, media=media)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question