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

Uploaded Source

Built Distribution

yatbaf_menu-0.3.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yatbaf_menu-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 685d39e70998a13c818bcb96a2bd1432eb54f8d393e9c411c9f4bc7abd960ac4
MD5 8c1a12d0cc5412fc6deff7668bab59f3
BLAKE2b-256 0175bd4aa7056dc10989af3dd022ad652d567eeea6b1d5f6b0d43db3427498e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yatbaf_menu-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8655069ebd9eb8e1349d9836adaa977a133f46244cdca701a70ba0b0164f6053
MD5 3e7cb78f8b0cfc5686a5451abd165b1f
BLAKE2b-256 9b2b5bc6703e0a10ad4990ca18c129f44655637cefe35dcd673c653df178ee1a

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