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.di import Provide
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")


@on_message(filters=[Command("menu")])
async def open_menu(message: Message, menu: Menu) -> None:
    await menu.render(message)


menu = Menu(
    title="Menu title",
    buttons=[
        [
            Action(title="Click 1", action=button1),
            Action(title="Click 2", action=button2),
        ],
    ],
)

Bot(
    "<replace-with-your-token>",
    handlers=[open_menu, build_router(menu)],
    dependencies={"menu": Provide(menu.provide)},
).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.5.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

yatbaf_menu-0.5.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file yatbaf_menu-0.5.0.tar.gz.

File metadata

  • Download URL: yatbaf_menu-0.5.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.0

File hashes

Hashes for yatbaf_menu-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7cbad04b76f71343727d28b7123f4f6d64af87cc383dee1d77df257ba66f2437
MD5 25a4f9caa17ba45126d779e00a56b132
BLAKE2b-256 bc35dc3661b51c1cd133b6046d0c08113e8729921f14c3584aa3bb9a682e0d3b

See more details on using hashes here.

File details

Details for the file yatbaf_menu-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: yatbaf_menu-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.0

File hashes

Hashes for yatbaf_menu-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff5cc6f1d71e39c254fcda5470583d4d05e8d0d0d65f65973a7f9c03c3fd6b8b
MD5 f6fddbe121ff4f76657ba509332a67a8
BLAKE2b-256 afb4a698014012f47616f04ee8d5f8d8d387e956b9b3cdbe437bbbf4553a268f

See more details on using hashes here.

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