Metadata-Version: 2.4
Name: maxbot-sdk
Version: 0.5.0
Summary: Async library for MAX Messenger bots
Project-URL: Homepage, https://github.com/Veremud/maxbot-sdk
Project-URL: Repository, https://github.com/Veremud/maxbot-sdk
Project-URL: Issues, https://github.com/Veremud/maxbot-sdk/issues
Project-URL: Changelog, https://github.com/Veremud/maxbot-sdk/blob/main/CHANGELOG.md
Author: Veremud
License-Expression: MIT
License-File: LICENSE
Keywords: async,bot,max,maxbot,messenger
Requires-Python: >=3.10
Requires-Dist: certifi>=2024.0.0
Requires-Dist: httpx>=0.27
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: redis
Requires-Dist: redis>=5.0; extra == 'redis'
Provides-Extra: webhook
Requires-Dist: uvicorn>=0.30; extra == 'webhook'
Description-Content-Type: text/markdown

# maxbot-sdk

Библиотека для ботов в [MAX](https://dev.max.ru/docs-api/).  
Async, декораторы на `Bot`, polling / webhook, клавиатуры, файлы, простой FSM.

```bash
pip install maxbot-sdk
# опционально:
pip install "maxbot-sdk[webhook]"
pip install "maxbot-sdk[redis]"
```

```python
import os
from maxbot import Bot, types

bot = Bot(token=os.environ["MAX_BOT_TOKEN"])

@bot.message_handler(commands=["start"])
async def start(message: types.Message):
    await message.answer("ok")

@bot.message_handler(func=lambda m: True)
async def echo(message: types.Message):
    await message.answer(message.text or "")

bot.run()
```

## Что внутри

- хендлеры: `message_handler`, `callback_query_handler`, `bot_started_handler`, middleware
- сообщения, чаты, pin, members, `send_chat_action`
- медиа: `send_photo` / `send_document` / `download`, retry на `attachment.not.ready`
- FSM: `MemoryStorage`, `RedisStorage` (`state=` в хендлерах)
- кнопки: callback, link, message, contact, geo, clipboard, open_app
- сырой API: `bot.call(...)` и `bot.api.*`
- SSL с CA Минцифры (для CDN MAX)

Примеры: [`examples/`](examples/).  
Проверка руками: [`docs/SMOKE.md`](docs/SMOKE.md).

## Redis

```python
from maxbot import Bot
from maxbot.storage import RedisStorage

bot = Bot(
    token="...",
    storage=RedisStorage(url="redis://localhost:6379/0", prefix="mybot", ttl=86400),
)
```

## Webhook

```python
app = bot.create_webhook_app(path="/webhook", secret="s3cret")

# или сразу:
await bot.run_webhook(
    listen="https://host/webhook",
    secret="s3cret",
)
```

Нужен `pip install "maxbot-sdk[webhook]"`.

## API

```python
me = await bot.call("GET", "/me")
await bot.api.get_chat(123)
await bot.send_chat_action(123)
```

Ошибки — `ApiError` (есть `.is_rate_limited`, `.is_attachment_not_ready`).
