Metadata-Version: 2.4
Name: gramix
Version: 0.1.1
Summary: Мощный фреймворк для создания Telegram ботов.
Author: riokzy
License-Expression: MIT
Project-URL: Homepage, https://github.com/riokzy/gramix
Project-URL: Repository, https://github.com/riokzy/gramix
Project-URL: Issues, https://github.com/riokzy/gramix/issues
Keywords: telegram,bot,framework,async,gramix
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Communications :: Chat
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.24.0
Provides-Extra: aiohttp
Requires-Dist: aiohttp>=3.9; extra == "aiohttp"
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100; extra == "fastapi"
Requires-Dist: uvicorn>=0.20; extra == "fastapi"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Dynamic: license-file

# gramix

[![PyPI](https://img.shields.io/pypi/v/gramix)](https://pypi.org/project/gramix)
[![Python](https://img.shields.io/pypi/pyversions/gramix)](https://pypi.org/project/gramix)
[![License](https://img.shields.io/pypi/l/gramix)](LICENSE)

Мощный фреймворк для создания Telegram ботов на Python.

```
pip install gramix
```

---

## Примеры

**Простой бот**

```python
from gramix import Bot, Dispatcher, Router
from gramix.env import load_env

load_env()

bot = Bot()
rt  = Router()
dp  = Dispatcher(bot)

@rt.message("/start")
def on_start(msg):
    msg.reply(f"Привет, {msg.from_user.first_name}!")

@rt.message()
def echo(msg):
    msg.reply(msg.text)

dp.include(rt)
dp.run()
```

**Inline клавиатура**

```python
from gramix import Inline

@rt.message("/menu")
def on_menu(msg):
    kb = Inline()
    kb.button("Да", callback="yes")
    kb.button("Нет", callback="no")
    msg.reply("Выбери:", keyboard=kb)

@rt.callback("yes")
def on_yes(call):
    call.answer("Отлично!")
    call.message.edit("✅ Выбрано: Да")
```

**FSM**

```python
from gramix import State, Step

class Form(State):
    name = Step()
    age  = Step()

@rt.message("/start")
def on_start(msg):
    state = rt.fsm.get(msg.from_user.id)
    state.set(Form.name)
    msg.reply("Как тебя зовут?")

@rt.state(Form.name)
def get_name(msg, state):
    state.data["name"] = msg.text
    state.next()
    msg.reply("Сколько лет?")

@rt.state(Form.age)
def get_age(msg, state):
    name = state.data["name"]
    state.finish()
    msg.reply(f"{name}, {msg.text} лет — записал.")
```

**Async**

```python
@rt.message("/start")
async def on_start(msg):
    await msg.answer("Привет!")

dp.run_async()
```

Больше примеров в папке [`examples/`](examples/).

---

## Лицензия

MIT © riokzy
