Skip to main content

Binary CallbackData serialization for aiogram 3.x

Project description

aiogram-bincallback

Библиотека для aiogram 3.x, сериализующая CallbackData в бинарном виде вместо текстового формата key:value. Каждое поле упаковывается в заданное число бит, что позволяет уместить больше данных в лимит Telegram на callback_data в 64 байта и явно контролировать структуру данных.

Установка

pip install aiogram-bincallback

Использование

from enum import Enum, IntEnum

from aiogram_bincallback import BinaryCallbackData, bfield


class CbPrefix(IntEnum):
    ORDER = 1
    HOME = 2


class Status(str, Enum):
    PENDING = "pending"
    SHIPPED = "shipped"


class OrderCb(BinaryCallbackData, prefix=CbPrefix.ORDER.value, version=1):
    order_id: int = bfield(bits=16, signed=False)
    status: Status = bfield(bits=4)

Поддерживаемые типы полей, правила вложенности и обработка ошибок описаны в тестах в директории tests/.

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

aiogram_bincallback-0.3.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram_bincallback-0.3.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiogram_bincallback-0.3.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiogram_bincallback-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8f69e37757c363c6933f8ecd7e14273f47af25d355bec136a9c91c1b0ae3d6c4
MD5 1b13b907119e455e17a531a4ef93648c
BLAKE2b-256 7eb372454662d55dee6e2e19ee213ab25af9048681c6cfd1e0c78160d725537f

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_bincallback-0.3.0.tar.gz:

Publisher: release.yml on boykopovar/aiogram-bincallback

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for aiogram_bincallback-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c88353bdbdc696a749e69819fe2108d501045c4e545f89d9589ec26ea483008c
MD5 bf2c02304262df12aeef48f846061e8d
BLAKE2b-256 b29e71887b5347b550f0b9e85baaa6ed935ddd6f8bc204a336703361c2c2f884

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_bincallback-0.3.0-py3-none-any.whl:

Publisher: release.yml on boykopovar/aiogram-bincallback

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page