Skip to content

Helpers API

NewsletterHelpers

Helpers for newsletter message serialization and builders.

Methods:

parse_message staticmethod

parse_message(data: bytes) -> Message

Deserialize protobuf bytes into a Message proto.

PARAMETER DESCRIPTION
data

Raw protobuf bytes.

TYPE: bytes

RETURNS DESCRIPTION
Message

Parsed Message proto.

Source code in python/tryx/helpers.py
    participant = GroupsHelpers.build_participant(
        jid=JID("1234567890", "s.whatsapp.net")
    )
"""

from ._tryx import helpers  # type: ignore

for name in dir(helpers):  # type: ignore
    obj = getattr(helpers, name)  # type: ignore
    if isinstance(obj, type):
        globals()[name] = obj

serialize_message staticmethod

serialize_message(message: Message) -> bytes

Serialize a Message proto into protobuf bytes.

PARAMETER DESCRIPTION
message

Message proto to serialize.

TYPE: Message

RETURNS DESCRIPTION
bytes

Serialized bytes.

Source code in python/tryx/helpers.py
__all__ = [name for name in dir(helpers) if isinstance(getattr(helpers, name), type)]  # type: ignore

build_text_message staticmethod

build_text_message(text: str) -> Message

Build a text-only Message proto.

PARAMETER DESCRIPTION
text

Message body text.

TYPE: str

RETURNS DESCRIPTION
Message

Message proto with conversation set.

GroupsHelpers

Helpers for group invite and option object construction.

Methods:

strip_invite_url staticmethod

strip_invite_url(code: str) -> str

Strip the WhatsApp invite URL prefix from a code.

PARAMETER DESCRIPTION
code

Full invite URL or raw code.

TYPE: str

RETURNS DESCRIPTION
str

Stripped invite code.

build_participant staticmethod

build_participant(
    jid: JID,
    phone_number: JID | None = None,
    privacy: bytes | None = None,
) -> GroupParticipantOptions

Build a GroupParticipantOptions object.

PARAMETER DESCRIPTION
jid

Participant JID.

TYPE: JID

phone_number

Optional phone number JID.

TYPE: JID | None DEFAULT: None

privacy

Optional privacy bytes.

TYPE: bytes | None DEFAULT: None

RETURNS DESCRIPTION
GroupParticipantOptions

GroupParticipantOptions instance.

build_create_options staticmethod

build_create_options(
    subject: str,
    participants: list[GroupParticipantOptions] = [],
    member_link_mode: MemberLinkMode | None = AdminLink,
    member_add_mode: MemberAddMode | None = AllMemberAdd,
    membership_approval_mode: MembershipApprovalMode
    | None = Off,
    ephemeral_expiration: int | None = 0,
    is_parent: bool = False,
    closed: bool = False,
    allow_non_admin_sub_group_creation: bool = False,
    create_general_chat: bool = False,
) -> CreateGroupOptions

Build a CreateGroupOptions object.

PARAMETER DESCRIPTION
subject

Group name.

TYPE: str

participants

List of initial participants.

TYPE: list[GroupParticipantOptions] DEFAULT: []

member_link_mode

Who can share the group link.

TYPE: MemberLinkMode | None DEFAULT: AdminLink

member_add_mode

Who can add members.

TYPE: MemberAddMode | None DEFAULT: AllMemberAdd

membership_approval_mode

Require approval for new members.

TYPE: MembershipApprovalMode | None DEFAULT: Off

ephemeral_expiration

Disappearing message timer in seconds.

TYPE: int | None DEFAULT: 0

is_parent

If True, create as a parent group.

TYPE: bool DEFAULT: False

closed

If True, only admins can edit group info.

TYPE: bool DEFAULT: False

allow_non_admin_sub_group_creation

Allow non-admins to create subgroups.

TYPE: bool DEFAULT: False

create_general_chat

Auto-create a general chat.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
CreateGroupOptions

CreateGroupOptions instance.

StatusHelpers

Helpers for status privacy and send options.

Methods:

build_send_options staticmethod

build_send_options(
    privacy: StatusPrivacySetting = Contacts,
) -> StatusSendOptions

Build a StatusSendOptions object.

PARAMETER DESCRIPTION
privacy

Privacy setting (Contacts, AllowList, DenyList).

TYPE: StatusPrivacySetting DEFAULT: Contacts

RETURNS DESCRIPTION
StatusSendOptions

StatusSendOptions instance.

default_privacy staticmethod

default_privacy() -> StatusPrivacySetting

Return the default status privacy setting.

RETURNS DESCRIPTION
StatusPrivacySetting

StatusPrivacySetting.Contacts.

ChatstateHelpers

Helpers for constructing chat state enum values.

Methods:

composing staticmethod

composing() -> ChatStateType

Return ChatStateType.Composing.

RETURNS DESCRIPTION
ChatStateType

ChatStateType for typing indicator.

recording staticmethod

recording() -> ChatStateType

Return ChatStateType.Recording.

RETURNS DESCRIPTION
ChatStateType

ChatStateType for recording indicator.

paused staticmethod

paused() -> ChatStateType

Return ChatStateType.Paused.

RETURNS DESCRIPTION
ChatStateType

ChatStateType for paused indicator.


Helpers in tryx.helpers are stateless utility surfaces for builders, enum defaults, and payload conversion.

Design intent

Use helpers for deterministic object construction and conversion logic. Keep side effects in client namespace calls.

NewsletterHelpers

Method Return
parse_message(data) MessageProto
serialize_message(message) bytes
build_text_message(text) MessageProto
from tryx.helpers import NewsletterHelpers

proto = NewsletterHelpers.build_text_message("Release update")
blob = NewsletterHelpers.serialize_message(proto)
restored = NewsletterHelpers.parse_message(blob)

GroupsHelpers

Method Purpose
strip_invite_url(code) Normalize invite URL/code
build_participant(...) Build GroupParticipantOptions
build_create_options(...) Build CreateGroupOptions
from tryx.helpers import GroupsHelpers

participant = GroupsHelpers.build_participant(jid=target_jid)
opts = GroupsHelpers.build_create_options(
    subject="Ops Room", participants=[participant]
)
result = await client.groups.create_group(opts)

StatusHelpers

Method Return
build_send_options(privacy=...) StatusSendOptions
default_privacy() StatusPrivacySetting
from tryx.helpers import StatusHelpers

options = StatusHelpers.build_send_options()
await client.status.send_text("status", 0xFF1F9D86, 1, recipients, options=options)

ChatstateHelpers

Method Return
composing() ChatStateType.Composing
recording() ChatStateType.Recording
paused() ChatStateType.Paused
from tryx.helpers import ChatstateHelpers

await client.chatstate.send(chat_jid, ChatstateHelpers.composing())

BlockingHelpers

Method Return
same_user(a, b) bool
from tryx.helpers import BlockingHelpers

if BlockingHelpers.same_user(a, b):
    print("Equivalent identity")

PollsHelpers

Method Return
decrypt_vote(...) list[bytes]
aggregate_votes(...) list[PollOptionResult]
from tryx.helpers import PollsHelpers

decoded = PollsHelpers.decrypt_vote(
    enc_payload, enc_iv, secret, poll_id, creator_jid, voter_jid
)

PresenceHelpers

Method Return
default_status() PresenceStatus
from tryx.helpers import PresenceHelpers

await client.presence.set(PresenceHelpers.default_status())

Integration Map

Use helpers before calling: - Groups Namespace - Status Namespace

Use helpers with: - Polls Namespace - Newsletter Namespace

Use helpers with: - Chatstate Namespace - Presence Namespace

Avoid mixing concerns

Helpers should not replace runtime validation. Keep business rules in handler/service layers.