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 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

click gif

code

URL

URL button

url pic

code

Submenu

Submenu button

submenu gif

code

Dynamic

You can use a dynamic show/hide for buttons and dynamic text for button/menu title.

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.2.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

yatbaf_menu-0.2.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yatbaf_menu-0.2.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for yatbaf_menu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e1596aad6257ac68d34d02ca304dd496b22b6f54237d982f3c4230c5270ecaf7
MD5 3f4e01e431195f7c52124db6f800a19d
BLAKE2b-256 69b98b64fd55f128e50a592c68a08e44136a47be632507ffb8bd856d18d25179

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yatbaf_menu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for yatbaf_menu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70afa2effcd9ad8072beff2b730ccb321f93b95820fab7c5fa824d1fd0faf538
MD5 c1c6ac938a9382f6ca81124370b03271
BLAKE2b-256 72225f7785f378f4d713fe23636bfa8cd74a9bb19994d3d8ae1aa18e84b1d25e

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