
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
aiogram-inline-paginations
Advanced tools
A simple library for aiogram that allows you to easily do pagination for any Inline keyboards.
A simple library for aiogram that allows you to easily do pagination for any Inline keyboards.
Install for pip:
pip install aiogram-inline-paginations
Install for poetry:
poetry add aiogram-inline-paginations
from aiogram_inline_paginations.paginator import Paginator
from aiogram import types
kb = types.InlineKeyboardMarkup()
paginator = Paginator(data=kb, size=5)
data: Any ready-to-use keyboard InlineKeyboardMarkup or any iterable object with InlineKeyboardButton.
size: The number of rows of buttons on one page, excluding the navigation bar.
A paginator object that, when called, returns a ready-made keyboard with pagination.
from aiogram_inline_paginations.paginator import Paginator
from aiogram import types
kb = types.InlineKeyboardMarkup()
paginator = Paginator(data=kb, size=5)
@dp.message_handler()
async def some_func(message: types.Message):
await message.answer(
text='Some menu',
reply_markup=paginator()
)
Data for registrations paginator.
import random
from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher.filters import CommandStart
from aiogram.utils.executor import Executor
from aiogram_inline_paginations.paginator import Paginator
token = 'your token'
storage = MemoryStorage()
bot = Bot(token=token)
dp = Dispatcher(bot, storage=storage)
@dp.message_handler(CommandStart(), state='*')
async def start(message: types.Message):
await message.answer('Hello text')
kb = types.InlineKeyboardMarkup() # some keyboard
'''To demonstrate, I will add more than 50 buttons to the keyboard and divide them into 5 lines per page'''
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
) for i in range(2)
]
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
) for i in range(3)
]
)
kb.add(
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
)
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
) for i in range(2)
]
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data='pass'
) for i in range(50)
]
)
paginator = Paginator(data=kb, size=5, dp=dp)
await message.answer(
text='Some menu',
reply_markup=paginator()
)
if __name__ == '__main__':
Executor(dp).start_polling()
import random
from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters import CommandStart, Text
from aiogram.utils.executor import Executor
from aiogram_inline_paginations.paginator import CheckBoxPaginator
token = 'your token'
storage = MemoryStorage()
bot = Bot(token=token)
dp = Dispatcher(bot, storage=storage)
@dp.message_handler(CommandStart(), state='*')
async def start(message: types.Message):
await message.answer('Hello text')
kb = types.InlineKeyboardMarkup() # some keyboard
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data=f'pass_{str(random.randint(1000000, 10000000))}'
) for i in range(2)
]
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data=f'pass_{str(random.randint(1000000, 10000000))}'
) for i in range(3)
]
)
kb.add(
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data=f'pass_{str(random.randint(1000000, 10000000))}'
)
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data=f'pass_{str(random.randint(1000000, 10000000))}'
) for i in range(2)
]
)
kb.add(
*[
types.InlineKeyboardButton(
text=str(random.randint(1000000, 10000000)),
callback_data=f'pass_{str(random.randint(1000000, 10000000))}'
) for i in range(50)
]
)
paginator = CheckBoxPaginator(
data=kb,
size=5,
callback_startswith='page_',
callback_startswith_button='pass_',
confirm_text='Approve',
dp=dp
)
await message.answer(
text='Some menu',
reply_markup=paginator()
)
@dp.callback_query_handler(Text(startswith='Approve', endswith='confirm'))
async def approve(call: types.CallbackQuery, state: FSMContext):
data = await state.get_data()
selected = data.get('page_selected', None)
await call.answer(
text='Your selected"\n'.join(selected)
)
if __name__ == '__main__':
Executor(dp).start_polling()
confirim callback:
f"{confirm_text}confirm"
selected data:
data = await state.get_data()
selected = data.get(f'{startswith}selected', None)
First page:
Second page:
Last page:
The order of entries is not lost.
FAQs
A simple library for aiogram that allows you to easily do pagination for any Inline keyboards.
We found that aiogram-inline-paginations demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.