Inline menu builder for yatbaf
Project description
yatbaf-menu
Inline menu builder for yatbaf.
Installation
$ pip install yatbaf-menu
Usage
from yatbaf import Bot
from yatbaf import on_message
from yatbaf.filters import Command
from yatbaf.types import CallbackQuery
from yatbaf_menu import Action
from yatbaf_menu import Menu
async def button1(q: CallbackQuery) -> None:
await q.answer()
await q.message.answer("click1")
async def button2(q: CallbackQuery) -> None:
await q.answer()
await q.message.answer("click2")
menu = Menu(
title="Menu title",
name="main",
buttons=[
[
Action(title="Click 1", action=button1),
Action(title="Click 2", action=button2),
],
],
)
@on_message(filters=[Command("menu")])
async def open_menu(message: Message) -> None:
await message.answer(**(await menu.get_message_params(message)))
Bot(
"<replace-with-your-token>",
handlers=[open_menu],
routers=[menu.get_router()],
).run()
Examples
Click
Click action
URL
URL button
Submenu
Submenu button
Dynamic
You can use a dynamic show/hide for buttons and dynamic text for button/menu title.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yatbaf_menu-0.1.0.tar.gz
(8.4 kB
view details)