ksinn / python-telegram-bot-pagination

Python inline keyboard pagination for Telegram Bot API
Other
105 stars 23 forks source link

Create examle3.py use aiogram #11

Open macros0 opened 1 year ago

macros0 commented 1 year ago

Create examle3.py use aiogram

gulyaeve commented 1 year ago

To work with aiogram 3.x version i added this function to convert paginator.markup to inline keyboard:

def make_inline_keyboard(markup):
    markup = json.loads(markup)['inline_keyboard']

    rows = []
    for row in markup:
        buttons = []
        for button in row:
            buttons.append(types.InlineKeyboardButton(text=button['text'], callback_data=button['callback_data']))
        rows.append(buttons)

    keyboard = types.InlineKeyboardMarkup(inline_keyboard=rows)
    return keyboard