Answer the question
In order to leave comments, you need to log in
Aiogram Bot: how to send multiple media as one photo collage?
If we reduce the bot as much as possible, we get the following code:
import logging
import conceptual_config
from aiogram import Bot, Dispatcher, executor, types
from aiogram.utils.markdown import *
API_TOKEN = conceptual_config.TOKEN # Токен бота из личного файла
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN, parse_mode="html")
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def send_welcome(message: types.Message):
await message.answer("Бот принял команду /start")
media_txt = "Превосходная \nФотография"
media = [types.InputMediaPhoto('media/Starbucks_Logo.jpg', 'Превосходная фотография'), types.InputMediaPhoto('media/Starbucks_Logo_2.jpg')] # Показываем, где фото и как её подписать
await bot.send_chat_action(call.message.chat.id, types.ChatActions.UPLOAD_DOCUMENT) # Устанавливаем action "Uploading a document..."
await bot.send_media_group(call.message.chat.id, media=media) # Отправка фото
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
aiogram.utils.exceptions.BadRequest: Wrong http url specified
media = [types.InputMediaPhoto('media/Starbucks_Logo.jpg', 'Превосходная фотография')] # Показываем, где фото и как её подписать
media.append(types.InputMediaPhoto('media/Starbucks_Logo_2.jpg'))
await types.ChatActions.upload_photo() # Установка action "Отправка фотографии..."
await bot.send_media_group(message.chat.id, media=media) # Отправка фото
Answer the question
In order to leave comments, you need to log in
media = types.MediaGroup()
media.attach_photo(types.InputFile('media/Starbucks_Logo.jpg'), 'Превосходная фотография')
media.attach_photo(types.InputFile('media/Starbucks_Logo_2.jpg'), 'Превосходная фотография 2')
await bot.send_media_group(call.message.chat.id, media=media)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question