A Python SDK for building bots and applications on the Mezon platform. Async-first, type-safe, and production-ready.
pip install mezon-sdkimport asyncio
from mezon import MezonClient
from mezon.models import ChannelMessage, ChannelMessageContent
client = MezonClient(
client_id="YOUR_BOT_ID",
api_key="YOUR_API_KEY",
)
async def handle_message(message: ChannelMessage):
if message.sender_id == client.client_id:
return
channel = await client.channels.fetch(message.channel_id)
await channel.send(content=ChannelMessageContent(t="Hello!"))
client.on_channel_message(handle_message)
async def main():
await client.login()
await asyncio.Event().wait()
asyncio.run(main())Full documentation: https://docs.laptrinhai.id.vn/
- Async/await native with
asyncio - Real-time WebSocket with auto-reconnection
- Type-safe with Pydantic models
- Event-driven architecture
- Interactive messages (buttons, forms)
- Token sending support
- Message caching with SQLite
Pytest is the primary path for focused unit and regression coverage.
For regression coverage around socket/protobuf/login behavior, run:
uv run pytest tests/unit/test_socket_regressions.pyYou can also run the broader pytest suite with:
uv run pytest tests/For broader integration coverage against a real Mezon environment, set the required MEZON_* environment variables and run:
uv run python -m tests.test_runnerThe integration runner includes the reconnect/login suite in tests/test_reconnect.py.
Apache License 2.0 - see LICENSE for details.