import io import json from aiogram import types from load import dp, bot from keyboards.inline.timetable import timetable @dp.callback_query_handler(lambda c: c.data.split("|")[0] == "timetable") async def callback_table(query: types.CallbackQuery): message = query.message group = query.data.split("|")[1] file = timetable(group) for f in file: await bot.send_photo( message.chat.id, io.BytesIO(open(f, 'rb').read()) ) await query.answer()