Media group

media_group.py
 1import asyncio
 2
 3from aiogram import Bot, Dispatcher, executor, filters, types
 4
 5
 6API_TOKEN = 'BOT_TOKEN_HERE'
 7
 8bot = Bot(token=API_TOKEN)
 9dp = Dispatcher(bot)
10
11
12@dp.message_handler(filters.CommandStart())
13async def send_welcome(message: types.Message):
14    # So... At first I want to send something like this:
15    await message.reply("Do you want to see many pussies? Are you ready?")
16
17    # Wait a little...
18    await asyncio.sleep(1)
19
20    # Good bots should send chat actions...
21    await types.ChatActions.upload_photo()
22
23    # Create media group
24    media = types.MediaGroup()
25
26    # Attach local file
27    media.attach_photo(types.InputFile('data/cat.jpg'), 'Cat!')
28    # More local files and more cats!
29    media.attach_photo(types.InputFile('data/cats.jpg'), 'More cats!')
30
31    # You can also use URL's
32    # For example: get random puss:
33    media.attach_photo('http://lorempixel.com/400/200/cats/', 'Random cat.')
34
35    # And you can also use file ID:
36    # media.attach_photo('<file_id>', 'cat-cat-cat.')
37
38    # Done! Send media group
39    await message.reply_media_group(media=media)
40
41
42if __name__ == '__main__':
43    executor.start_polling(dp, skip_updates=True)