aio-kb
Simple and flexible keyboard helpers for aiogram 3.x.
aio-kb helps you create Telegram bot keyboards faster and cleaner.
Features
- Reply keyboards
- Inline keyboards
- URL buttons
- Callback buttons
- Web App buttons
- Copy text buttons
- Login URL buttons
- Contact request button
- Location request button
- Pagination keyboard
- Back / Close buttons
- Yes / No buttons
- Custom button texts
- Simple builder helpers
Installation
pip install aio-kb
Requirements
Python >= 3.10
aiogram >= 3.0.0
Quick Start
from aio_kb import reply_kb, inline_kb, Btn
menu = reply_kb([
["Start", "Help"],
["About"]
])
inline = inline_kb([
[Btn("Website", url="https://example.com")],
[Btn("Click", callback="click")]
])
Reply Keyboard
from aio_kb import reply_kb
keyboard = reply_kb([
["Menu", "Help"],
["About"]
])
Use it in a handler:
await message.answer("Choose an option:", reply_markup=keyboard)
Inline Keyboard
from aio_kb import inline_kb, Btn
keyboard = inline_kb([
[Btn("Open website", url="https://example.com")],
[Btn("Profile", callback="profile")]
])
Use it in a handler:
await message.answer("Inline menu:", reply_markup=keyboard)
URL Button
from aio_kb import inline_buttons, url_btn
keyboard = inline_buttons(
url_btn("GitHub", "https://github.com")
)
Callback Button
from aio_kb import inline_buttons, cb_btn
keyboard = inline_buttons(
cb_btn("Open menu", "menu:open")
)
Callback handler:
from aiogram import F
from aiogram.types import CallbackQuery
@router.callback_query(F.data == "menu:open")
async def open_menu(call: CallbackQuery):
await call.answer("Menu opened")
Web App Button
from aio_kb import inline_buttons, webapp_btn
keyboard = inline_buttons(
webapp_btn("Open Web App", "https://example.com/app")
)
Copy Text Button
from aio_kb import inline_buttons, copy_btn
keyboard = inline_buttons(
copy_btn("Copy code", "ABC-123")
)
Contact Button
from aio_kb import contact_kb
keyboard = contact_kb()
Custom text:
keyboard = contact_kb("📞 Send phone number")
Location Button
from aio_kb import location_kb
keyboard = location_kb()
Custom text:
keyboard = location_kb("📍 Send location")
Back / Close Buttons
from aio_kb import back_kb, close_kb, back_close_kb
back = back_kb()
close = close_kb()
both = back_close_kb()
Custom text:
keyboard = back_close_kb(
back_text="⬅️ Back",
close_text="❌ Close"
)
Yes / No Keyboard
from aio_kb import yes_no_kb
keyboard = yes_no_kb()
Custom callbacks and texts:
keyboard = yes_no_kb(
yes_callback="confirm:yes",
no_callback="confirm:no",
yes_text="✅ Yes",
no_text="❌ No"
)
Pagination
from aio_kb import pager
keyboard = pager(
page=1,
total_pages=5
)
Custom prefix:
keyboard = pager(
page=2,
total_pages=10,
prefix="products"
)
Example callback values:
products:1
products:2
products:home
products:current
Custom Language
Default texts are English, but you can use any language.
from aio_kb import yes_no_kb, back_close_kb
confirm = yes_no_kb(
yes_text="✅ Ha",
no_text="❌ Yo‘q"
)
navigation = back_close_kb(
back_text="⬅️ Orqaga",
close_text="❌ Yopish"
)
Full Bot Example
import asyncio
from os import getenv
from aiogram import Bot, Dispatcher, Router, F
from aiogram.filters import Command
from aiogram.types import Message, CallbackQuery
from dotenv import load_dotenv
from aio_kb import reply_kb, inline_kb, Btn, yes_no_kb
load_dotenv()
BOT_TOKEN = getenv("BOT_TOKEN")
router = Router()
@router.message(Command("start"))
async def start(message: Message):
keyboard = reply_kb([
["Help", "About"],
["Settings"]
])
await message.answer(
"Hello! Choose menu:",
reply_markup=keyboard
)
@router.message(F.text == "Help")
async def help_handler(message: Message):
keyboard = inline_kb([
[Btn("Open website", url="https://example.com")],
[Btn("Show profile", callback="profile:show")],
[Btn("Confirm", callback="confirm")]
])
await message.answer(
"Help menu:",
reply_markup=keyboard
)
@router.callback_query(F.data == "profile:show")
async def show_profile(call: CallbackQuery):
await call.message.answer("This is your profile.")
await call.answer()
@router.callback_query(F.data == "confirm")
async def confirm_handler(call: CallbackQuery):
await call.message.answer(
"Are you sure?",
reply_markup=yes_no_kb(
yes_callback="confirm:yes",
no_callback="confirm:no"
)
)
await call.answer()
@router.callback_query(F.data == "confirm:yes")
async def confirm_yes(call: CallbackQuery):
await call.message.answer("Confirmed!")
await call.answer()
@router.callback_query(F.data == "confirm:no")
async def confirm_no(call: CallbackQuery):
await call.message.answer("Cancelled!")
await call.answer()
async def main():
bot = Bot(token=BOT_TOKEN)
dp = Dispatcher()
dp.include_router(router)
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())
Available Imports
from aio_kb import (
Btn,
reply_kb,
reply_keyboard,
rk,
reply_buttons,
contact_kb,
location_kb,
inline_kb,
inline_keyboard,
ikb,
inline_buttons,
url_btn,
cb_btn,
webapp_btn,
switch_btn,
switch_current_btn,
copy_btn,
login_btn,
reply_builder,
inline_builder,
pager,
back_kb,
close_kb,
back_close_kb,
yes_no_kb,
social_kb,
)
License
MIT License
Author
Created by Natsu.
Metadata
Release files for aio-kb 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aio_kb-0.1.1.tar.gz | 3.0 kB | Without provenance | Details for aio_kb-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aio_kb-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for aio_kb-0.1.1-py3-none-any.whl |
Total release size: 5.9 kB
Release files / aio_kb-0.1.1.tar.gz
| Download URL | aio_kb-0.1.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bc55a93d66c267182f7d61c1351b74b3f2a3f83711070e5409897ede459c361
|
|
BLAKE2b-256 checksum How to use checksums |
1541f7977a6e7a9cb7d94780eb02c26738a481d8c57e0cb23a298965a7f09563
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / aio_kb-0.1.1-py3-none-any.whl
| Download URL | aio_kb-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
548c30779decd273dd23bf80f15335a399557ed0d3959d6a39da1a0cf0bb47d5
|
|
BLAKE2b-256 checksum How to use checksums |
440e0aa9413c02e08fcad5bdb0b5d32bd3feb2d4446357285bb13ff187d6471a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for aio-kb 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.