Skip to main content

Inline menu builder for yatbaf

Project description

yatbaf-menu

Inline menu builder for yatbaf.

Installation

$ pip install yatbaf-menu

Usage

from typing import TYPE_CHECKING

from yatbaf import Bot
from yatbaf import on_message
from yatbaf.filters import Command

from yatbaf_menu import Action
from yatbaf_menu import Menu
from yatbaf_menu import build_router

if TYPE_CHECKING:
    from yatbaf.types import CallbackQuery
    from yatbaf.types import Message



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",
    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=[build_router(menu)],
).run()

Examples

Click

Click action

click gif

code

URL

URL button

url pic

code

Submenu

Submenu button

submenu gif

code

Choice

choice gif

code

Pagination

paging gif

code

Dynamic titles and visibility

dynamic gif

code

License

MIT

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.4.0.tar.gz (13.5 kB view hashes)

Uploaded Source

Built Distribution

yatbaf_menu-0.4.0-py3-none-any.whl (14.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page