Metadata-Version: 2.1
Name: yatbaf-menu
Version: 0.3.2
Summary: Inline menu builder for yatbaf
Project-URL: Source, https://codeberg.org/maraudeur/yatbaf-menu
Author-email: Maraudeur <maraudeur1@protonmail.ch>
License:  The MIT License (MIT)
        
         Copyright (c) 2023 Maraudeur
        
         Permission is hereby granted, free of charge, to any person obtaining
         a copy of this software and associated documentation files (the
         "Software"), to deal in the Software without restriction, including
         without limitation the rights to use, copy, modify, merge, publish,
         distribute, sublicense, and/or sell copies of the Software, and to
         permit persons to whom the Software is furnished to do so, subject to
         the following conditions:
        
         The above copyright notice and this permission notice shall be included
         in all copies or substantial portions of the Software.
        
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
         IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
         CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
         TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
         SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Keywords: telegram-bot,telegram-bot-api,yatbaf
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: yatbaf<1.0.0,>=0.7.0
Provides-Extra: dev
Requires-Dist: pre-commit<4.0.0,>=3.0.0; extra == 'dev'
Provides-Extra: lint
Requires-Dist: flake8-bugbear==23.3.23; extra == 'lint'
Requires-Dist: flake8-unused-arguments==0.0.13; extra == 'lint'
Requires-Dist: flake8==6.0.0; extra == 'lint'
Requires-Dist: isort<6.0.0,>=5.10.0; extra == 'lint'
Requires-Dist: mypy==1.3.0; extra == 'lint'
Requires-Dist: yapf==0.40.1; extra == 'lint'
Provides-Extra: test
Requires-Dist: coverage==7.1.0; extra == 'test'
Requires-Dist: pytest-asyncio==0.21.0; extra == 'test'
Requires-Dist: pytest-cov==4.0.0; extra == 'test'
Requires-Dist: pytest>=7.0.0; extra == 'test'
Description-Content-Type: text/markdown

## yatbaf-menu

Inline menu builder for [yatbaf](https://codeberg.org/maraudeur/yatbaf).

## Installation

```shell
$ pip install yatbaf-menu
```

## Usage

```python
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](media/click.gif)

[code](examples/click.py)

### URL
URL button

![url pic](media/url.webp)

[code](examples/url.py)

### Submenu
Submenu button

![submenu gif](media/submenu.gif)

[code](examples/submenu.py)

### Choice

![choice gif](media/choice.gif)

[code](examples/choice.py)

### Pagination

![paging gif](media/paging.gif)

[code](examples/paging.py)

### Dynamic titles and visibility

![dynamic gif](media/dynamic.gif)

[code](examples/dynamic.py)

## License
[MIT](./LICENSE)
