Skip to content

API Reference

Complete API reference for Neonize.

Overview

This section provides comprehensive API documentation for all Neonize modules, classes, and functions.

Modules

Core Client

neonize.client.NewClient

Python
NewClient(name: str, jid: Optional[JID] = None, props: Optional[DeviceProps] = None, uuid: Optional[str] = None)

Initializes a new client instance.

PARAMETER DESCRIPTION
name

The name or identifier for the new client.

TYPE: str

jid

Optional. The JID (Jabber Identifier) for the client. If not provided, first client is used.

TYPE: Optional[JID] DEFAULT: None

qrCallback

Optional. A callback function for handling QR code updates, defaults to None.

TYPE: (Optional[Callable[[NewClient, bytes], None]], optional)

messageCallback

Optional. A callback function for handling incoming messages, defaults to None.

TYPE: (Optional[Callable[[NewClient, MessageSource, Message], None]], optional)

uuid

Optional. A unique identifier for the client, defaults to None.

TYPE: Optional[str] DEFAULT: None

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def __init__(
    self,
    name: str,
    jid: Optional[JID] = None,
    props: Optional[DeviceProps] = None,
    uuid: Optional[str] = None,
):
    """Initializes a new client instance.

    :param name: The name or identifier for the new client.
    :type name: str
    :param jid: Optional. The JID (Jabber Identifier) for the client. If not provided, first client is used.
    :param qrCallback: Optional. A callback function for handling QR code updates, defaults to None.
    :type qrCallback: Optional[Callable[[NewClient, bytes], None]], optional
    :param messageCallback: Optional. A callback function for handling incoming messages, defaults to None.
    :type messageCallback: Optional[Callable[[NewClient, MessageSource, Message], None]], optional
    :param uuid: Optional. A unique identifier for the client, defaults to None.
    :type uuid: Optional[str], optional
    """
    self.name = name
    self.device_props = props
    self.jid = jid
    self.uuid = (jid.User if jid else (uuid or name)).encode()
    self.__client = gocode
    self.event = Event(self)
    self.qr = self.event.qr
    self.contact = ContactStore(self.uuid)
    self.chat_settings = ChatSettingsStore(self.uuid)
    self.connected = False
    self.me = None
    _log_.debug("🔨 Creating a NewClient instance")

Attributes

is_connected property

Python
is_connected: bool

Check if the object is currently connected.

RETURNS DESCRIPTION
bool

True if the object is connected, False otherwise.

is_logged_in property

Python
is_logged_in: bool

Check if the user is currently logged in.

RETURNS DESCRIPTION
bool

True if the user is logged in, False otherwise.

Functions

send_message

Python
send_message(to: JID, message: Union[Message, str], link_preview: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a message to the specified JID.

PARAMETER DESCRIPTION
to

The JID to send the message to.

TYPE: JID

message

The message to send.

TYPE: Union[Message, str]

link_preview

Whether to send a link preview, defaults to False

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

The response from the server.

RAISES DESCRIPTION
SendMessageError

If there was an error sending the message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_message(
    self,
    to: JID,
    message: typing.Union[Message, str],
    link_preview: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Send a message to the specified JID.

    :param to: The JID to send the message to.
    :type to: JID
    :param message: The message to send.
    :type message: typing.Union[Message, str]
    :param link_preview: Whether to send a link preview, defaults to False
    :type link_preview: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :raises SendMessageError: If there was an error sending the message.
    :return: The response from the server.
    :rtype: SendResponse
    """
    to_bytes = to.SerializeToString()
    if isinstance(message, str):
        mentioned_groups = self._parse_group_mention(message)
        mentioned_jid = self._parse_mention(
            (ghost_mentions or message), mentions_are_lids
        )
        partial_msg = ExtendedTextMessage(
            text=message,
            contextInfo=ContextInfo(
                mentionedJID=mentioned_jid, groupMentions=mentioned_groups
            ),
        )
        if link_preview:
            preview = self._generate_link_preview(message)
            if preview:
                partial_msg.MergeFrom(preview)
        if partial_msg.previewType is None and not (
            mentioned_groups or mentioned_jid
        ):
            msg = Message(conversation=message)
        else:
            msg = Message(extendedTextMessage=partial_msg)
    else:
        msg = message
    if add_msg_secret:
        msg.messageContextInfo.messageSecret = urandom(32)
    message_bytes = msg.SerializeToString()
    bytes_ptr = self.__client.SendMessage(
        self.uuid, to_bytes, len(to_bytes), message_bytes, len(message_bytes)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SendMessageReturnFunction.FromString(protobytes)
    if model.Error:
        raise SendMessageError(model.Error)
    model.SendResponse.MergeFrom(model.SendResponse.__class__(Message=msg))
    return model.SendResponse

build_reply_message

Python
build_reply_message(message: Union[str, MessageWithContextInfo], quoted: Message, link_preview: bool = False, reply_privately: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

Send a reply message to a specified JID.

PARAMETER DESCRIPTION
message

The message to be sent. Can be a string or a MessageWithContextInfo object.

TYPE: Union[str, MessageWithContextInfo]

quoted

The message to be quoted in the message being sent.

TYPE: Message

link_preview

If set to True, enables link previews in the message being sent. Defaults to False.

TYPE: bool DEFAULT: False

reply_privately

If set to True, the message is sent as a private reply. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

Response of the send operation.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_reply_message(
    self,
    message: typing.Union[str, MessageWithContextInfo],
    quoted: neonize_proto.Message,
    link_preview: bool = False,
    reply_privately: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """Send a reply message to a specified JID.

    :param message: The message to be sent. Can be a string or a MessageWithContextInfo object.
    :type message: typing.Union[str, MessageWithContextInfo]
    :param quoted: The message to be quoted in the message being sent.
    :type quoted: neonize_proto.Message
    :param link_preview: If set to True, enables link previews in the message being sent. Defaults to False.
    :type link_preview: bool, optional
    :param reply_privately: If set to True, the message is sent as a private reply. Defaults to False.
    :type reply_privately: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :return: Response of the send operation.
    :rtype: SendResponse
    """
    build_message = Message()
    if isinstance(message, str):
        partial_message = ExtendedTextMessage(
            text=message,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or message), mentions_are_lids
                ),
                groupMentions=(self._parse_group_mention(message)),
            ),
        )
        if link_preview:
            preview = self._generate_link_preview(message)
            if preview is not None:
                partial_message.MergeFrom(preview)
    else:
        partial_message = message
    field_name = (
        partial_message.__class__.__name__[0].lower()
        + partial_message.__class__.__name__[1:]
    )  # type: ignore
    partial_message.contextInfo.MergeFrom(
        self._make_quoted_message(quoted, reply_privately)
    )
    getattr(build_message, field_name).MergeFrom(partial_message)
    return build_message

reply_message

Python
reply_message(message: Union[str, MessageWithContextInfo], quoted: Message, to: Optional[JID] = None, link_preview: bool = False, reply_privately: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a reply message to a specified JID.

PARAMETER DESCRIPTION
message

The message to be sent. Can be a string or a MessageWithContextInfo object.

TYPE: Union[str, MessageWithContextInfo]

quoted

The message to be quoted in the message being sent.

TYPE: Message

to

The recipient of the message. If not specified, the message is sent to the default recipient.

TYPE: Optional[JID] DEFAULT: None

link_preview

If set to True, enables link previews in the message being sent. Defaults to False.

TYPE: bool DEFAULT: False

reply_privately

If set to True, the message is sent as a private reply. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

If set to True generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

Response of the send operation.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def reply_message(
    self,
    message: typing.Union[str, MessageWithContextInfo],
    quoted: neonize_proto.Message,
    to: Optional[JID] = None,
    link_preview: bool = False,
    reply_privately: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Send a reply message to a specified JID.

    :param message: The message to be sent. Can be a string or a MessageWithContextInfo object.
    :type message: typing.Union[str, MessageWithContextInfo]
    :param quoted: The message to be quoted in the message being sent.
    :type quoted: neonize_proto.Message
    :param to: The recipient of the message. If not specified, the message is sent to the default recipient.
    :type to: Optional[JID], optional
    :param link_preview: If set to True, enables link previews in the message being sent. Defaults to False.
    :type link_preview: bool, optional
    :param reply_privately: If set to True, the message is sent as a private reply. Defaults to False.
    :type reply_privately: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: If set to True generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: Response of the send operation.
    :rtype: SendResponse
    """
    if to is None:
        if reply_privately:
            sender = quoted.Info.MessageSource.Sender
            if jid_is_lid(sender):
                sender = quoted.Info.MessageSource.SenderAlt or sender
            to = JIDToNonAD(sender)
        else:
            to = quoted.Info.MessageSource.Chat
    return self.send_message(
        to,
        self.build_reply_message(
            message=message,
            quoted=quoted,
            link_preview=link_preview,
            reply_privately=reply_privately,
            ghost_mentions=ghost_mentions,
            mentions_are_lids=mentions_are_lids,
        ),
        link_preview,
        add_msg_secret=add_msg_secret,
    )

edit_message

Python
edit_message(chat: JID, message_id: str, new_message: Message) -> SendResponse

Edit a message.

PARAMETER DESCRIPTION
chat

Chat ID

TYPE: JID

message_id

Message ID

TYPE: str

new_message

New message

TYPE: Message

RETURNS DESCRIPTION
SendResponse

Response from server

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def edit_message(
    self, chat: JID, message_id: str, new_message: Message
) -> SendResponse:
    """Edit a message.

    :param chat: Chat ID
    :type chat: JID
    :param message_id: Message ID
    :type message_id: str
    :param new_message: New message
    :type new_message: Message
    :return: Response from server
    :rtype: SendResponse
    """
    return self.send_message(chat, build_edit(chat, message_id, new_message))

revoke_message

Python
revoke_message(chat: JID, sender: JID, message_id: str) -> SendResponse

Revoke a message.

PARAMETER DESCRIPTION
chat

Chat ID

TYPE: JID

sender

Sender ID

TYPE: JID

message_id

Message ID

TYPE: str

RETURNS DESCRIPTION
SendResponse

Response from server

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def revoke_message(self, chat: JID, sender: JID, message_id: str) -> SendResponse:
    """Revoke a message.

    :param chat: Chat ID
    :type chat: JID
    :param sender: Sender ID
    :type sender: JID
    :param message_id: Message ID
    :type message_id: str
    :return: Response from server
    :rtype: SendResponse
    """
    return self.send_message(chat, self.build_revoke(chat, sender, message_id))

build_poll_vote_creation

Python
build_poll_vote_creation(name: str, options: List[str], selectable_count: VoteType, quoted: Optional[Message] = None) -> Message

Build a poll vote creation message.

PARAMETER DESCRIPTION
name

The name of the poll.

TYPE: str

options

The options for the poll.

TYPE: List[str]

selectable_count

The number of selectable options.

TYPE: VoteType

quoted

A message that the poll message is a reply to, defaults to None

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
Message

The poll vote creation message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_poll_vote_creation(
    self,
    name: str,
    options: List[str],
    selectable_count: VoteType,
    quoted: Optional[neonize_proto.Message] = None,
) -> Message:
    """Build a poll vote creation message.

    :param name: The name of the poll.
    :type name: str
    :param options: The options for the poll.
    :type options: List[str]
    :param selectable_count: The number of selectable options.
    :type selectable_count: int
    :param quoted: A message that the poll message is a reply to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :return: The poll vote creation message.
    :rtype: Message
    """
    options_buf = neonize_proto.ArrayString(data=options).SerializeToString()
    bytes_ptr = self.__client.BuildPollVoteCreation(
        self.uuid,
        name.encode(),
        options_buf,
        len(options_buf),
        selectable_count.value,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = BuildMessageReturnFunction.FromString(protobytes)
    if model.Error:
        raise BuildPollVoteCreationError(model.Error)
    message = model.Message

    if quoted:
        message.pollCreationMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

build_poll_vote

Python
build_poll_vote(poll_info: MessageInfo, option_names: List[str]) -> Message

Builds a poll vote.

PARAMETER DESCRIPTION
poll_info

The information about the poll.

TYPE: MessageInfo

option_names

The names of the options to vote for.

TYPE: List[str]

RETURNS DESCRIPTION
Message

The poll vote message.

RAISES DESCRIPTION
BuildPollVoteError

If there is an error building the poll vote.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_poll_vote(
    self, poll_info: MessageInfo, option_names: List[str]
) -> Message:
    """Builds a poll vote.

    :param poll_info: The information about the poll.
    :type poll_info: MessageInfo
    :param option_names: The names of the options to vote for.
    :type option_names: List[str]
    :return: The poll vote message.
    :rtype: Message
    :raises BuildPollVoteError: If there is an error building the poll vote.
    """
    option_names_proto = neonize_proto.ArrayString(
        data=option_names
    ).SerializeToString()
    poll_info_proto = poll_info.SerializeToString()
    bytes_ptr = self.__client.BuildPollVote(
        self.uuid,
        poll_info_proto,
        len(poll_info_proto),
        option_names_proto,
        len(option_names_proto),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.BuildPollVoteReturnFunction.FromString(protobytes)
    if model.Error:
        raise BuildPollVoteError(model.Error)
    return model.PollVote

build_reaction

Python
build_reaction(chat: JID, sender: JID, message_id: str, reaction: str) -> Message

This function builds a reaction message in a chat. It takes the chat and sender IDs, the message ID to which the reaction is being made, and the reaction itself as input. It then serializes the chat and sender IDs to strings, and calls the BuildReaction function of the client with these serialized IDs, the message ID, and the reaction. It finally returns the reaction message.

PARAMETER DESCRIPTION
chat

The ID of the chat in which the reaction is being made

TYPE: JID

sender

The ID of the sender making the reaction

TYPE: JID

message_id

The ID of the message to which the reaction is being made

TYPE: str

reaction

The reaction being made

TYPE: str

RETURNS DESCRIPTION
Message

The reaction message

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_reaction(
    self, chat: JID, sender: JID, message_id: str, reaction: str
) -> Message:
    """
    This function builds a reaction message in a chat. It takes the chat and sender IDs,
    the message ID to which the reaction is being made, and the reaction itself as input.
    It then serializes the chat and sender IDs to strings, and calls the BuildReaction
    function of the client with these serialized IDs, the message ID, and the reaction.
    It finally returns the reaction message.

    :param chat: The ID of the chat in which the reaction is being made
    :type chat: JID
    :param sender: The ID of the sender making the reaction
    :type sender: JID
    :param message_id: The ID of the message to which the reaction is being made
    :type message_id: str
    :param reaction: The reaction being made
    :type reaction: str
    :return: The reaction message
    :rtype: Message
    """
    sender_proto = sender.SerializeToString()
    chat_proto = chat.SerializeToString()
    bytes_ptr = self.__client.BuildReaction(
        self.uuid,
        chat_proto,
        len(chat_proto),
        sender_proto,
        len(sender_proto),
        message_id.encode(),
        reaction.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = BuildMessageReturnFunction.FromString(protobytes)
    if result.Error:
        raise SendMessageError(result.Error)
    return result.Message

build_revoke

Python
build_revoke(chat: JID, sender: JID, message_id: str, with_go: bool = False) -> Message

Builds a message to revoke a previous message.

PARAMETER DESCRIPTION
chat

The JID (Jabber Identifier) of the chat where the message should be revoked.

TYPE: JID

sender

The JID of the sender of the message to be revoked.

TYPE: JID

message_id

The unique identifier of the message to be revoked.

TYPE: str

RETURNS DESCRIPTION
Message

The constructed Message object for revoking the specified message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_revoke(
    self, chat: JID, sender: JID, message_id: str, with_go: bool = False
) -> Message:
    """Builds a message to revoke a previous message.

    :param chat: The JID (Jabber Identifier) of the chat where the message should be revoked.
    :type chat: JID
    :param sender: The JID of the sender of the message to be revoked.
    :type sender: JID
    :param message_id: The unique identifier of the message to be revoked.
    :type message_id: str
    :return: The constructed Message object for revoking the specified message.
    :rtype: Message
    """
    if with_go:
        chat_buf = chat.SerializeToString()
        sender_buf = sender.SerializeToString()
        bytes_ptr = self.__client.BuildRevoke(
            self.uuid,
            chat_buf,
            len(chat_buf),
            sender_buf,
            len(sender_buf),
            message_id.encode(),
        )
        protobytes = bytes_ptr.contents.get_bytes()
        free_bytes(bytes_ptr)
        result = Message.FromString(protobytes)
        return result
    else:
        return build_revoke(chat, sender, message_id, self.get_me().JID)

build_sticker_message

Python
build_sticker_message(file: Union[str, bytes], quoted: Optional[Message] = None, name: str = '', packname: str = '', crop: bool = False, enforce_not_broken: bool = False, animated_gif: bool = False, passthrough: bool = False) -> Message

This function builds a sticker message from a given image or video file. The file is converted to a webp format and uploaded to a server. The resulting URL and other metadata are used to construct the sticker message.

PARAMETER DESCRIPTION
file

The path to the image or video file or the file data in bytes

TYPE: Union[str, bytes]

quoted

A message that the sticker message is a reply to, defaults to None

TYPE: Optional[Message] DEFAULT: None

name

The name of the sticker, defaults to ""

TYPE: str DEFAULT: ''

packname

The name of the sticker pack, defaults to ""

TYPE: str DEFAULT: ''

crop

Crop-center the image, defaults to False

TYPE: bool DEFAULT: False

enforce_not_broken

Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False

TYPE: bool DEFAULT: False

animated_gif

Ensure transparent media are properly processed, defaults to False

TYPE: bool DEFAULT: False

passthrough

Don't process sticker, send as is, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Message

The constructed sticker message

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_sticker_message(
    self,
    file: typing.Union[str, bytes],
    quoted: Optional[neonize_proto.Message] = None,
    name: str = "",
    packname: str = "",
    crop: bool = False,
    enforce_not_broken: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
) -> Message:
    """
    This function builds a sticker message from a given image or video file.
    The file is converted to a webp format and uploaded to a server.
    The resulting URL and other metadata are used to construct the sticker message.

    :param file: The path to the image or video file or the file data in bytes
    :type file: typing.Union[str, bytes]
    :param quoted: A message that the sticker message is a reply to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :param name: The name of the sticker, defaults to ""
    :type name: str, optional
    :param packname: The name of the sticker pack, defaults to ""
    :type packname: str, optional
    :param crop: Crop-center the image, defaults to False
    :type crop: bool, optional
    :param enforce_not_broken: Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
    :type enforce_not_broken: bool, optional
    :param animated_gif: Ensure transparent media are properly processed, defaults to False
    :type animated_gif: bool, optional
    :param passthrough: Don't process sticker, send as is, defaults to False.
    :type passthrough: bool, optional
    :return: The constructed sticker message
    :rtype: Message
    """
    sticker = get_bytes_from_name_or_url(file)
    animated = is_webm = is_webp = is_image = saved_exif = False
    mime = magic.from_buffer(sticker, mime=True)
    if mime == "image/webp":
        is_webp = True
        io_save = BytesIO(sticker)
        img = Image.open(io_save)
        if len(ImageSequence.all_frames(img)) < 2:
            is_image = True
    elif mime == "video/webm":
        is_webm = True
    elif (mime := mime.split("/"))[0] == "image":
        is_image = True
    animated = not (is_image)
    if not passthrough and not animated_gif and is_image:
        io_save = BytesIO(sticker)
        stk = auto_sticker(io_save) if crop else original_sticker(io_save)
        io_save = BytesIO()
        # io_save.seek(0)
    elif not passthrough:
        animated = True
        sticker, saved_exif = convert_to_sticker(
            sticker, name, packname, enforce_not_broken, animated_gif, is_webm
        )
        if saved_exif:
            io_save = BytesIO(sticker)
        else:
            stk = Image.open(BytesIO(sticker))
            io_save = BytesIO()
    else:
        if not is_webp:
            raise ConvertStickerError(
                "File is not a webp, which is required for passthrough."
            )
    if not (passthrough or saved_exif):
        stk.save(
            io_save,
            format="webp",
            exif=add_exif(name, packname),
            save_all=True,
            loop=0,
        )
    upload = self.upload(io_save.getvalue())
    message = Message(
        stickerMessage=StickerMessage(
            URL=upload.url,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(io_save.getvalue(), mime=True),
            isAnimated=animated,
        )
    )
    if quoted:
        message.stickerMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_sticker

Python
send_sticker(to: JID, file: Union[str, bytes], quoted: Optional[Message] = None, name: str = '', packname: str = '', crop: bool = False, enforce_not_broken: bool = False, animated_gif: bool = False, passthrough: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a sticker to a specific JID.

PARAMETER DESCRIPTION
to

The JID to send the sticker to.

TYPE: JID

file

The file path of the sticker or the sticker data in bytes.

TYPE: Union[str, bytes]

quoted

The quoted message, if any, defaults to None.

TYPE: Optional[Message] DEFAULT: None

name

The name of the sticker, defaults to "".

TYPE: str DEFAULT: ''

packname

The name of the sticker pack, defaults to "".

TYPE: str DEFAULT: ''

crop

Whether to crop-center the image, defaults to False

TYPE: bool DEFAULT: False

enforce_not_broken

Whether to enforce non-broken stickers by constraining sticker size to WA limits, defaults to False

TYPE: bool DEFAULT: False

animated_gif

Ensure transparent media are properly processed, defaults to False

TYPE: bool DEFAULT: False

passthrough

Don't process sticker, send as is, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

The response from the send message function.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_sticker(
    self,
    to: JID,
    file: typing.Union[str, bytes],
    quoted: Optional[neonize_proto.Message] = None,
    name: str = "",
    packname: str = "",
    crop: bool = False,
    enforce_not_broken: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """
    Send a sticker to a specific JID.

    :param to: The JID to send the sticker to.
    :type to: JID
    :param file: The file path of the sticker or the sticker data in bytes.
    :type file: typing.Union[str, bytes]
    :param quoted: The quoted message, if any, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param name: The name of the sticker, defaults to "".
    :type name: str, optional
    :param packname: The name of the sticker pack, defaults to "".
    :type packname: str, optional
    :param crop: Whether to crop-center the image, defaults to False
    :type crop: bool, optional
    :param enforce_not_broken: Whether to enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
    :type enforce_not_broken: bool, optional
    :param animated_gif: Ensure transparent media are properly processed, defaults to False
    :type animated_gif: bool, optional
    :param passthrough: Don't process sticker, send as is, defaults to False.
    :type passthrough: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: The response from the send message function.
    :rtype: SendResponse
    """
    return self.send_message(
        to,
        self.build_sticker_message(
            file,
            quoted,
            name,
            packname,
            crop,
            enforce_not_broken,
            animated_gif,
            passthrough,
        ),
        add_msg_secret=add_msg_secret,
    )

send_stickerpack

Python
send_stickerpack(to: JID, files: list, quoted: Optional[Message] = None, packname: str = 'Sticker pack', publisher: str = '', crop: bool = False, animated_gif: bool = False, passthrough: bool = False, add_msg_secret: bool = False) -> List[SendResponse]

Send a sticker pack to a specific JID.

PARAMETER DESCRIPTION
to

The JID to send the sticker to.

TYPE: JID

files

A list of file paths of the stickers or a list of stickers data in bytes.

TYPE: list

quoted

The quoted message, if any, defaults to None.

TYPE: Optional[Message] DEFAULT: None

packname

The name of the sticker pack, defaults to "Sticker pack".

TYPE: str DEFAULT: 'Sticker pack'

publisher

The name of the publisher, defaults to "".

TYPE: str DEFAULT: ''

crop

Whether to crop-center the image, defaults to False

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
List[SendResponse]

A list of response(s) from the send message function.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_stickerpack(
    self,
    to: JID,
    files: list,
    quoted: Optional[neonize_proto.Message] = None,
    packname: str = "Sticker pack",
    publisher: str = "",
    crop: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
    add_msg_secret: bool = False,
) -> List[SendResponse]:
    """
    Send a sticker pack to a specific JID.

    :param to: The JID to send the sticker to.
    :type to: JID
    :param files:  A list of file paths of the stickers or a list of stickers data in bytes.
    :type file: List[typing.Union[str, bytes]]
    :param quoted: The quoted message, if any, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param packname: The name of the sticker pack, defaults to "Sticker pack".
    :type packname: str, optional
    :param publisher: The name of the publisher, defaults to "".
    :type publisher: str, optional
    :param crop: Whether to crop-center the image, defaults to False
    :type crop: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A list of response(s) from the send message function.
    :rtype: List[SendResponse]
    """
    responses = []
    msgs = self.build_stickerpack_message(
        files, quoted, packname, publisher, crop, animated_gif, passthrough
    )
    for msg in msgs:
        response = self.send_message(
            to,
            msg,
            add_msg_secret=add_msg_secret,
        )
        responses.append(response)
    return responses

build_video_message

Python
build_video_message(file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, gifplayback: bool = False, is_gif: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

This function is used to build a video message. It uploads a video file, extracts necessary information, and constructs a message with the given parameters.

PARAMETER DESCRIPTION
file

The file path or bytes of the video file to be uploaded.

TYPE: str | bytes

caption

The caption to be added to the video message, defaults to None

TYPE: Optional[str] DEFAULT: None

quoted

A message that the video message is in response to, defaults to None

TYPE: Optional[Message] DEFAULT: None

viewonce

A flag indicating if the video message can be viewed only once, defaults to False

TYPE: bool DEFAULT: False

gifplayback

Optional. Whether the video should be sent as gif. Defaults to False.

TYPE: bool DEFAULT: False

is_gif

Optional. Whether the video to be sent is a gif. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Message

A video message with the given parameters.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_video_message(
    self,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    gifplayback: bool = False,
    is_gif: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """
    This function is used to build a video message. It uploads a video file, extracts necessary information,
    and constructs a message with the given parameters.

    :param file: The file path or bytes of the video file to be uploaded.
    :type file: str | bytes
    :param caption: The caption to be added to the video message, defaults to None
    :type caption: Optional[str], optional
    :param quoted: A message that the video message is in response to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :param viewonce: A flag indicating if the video message can be viewed only once, defaults to False
    :type viewonce: bool, optional
    :param gifplayback: Optional. Whether the video should be sent as gif. Defaults to False.
    :type gifplayback: bool, optional
    :param is_gif: Optional. Whether the video to be sent is a gif. Defaults to False.
    :type is_gif: bool, optional
    :return: A video message with the given parameters.
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :rtype: Message
    """
    io = BytesIO(get_bytes_from_name_or_url(file))
    io.seek(0)
    buff = io.read()
    if is_gif:
        with FFmpeg(file) as ffmpeg:
            buff = file = ffmpeg.gif_to_mp4()
    with FFmpeg(file) as ffmpeg:
        duration = int(ffmpeg.extract_info().format.duration)
        thumbnail = ffmpeg.extract_thumbnail()
    upload = self.upload(buff)
    message = Message(
        videoMessage=VideoMessage(
            URL=upload.url,
            caption=caption,
            gifPlayback=gifplayback,
            seconds=duration,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(buff, mime=True),
            JPEGThumbnail=thumbnail,
            thumbnailDirectPath=upload.DirectPath,
            thumbnailEncSHA256=upload.FileEncSHA256,
            thumbnailSHA256=upload.FileSHA256,
            viewOnce=viewonce,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.videoMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_video

Python
send_video(to: JID, file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, gifplayback: bool = False, is_gif: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends a video to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the video.

TYPE: str | bytes

caption

Optional. The caption of the video. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the video is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Optional. Whether the video should be viewonce. Defaults to False.

TYPE: bool DEFAULT: False

gifplayback

Optional. Whether the video should be sent as gif. Defaults to False.

TYPE: bool DEFAULT: False

is_gif

Optional. Whether the video to be sent is a gif. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the video sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_video(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    gifplayback: bool = False,
    is_gif: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends a video to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the video.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the video. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the video is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param viewonce: Optional. Whether the video should be viewonce. Defaults to False.
    :type viewonce: bool, optional
    :param gifplayback: Optional. Whether the video should be sent as gif. Defaults to False.
    :type gifplayback: bool, optional
    :param is_gif: Optional. Whether the video to be sent is a gif. Defaults to False.
    :type is_gif: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the video sending process.
    :rtype: SendResponse
    """
    return self.send_message(
        to,
        self.build_video_message(
            file,
            caption,
            quoted,
            viewonce,
            gifplayback,
            is_gif,
            ghost_mentions,
            mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

build_image_message

Python
build_image_message(file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

This function builds an image message. It takes a file (either a string or bytes), an optional caption, an optional quoted message, and a boolean indicating whether the message should be viewed once. It then uploads the image, generates a thumbnail, and constructs the message with the given parameters and the information from the uploaded image.

PARAMETER DESCRIPTION
file

The image file to be uploaded and sent, either as a string URL or bytes.

TYPE: str | bytes

caption

The caption for the image message, defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

The message to be quoted in the image message, defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Whether the image message should be viewable only once, defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Message

The constructed image message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_image_message(
    self,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """
    This function builds an image message. It takes a file (either a string or bytes),
    an optional caption, an optional quoted message, and a boolean indicating whether
    the message should be viewed once. It then uploads the image, generates a thumbnail,
    and constructs the message with the given parameters and the information from the
    uploaded image.

    :param file: The image file to be uploaded and sent, either as a string URL or bytes.
    :type file: str | bytes
    :param caption: The caption for the image message, defaults to None.
    :type caption: Optional[str], optional
    :param quoted: The message to be quoted in the image message, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param viewonce: Whether the image message should be viewable only once, defaults to False.
    :type viewonce: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :return: The constructed image message.
    :rtype: Message
    """
    n_file = get_bytes_from_name_or_url(file)
    img = Image.open(BytesIO(n_file))
    img.thumbnail(AspectRatioMethod(*img.size, res=200))
    thumbnail = BytesIO()
    img_saveable = img if img.mode == "RGB" else img.convert("RGB")
    img_saveable.save(thumbnail, format="jpeg")
    upload = self.upload(n_file)
    message = Message(
        imageMessage=ImageMessage(
            URL=upload.url,
            caption=caption,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(n_file, mime=True),
            JPEGThumbnail=thumbnail.getvalue(),
            thumbnailDirectPath=upload.DirectPath,
            thumbnailEncSHA256=upload.FileEncSHA256,
            thumbnailSHA256=upload.FileSHA256,
            viewOnce=viewonce,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.imageMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_image

Python
send_image(to: JID, file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends an image to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the image.

TYPE: str | bytes

caption

Optional. The caption of the image. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the image is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Optional. Whether the image should be viewonce. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the image sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_image(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends an image to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the image.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the image. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the image is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param viewonce: Optional. Whether the image should be viewonce. Defaults to False.
    :type viewonce: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the image sending process.
    :rtype: SendResponse
    """
    return self.send_message(
        to,
        self.build_image_message(
            file,
            caption,
            quoted,
            viewonce=viewonce,
            ghost_mentions=ghost_mentions,
            mentions_are_lids=mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

send_album

Python
send_album(to: JID, files: list, caption: Optional[str] = None, quoted: Optional[Message] = None, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> List[SendResponse, List[SendResponse]]

Sends an album containing images, videos or both to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

files

A list containing either a file path (str), url (str) or binary data (bytes) representing the image/video.

TYPE: list

caption

Optional. The caption of the first media in the album. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the album is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
List[SendResponse, List[SendResponse]]

A function for handling the result of the album sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_album(
    self,
    to: JID,
    files: list,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> List[SendResponse, List[SendResponse]]:
    """Sends an album containing images, videos or both to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param files: A list containing either a file path (str), url (str) or binary data (bytes) representing the image/video.
    :type file: List[typing.Union[str | bytes]]
    :param caption: Optional. The caption of the first media in the album. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the album is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the album sending process.
    :rtype: List[SendResponse, List[SendResponse]]
    """
    image_count = video_count = 0
    medias = []
    for file in files:
        file = get_bytes_from_name_or_url(file)
        mime = magic.from_buffer(file, mime=True)
        media_type = mime.split("/")[0]
        if media_type == "image":
            image_count += 1
        elif media_type == "video":
            video_count += 1
        else:
            _log_.warning(
                f"File with mime_type: {mime} was wrongly passed to send_album_message, ignoring…"
            )
            continue
        medias.append((file, media_type))
    if not (image_count or video_count):
        raise SendMessageError("No media found to send!")
    elif len(medias) < 2:
        raise SendMessageError("No enough media to send an album")
    message = Message(
        albumMessage=AlbumMessage(
            expectedImageCount=image_count,
            expectedVideoCount=video_count,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.albumMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    response = self.send_message(to, message, add_msg_secret=add_msg_secret)
    msg_association = MessageAssociation(
        associationType=MessageAssociation.AssociationType.MEDIA_ALBUM,
        parentMessageKey=MessageKey(
            remoteJID=Jid2String(to),
            fromMe=True,
            ID=response.ID,
        ),
    )
    with ThreadPoolExecutor(max_workers=25) as executor:
        futures = [
            executor.submit(
                self.build_album_content,
                file,
                media_type,
                msg_association,
                caption=caption,
                quoted=quoted,
                ghost_mentions=ghost_mentions,
                mentions_are_lids=mentions_are_lids,
            )
            for file, media_type in medias[:1]
        ]
        futures.extend(
            [
                executor.submit(
                    self.build_album_content,
                    file,
                    media_type,
                    msg_association,
                    quoted=quoted,
                )
                for file, media_type in medias[1:]
            ]
        )

        messages = [fut.result() for fut in futures]

    with ThreadPoolExecutor(max_workers=25) as executor:
        send_futures = [
            executor.submit(
                self.send_message, to, msg, add_msg_secret=add_msg_secret
            )
            for msg in messages
        ]
        responses = [fut.result() for fut in send_futures]
    return [response, responses]

build_audio_message

Python
build_audio_message(file: str | bytes, ptt: bool = False, quoted: Optional[Message] = None) -> Message

This method builds an audio message from a given file or bytes.

PARAMETER DESCRIPTION
file

The audio file in string or bytes format to be converted into an audio message

TYPE: str | bytes

ptt

A boolean indicating if the audio message is a 'push to talk' message, defaults to False

TYPE: bool DEFAULT: False

quoted

A message that the audio message may be replying to, defaults to None

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
Message

The audio message built from the given parameters

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def build_audio_message(
    self,
    file: str | bytes,
    ptt: bool = False,
    quoted: Optional[neonize_proto.Message] = None,
) -> Message:
    """
    This method builds an audio message from a given file or bytes.

    :param file: The audio file in string or bytes format to be converted into an audio message
    :type file: str | bytes
    :param ptt: A boolean indicating if the audio message is a 'push to talk' message, defaults to False
    :type ptt: bool, optional
    :param quoted: A message that the audio message may be replying to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :return: The audio message built from the given parameters
    :rtype: Message
    """
    io = BytesIO(get_bytes_from_name_or_url(file))
    io.seek(0)
    buff = io.read()
    upload = self.upload(buff)
    with FFmpeg(io.getvalue()) as ffmpeg:
        duration = int(ffmpeg.extract_info().format.duration)
    message = Message(
        audioMessage=AudioMessage(
            URL=upload.url,
            seconds=duration,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(buff, mime=True),
            PTT=ptt,
        )
    )
    if quoted:
        message.audioMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_audio

Python
send_audio(to: JID, file: str | bytes, ptt: bool = False, quoted: Optional[Message] = None, add_msg_secret: bool = False) -> SendResponse

Sends an audio to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the audio.

TYPE: str | bytes

ptt

Optional. Whether the audio should be ptt. Defaults to False.

TYPE: bool DEFAULT: False

quoted

Optional. The message to which the audio is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the audio sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_audio(
    self,
    to: JID,
    file: str | bytes,
    ptt: bool = False,
    quoted: Optional[neonize_proto.Message] = None,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends an audio to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the audio.
    :type file: typing.Union[str | bytes]
    :param ptt: Optional. Whether the audio should be ptt. Defaults to False.
    :type ptt: bool, optional
    :param quoted: Optional. The message to which the audio is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param add_msg_secret: Optional. Whether to  generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the audio sending process.
    :rtype: SendResponse
    """

    return self.send_message(
        to,
        self.build_audio_message(file, ptt, quoted),
        add_msg_secret=add_msg_secret,
    )

send_document

Python
send_document(to: JID, file: str | bytes, caption: Optional[str] = None, title: Optional[str] = None, filename: Optional[str] = None, mimetype: Optional[str] = None, quoted: Optional[Message] = None, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends a document to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the document.

TYPE: str | bytes

caption

Optional. The caption of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

title

Optional. The title of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

filename

Optional. The filename of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the document is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the document sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_document(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    title: Optional[str] = None,
    filename: Optional[str] = None,
    mimetype: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends a document to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the document.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the document. Defaults to None.
    :type caption: Optional[str], optional
    :param title: Optional. The title of the document. Defaults to None.
    :type title: Optional[str], optional
    :param filename: Optional. The filename of the document. Defaults to None.
    :type filename: Optional[str], optional
    :param quoted: Optional. The message to which the document is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the document sending process.
    :rtype: SendResponse
    """
    return self.send_message(
        to,
        self.build_document_message(
            file,
            caption,
            title,
            filename,
            mimetype,
            quoted,
            ghost_mentions,
            mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

send_contact

Python
send_contact(to: JID, contact_name: str, contact_number: str, quoted: Optional[Message] = None) -> SendResponse

Sends a contact to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

contact_name

The name of the contact.

TYPE: str

contact_number

The number of the contact.

TYPE: str

quoted

Optional. The message to which the contact is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the contact sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_contact(
    self,
    to: JID,
    contact_name: str,
    contact_number: str,
    quoted: Optional[neonize_proto.Message] = None,
) -> SendResponse:
    """Sends a contact to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param contact_name: The name of the contact.
    :type contact_name: str
    :param contact_number: The number of the contact.
    :type contact_number: str
    :param quoted: Optional. The message to which the contact is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :return: A function for handling the result of the contact sending process.
    :rtype: SendResponse
    """
    message = Message(
        contactMessage=ContactMessage(
            displayName=contact_name,
            vcard=gen_vcard(contact_name, contact_number),
        )
    )
    if quoted:
        message.contactMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return self.send_message(to, message)

upload

Python
upload(binary: bytes, media_type: Optional[MediaType] = None) -> UploadResponse

Uploads media content.

PARAMETER DESCRIPTION
binary

The binary data to be uploaded.

TYPE: bytes

media_type

Optional. The media type of the binary data, defaults to None.

TYPE: Optional[MediaType] DEFAULT: None

RETURNS DESCRIPTION
UploadResponse

An UploadResponse containing information about the upload.

RAISES DESCRIPTION
UploadError

Raised if there is an issue with the upload.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def upload(
    self, binary: bytes, media_type: Optional[MediaType] = None
) -> UploadResponse:
    """Uploads media content.

    :param binary: The binary data to be uploaded.
    :type binary: bytes
    :param media_type: Optional. The media type of the binary data, defaults to None.
    :type media_type: Optional[MediaType], optional
    :raises UploadError: Raised if there is an issue with the upload.
    :return: An UploadResponse containing information about the upload.
    :rtype: UploadResponse
    """
    if not media_type:
        mime = MediaType.from_magic(binary)
    else:
        mime = media_type
    bytes_ptr = self.__client.Upload(self.uuid, binary, len(binary), mime.value)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    upload_model = UploadReturnFunction.FromString(protobytes)
    if upload_model.Error:
        raise UploadError(upload_model.Error)
    return upload_model.UploadResponse

download_any

Python
download_any(message: Message) -> bytes
Python
download_any(message: Message, path: str) -> NoneType
Python
download_any(message: Message, path: Optional[str] = None) -> typing.Union[None, bytes]

Downloads content from a message.

PARAMETER DESCRIPTION
message

The message containing the content to download.

TYPE: Message

path

Optional. The local path to save the downloaded content, defaults to None.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Union[None, bytes]

The downloaded content as bytes, or None if the content is not available.

RAISES DESCRIPTION
DownloadException

Raised if there is an issue with the download.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def download_any(
    self, message: Message, path: Optional[str] = None
) -> typing.Union[None, bytes]:
    """Downloads content from a message.

    :param message: The message containing the content to download.
    :type message: Message
    :param path: Optional. The local path to save the downloaded content, defaults to None.
    :type path: Optional[str], optional
    :raises DownloadException: Raised if there is an issue with the download.
    :return: The downloaded content as bytes, or None if the content is not available.
    :rtype: Union[None, bytes]
    """
    msg_protobuf = message.SerializeToString()
    bytes_ptr = self.__client.DownloadAny(
        self.uuid, msg_protobuf, len(msg_protobuf)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    media = DownloadReturnFunction.FromString(protobytes)
    if media.Error:
        raise DownloadError(media.Error)
    if path:
        with open(path, "wb") as file:
            file.write(media.Binary)
    else:
        return media.Binary
    return None

download_media_with_path

Python
download_media_with_path(direct_path: str, enc_file_hash: bytes, file_hash: bytes, media_key: bytes, file_length: int, media_type: MediaType, mms_type: MediaTypeToMMS) -> bytes

Downloads media with the given parameters and path. The media is downloaded from the path specified.

PARAMETER DESCRIPTION
direct_path

The direct path to the media to be downloaded.

TYPE: str

enc_file_hash

The encrypted hash of the file.

TYPE: bytes

file_hash

The hash of the file.

TYPE: bytes

media_key

The key of the media to be downloaded.

TYPE: bytes

file_length

The length of the file to be downloaded.

TYPE: int

media_type

The type of the media to be downloaded.

TYPE: MediaType

mms_type

The type of the MMS to be downloaded.

TYPE: MediaTypeToMMS

RETURNS DESCRIPTION
bytes

The downloaded media in bytes.

RAISES DESCRIPTION
DownloadError

If there is an error in the download process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def download_media_with_path(
    self,
    direct_path: str,
    enc_file_hash: bytes,
    file_hash: bytes,
    media_key: bytes,
    file_length: int,
    media_type: MediaType,
    mms_type: MediaTypeToMMS,
) -> bytes:
    """
    Downloads media with the given parameters and path. The media is downloaded from the path specified.

    :param direct_path: The direct path to the media to be downloaded.
    :type direct_path: str
    :param enc_file_hash: The encrypted hash of the file.
    :type enc_file_hash: bytes
    :param file_hash: The hash of the file.
    :type file_hash: bytes
    :param media_key: The key of the media to be downloaded.
    :type media_key: bytes
    :param file_length: The length of the file to be downloaded.
    :type file_length: int
    :param media_type: The type of the media to be downloaded.
    :type media_type: MediaType
    :param mms_type: The type of the MMS to be downloaded.
    :type mms_type: str
    :raises DownloadError: If there is an error in the download process.
    :return: The downloaded media in bytes.
    :rtype: bytes
    """
    bytes_ptr = self.__client.DownloadMediaWithPath(
        self.uuid,
        direct_path.encode(),
        enc_file_hash,
        len(enc_file_hash),
        file_hash,
        len(file_hash),
        media_key,
        len(media_key),
        file_length,
        media_type.value,
        mms_type.value.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.DownloadReturnFunction.FromString(protobytes)
    if model.Error:
        raise DownloadError(model.Error)
    return model.Binary

generate_message_id

Python
generate_message_id() -> str

Generates a unique identifier for a message.

RETURNS DESCRIPTION
str

A string representing the unique identifier for the message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def generate_message_id(self) -> str:
    """Generates a unique identifier for a message.

    :return: A string representing the unique identifier for the message.
    :rtype: str
    """
    return self.__client.GenerateMessageID(self.uuid).decode()

send_chat_presence

Python
send_chat_presence(jid: JID, state: ChatPresence, media: ChatPresenceMedia) -> str

Sends chat presence information.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the chat.

TYPE: JID

state

The chat presence state.

TYPE: ChatPresence

media

The chat presence media information.

TYPE: ChatPresenceMedia

RETURNS DESCRIPTION
str

A string indicating the result or status of the presence information sending.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_chat_presence(
    self, jid: JID, state: ChatPresence, media: ChatPresenceMedia
) -> str:
    """Sends chat presence information.

    :param jid: The JID (Jabber Identifier) of the chat.
    :type jid: JID
    :param state: The chat presence state.
    :type state: ChatPresence
    :param media: The chat presence media information.
    :type media: ChatPresenceMedia
    :return: A string indicating the result or status of the presence information sending.
    :rtype: str
    """
    jidbyte = jid.SerializeToString()
    return self.__client.SendChatPresence(
        self.uuid, jidbyte, len(jidbyte), state.value, media.value
    ).decode()

is_on_whatsapp

Python
is_on_whatsapp(*numbers: str) -> Sequence[IsOnWhatsAppResponse]

This function checks if the provided phone numbers are registered with WhatsApp.

PARAMETER DESCRIPTION
numbers

A series of phone numbers to be checked.

TYPE: str DEFAULT: ()

RETURNS DESCRIPTION
Sequence[IsOnWhatsAppResponse]

A list of responses, each indicating whether the corresponding number is registered with WhatsApp.

RAISES DESCRIPTION
IsOnWhatsAppError

If an error occurs while verifying the phone numbers.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def is_on_whatsapp(self, *numbers: str) -> Sequence[IsOnWhatsAppResponse]:
    """
    This function checks if the provided phone numbers are registered with WhatsApp.

    :param numbers: A series of phone numbers to be checked.
    :type numbers: str
    :raises IsOnWhatsAppError: If an error occurs while verifying the phone numbers.
    :return: A list of responses, each indicating whether the corresponding number is registered with WhatsApp.
    :rtype: Sequence[IsOnWhatsAppResponse]
    """
    if numbers:
        numbers_buf = " ".join(numbers).encode()
        bytes_ptr = self.__client.IsOnWhatsApp(
            self.uuid, numbers_buf, len(numbers_buf)
        )
        protobytes = bytes_ptr.contents.get_bytes()
        free_bytes(bytes_ptr)
        model = IsOnWhatsAppReturnFunction.FromString(protobytes)
        if model.Error:
            raise IsOnWhatsAppError(model.Error)
        return model.IsOnWhatsAppResponse
    return []

get_user_info

Python
get_user_info(*jid: JID) -> RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]

This function retrieves user information given a set of JID. It serializes the JID into a string, gets the user information from the client, deserializes the returned information, checks for any errors, and finally returns the user information.

PARAMETER DESCRIPTION
jid

JID of the users to retrieve information from

TYPE: JID DEFAULT: ()

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]

The user information for each JID

RAISES DESCRIPTION
GetUserInfoError

If there is an error in the model returned by the client

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_user_info(
    self, *jid: JID
) -> RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]:
    """
    This function retrieves user information given a set of JID. It serializes the JID into a string,
    gets the user information from the client, deserializes the returned information, checks for any errors,
    and finally returns the user information.

    :param jid: JID of the users to retrieve information from
    :type jid: JID
    :raises GetUserInfoError: If there is an error in the model returned by the client
    :return: The user information for each JID
    :rtype: RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]
    """
    jidbuf = JIDArray(JIDS=jid).SerializeToString()
    bytes_ptr = self.__client.GetUserInfo(self.uuid, jidbuf, len(jidbuf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetUserInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetUserInfoError(model.Error)
    return model.UsersInfo

get_group_info

Python
get_group_info(jid: JID) -> GroupInfo

Retrieves information about a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

RETURNS DESCRIPTION
GroupInfo

Information about the specified group.

RAISES DESCRIPTION
GetGroupInfoError

Raised if there is an issue retrieving group information.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_group_info(self, jid: JID) -> GroupInfo:
    """Retrieves information about a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :raises GetGroupInfoError: Raised if there is an issue retrieving group information.
    :return: Information about the specified group.
    :rtype: GroupInfo
    """
    jidbuf = jid.SerializeToString()
    bytes_ptr = self.__client.GetGroupInfo(
        self.uuid,
        jidbuf,
        len(jidbuf),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo
Python
get_group_info_from_link(code: str) -> GroupInfo

Retrieves group information from a given link.

PARAMETER DESCRIPTION
code

The link code.

TYPE: str

RETURNS DESCRIPTION
GroupInfo

An object containing the group information.

RAISES DESCRIPTION
GetGroupInfoError

If there is an error retrieving the group information.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_group_info_from_link(self, code: str) -> GroupInfo:
    """Retrieves group information from a given link.

    :param code: The link code.
    :type code: str
    :return: An object containing the group information.
    :rtype: GroupInfo
    :raises GetGroupInfoError: If there is an error retrieving the group information.
    """
    bytes_ptr = self.__client.GetGroupInfoFromLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo

get_group_info_from_invite

Python
get_group_info_from_invite(jid: JID, inviter: JID, code: str, expiration: int) -> GroupInfo

Retrieves group information from an invite.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group.

TYPE: JID

inviter

The JID of the user who sent the invite.

TYPE: JID

code

The invite code.

TYPE: str

expiration

The expiration time of the invite.

TYPE: int

RETURNS DESCRIPTION
GroupInfo

The group information.

RAISES DESCRIPTION
GetGroupInfoError

If there is an error retrieving the group information.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_group_info_from_invite(
    self, jid: JID, inviter: JID, code: str, expiration: int
) -> GroupInfo:
    """Retrieves group information from an invite.

    :param jid: The JID (Jabber ID) of the group.
    :type jid: JID
    :param inviter: The JID of the user who sent the invite.
    :type inviter: JID
    :param code: The invite code.
    :type code: str
    :param expiration: The expiration time of the invite.
    :type expiration: int

    :return: The group information.
    :rtype: GroupInfo

    :raises GetGroupInfoError: If there is an error retrieving the group information.
    """
    jidbyte = jid.SerializeToString()
    inviterbyte = inviter.SerializeToString()
    bytes_ptr = self.__client.GetGroupInfoFromInvite(
        self.uuid,
        jidbyte,
        len(jidbyte),
        inviterbyte,
        len(inviterbyte),
        code.encode(),
        expiration,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo

set_group_name

Python
set_group_name(jid: JID, name: str) -> str

Sets the name of a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

name

The new name to be set for the group.

TYPE: str

RETURNS DESCRIPTION
str

A string indicating the result or an error status. Empty string if successful.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_group_name(self, jid: JID, name: str) -> str:
    """Sets the name of a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param name: The new name to be set for the group.
    :type name: str
    :return: A string indicating the result or an error status. Empty string if successful.
    :rtype: str
    """
    jidbuf = jid.SerializeToString()
    return self.__client.SetGroupName(
        self.uuid, jidbuf, len(jidbuf), ctypes.create_string_buffer(name.encode())
    ).decode()

set_group_photo

Python
set_group_photo(jid: JID, file_or_bytes: Union[str, bytes]) -> str

Sets the photo of a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

file_or_bytes

Either a file path (str) or binary data (bytes) representing the group photo.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
str

A string indicating the result or an error status.

RAISES DESCRIPTION
SetGroupPhotoError

Raised if there is an issue setting the group photo.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_group_photo(self, jid: JID, file_or_bytes: typing.Union[str, bytes]) -> str:
    """Sets the photo of a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param file_or_bytes: Either a file path (str) or binary data (bytes) representing the group photo.
    :type file_or_bytes: typing.Union[str, bytes]
    :raises SetGroupPhotoError: Raised if there is an issue setting the group photo.
    :return: A string indicating the result or an error status.
    :rtype: str
    """
    data = get_bytes_from_name_or_url(file_or_bytes)
    jid_buf = jid.SerializeToString()
    bytes_ptr = self.__client.SetGroupPhoto(
        self.uuid, jid_buf, len(jid_buf), data, len(data)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SetGroupPhotoReturnFunction.FromString(protobytes)
    if model.Error:
        raise SetGroupPhotoError(model.Error)
    return model.PictureID

set_profile_photo

Python
set_profile_photo(file_or_bytes: Union[str, bytes]) -> str

Sets profile photo.

PARAMETER DESCRIPTION
file_or_bytes

Either a file path (str) or binary data (bytes) representing the group photo.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
str

A string indicating the result or an error status.

RAISES DESCRIPTION
SetGroupPhotoError

Raised if there is an issue setting the profile photo.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_profile_photo(self, file_or_bytes: typing.Union[str, bytes]) -> str:
    """Sets profile photo.

    :param file_or_bytes: Either a file path (str) or binary data (bytes) representing the group photo.
    :type file_or_bytes: typing.Union[str, bytes]
    :raises SetGroupPhotoError: Raised if there is an issue setting the profile photo.
    :return: A string indicating the result or an error status.
    :rtype: str
    """
    data = get_bytes_from_name_or_url(file_or_bytes)
    bytes_ptr = self.__client.SetProfilePhoto(self.uuid, data, len(data))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SetGroupPhotoReturnFunction.FromString(protobytes)
    if model.Error:
        raise SetGroupPhotoError(model.Error)
    return model.PictureID

get_lid_from_pn

Python
get_lid_from_pn(jid: JID) -> JID

Retrieves the matching lid from the supplied jid.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) (pn) of the target user.

TYPE: JID

RETURNS DESCRIPTION
JID

The lid (hidden user) matching the supplied jid.

RAISES DESCRIPTION
GetJIDFromStoreError

Raised if there is an issue getting the lid from the given jid.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_lid_from_pn(self, jid: JID) -> JID:
    """Retrieves the matching lid from the supplied jid.

    :param jid: The JID (Jabber Identifier) (pn) of the target user.
    :type jid: JID
    :raises GetJIDFromStoreError: Raised if there is an issue getting the lid from the given jid.
    :return: The lid (hidden user) matching the supplied jid.
    :rtype: JID
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = self.__client.GetLIDFromPN(self.uuid, jid_buf, len(jid_buf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetJIDFromStoreReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJIDFromStoreError(model.Error)
    return model.Jid

get_pn_from_lid

Python
get_pn_from_lid(jid: JID) -> JID

Retrieves the matching jid from the supplied lid.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) (lid) of the target user.

TYPE: JID

RETURNS DESCRIPTION
JID

The jid (phone number) matching the supplied lid.

RAISES DESCRIPTION
GetJIDFromStoreError

Raised if there is an issue getting the jid from the given lid.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_pn_from_lid(self, jid: JID) -> JID:
    """Retrieves the matching jid from the supplied lid.

    :param jid: The JID (Jabber Identifier) (lid) of the target user.
    :type jid: JID
    :raises GetJIDFromStoreError: Raised if there is an issue getting the jid from the given lid.
    :return: The jid (phone number) matching the supplied lid.
    :rtype: JID
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = self.__client.GetPNFromLID(self.uuid, jid_buf, len(jid_buf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetJIDFromStoreReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJIDFromStoreError(model.Error)
    return model.Jid

pin_message

Python
pin_message(chat_jid: JID, sender_jid: JID, message_id: str, seconds: int)

Currently Non-functional

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def pin_message(
    self, chat_jid: JID, sender_jid: JID, message_id: str, seconds: int
):
    """
    Currently Non-functional
    """
    chat_buf = chat_jid.SerializeToString()
    sender_buf = sender_jid.SerializeToString()
    bytes_ptr = self.__client.PinMessage(
        self.uuid,
        chat_buf,
        len(chat_buf),
        sender_buf,
        len(sender_buf),
        message_id.encode(),
        seconds,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SendMessageReturnFunction.FromString(protobytes)
    if model.Error:
        raise SendMessageError(model.Error)
    return model.SendResponse

leave_group

Python
leave_group(jid: JID) -> str

Leaves a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the target group.

TYPE: JID

RETURNS DESCRIPTION
str

A string indicating the result or an error status. Empty string if successful.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def leave_group(self, jid: JID) -> str:
    """Leaves a group.

    :param jid: The JID (Jabber Identifier) of the target group.
    :type jid: JID
    :return: A string indicating the result or an error status. Empty string if successful.
    :rtype: str
    """
    jid_buf = jid.SerializeToString()
    return self.__client.LeaveGroup(self.uuid, jid_buf, len(jid_buf)).decode()
Python
get_group_invite_link(jid: JID, revoke: bool = False) -> str

Gets or revokes the invite link for a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

revoke

Optional. If True, revokes the existing invite link; if False, gets the invite link. Defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

The group invite link or an error status.

RAISES DESCRIPTION
GetGroupInviteLinkError

Raised if there is an issue getting or revoking the invite link.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_group_invite_link(self, jid: JID, revoke: bool = False) -> str:
    """Gets or revokes the invite link for a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param revoke: Optional. If True, revokes the existing invite link; if False, gets the invite link. Defaults to False.
    :type revoke: bool, optional
    :raises GetGroupInviteLinkError: Raised if there is an issue getting or revoking the invite link.
    :return: The group invite link or an error status.
    :rtype: str
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = self.__client.GetGroupInviteLink(
        self.uuid, jid_buf, len(jid_buf), revoke
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInviteLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInviteLinkError(model.Error)
    return model.InviteLink
Python
join_group_with_link(code: str) -> JID

Join a group using an invite link.

PARAMETER DESCRIPTION
code

The invite code or link for joining the group.

TYPE: str

RETURNS DESCRIPTION
JID

The JID (Jabber Identifier) of the joined group.

RAISES DESCRIPTION
InviteLinkError

Raised if the group membership is pending approval or if the link is invalid.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def join_group_with_link(self, code: str) -> JID:
    """Join a group using an invite link.

    :param code: The invite code or link for joining the group.
    :type code: str
    :raises InviteLinkError: Raised if the group membership is pending approval or if the link is invalid.
    :return: The JID (Jabber Identifier) of the joined group.
    :rtype: JID
    """
    bytes_ptr = self.__client.JoinGroupWithLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = JoinGroupWithLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise InviteLinkError(model.Error)
    return model.Jid

join_group_with_invite

Python
join_group_with_invite(jid: JID, inviter: JID, code: str, expiration: int)

This function allows a user to join a group in a chat application using an invite. It uses the JID (Jabber ID) of the group, the JID of the inviter, an invitation code, and an expiration time for the code.

PARAMETER DESCRIPTION
jid

The JID of the group to join.

TYPE: JID

inviter

The JID of the person who sent the invite.

TYPE: JID

code

The invitation code.

TYPE: str

expiration

The expiration time of the invitation code.

TYPE: int

RAISES DESCRIPTION
JoinGroupWithInviteError

If there is an error in joining the group, such as an invalid code or expired invitation.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def join_group_with_invite(
    self, jid: JID, inviter: JID, code: str, expiration: int
):
    """
    This function allows a user to join a group in a chat application using an invite.
    It uses the JID (Jabber ID) of the group, the JID of the inviter, an invitation code, and an expiration time for the code.

    :param jid: The JID of the group to join.
    :type jid: JID
    :param inviter: The JID of the person who sent the invite.
    :type inviter: JID
    :param code: The invitation code.
    :type code: str
    :param expiration: The expiration time of the invitation code.
    :type expiration: int
    :raises JoinGroupWithInviteError: If there is an error in joining the group, such as an invalid code or expired invitation.
    """
    jidbytes = jid.SerializeToString()
    inviterbytes = inviter.SerializeToString()
    err = self.__client.JoinGroupWithInvite(
        self.uuid,
        jidbytes,
        len(jidbytes),
        inviterbytes,
        len(inviterbytes),
        code.encode(),
        expiration,
    ).decode()
    if err:
        raise JoinGroupWithInviteError(err)
Python
link_group(parent: JID, child: JID)

Links a child group to a parent group.

PARAMETER DESCRIPTION
parent

The JID of the parent group

TYPE: JID

child

The JID of the child group

TYPE: JID

RAISES DESCRIPTION
LinkGroupError

If there is an error while linking the groups

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def link_group(self, parent: JID, child: JID):
    """
    Links a child group to a parent group.

    :param parent: The JID of the parent group
    :type parent: JID
    :param child: The JID of the child group
    :type child: JID
    :raises LinkGroupError: If there is an error while linking the groups
    """
    parent_bytes = parent.SerializeToString()
    child_bytes = child.SerializeToString()
    err = self.__client.LinkGroup(
        self.uuid, parent_bytes, len(parent_bytes), child_bytes, len(child_bytes)
    ).decode()
    if err:
        raise LinkGroupError(err)

mark_read

Python
mark_read(*message_ids: str, chat: JID, sender: JID, receipt: ReceiptType, timestamp: Optional[int] = None)

Marks the specified messages as read.

PARAMETER DESCRIPTION
message_ids

Identifiers of the messages to mark as read.

TYPE: str DEFAULT: ()

chat

The JID of the chat.

TYPE: JID

sender

The JID of the sender.

TYPE: JID

receipt

The type of receipt indicating the message status.

TYPE: ReceiptType

timestamp

The timestamp of the read action, defaults to None.

TYPE: Optional[int] DEFAULT: None

RAISES DESCRIPTION
MarkReadError

If there is an error marking messages as read.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def mark_read(
    self,
    *message_ids: str,
    chat: JID,
    sender: JID,
    receipt: ReceiptType,
    timestamp: Optional[int] = None,
):
    """Marks the specified messages as read.

    :param message_ids: Identifiers of the messages to mark as read.
    :type message_ids: str
    :param chat: The JID of the chat.
    :type chat: JID
    :param sender: The JID of the sender.
    :type sender: JID
    :param receipt: The type of receipt indicating the message status.
    :type receipt: ReceiptType
    :param timestamp: The timestamp of the read action, defaults to None.
    :type timestamp: Optional[int], optional
    :raises MarkReadError: If there is an error marking messages as read.
    """
    chat_proto = chat.SerializeToString()
    sender_proto = sender.SerializeToString()
    timestamp_args = int(time.time()) if timestamp is None else timestamp
    err = self.__client.MarkRead(
        self.uuid,
        " ".join(message_ids).encode(),
        timestamp_args,
        chat_proto,
        len(chat_proto),
        sender_proto,
        len(sender_proto),
        receipt.value,
    )
    if err:
        raise MarkReadError(err.decode())

newsletter_mark_viewed

Python
newsletter_mark_viewed(jid: JID, message_server_ids: List[MessageServerID])

Marks the specified newsletters as viewed by the user with the given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the user who has viewed the newsletters.

TYPE: JID

message_server_ids

List of server IDs of the newsletters that have been viewed.

TYPE: List[MessageServerID]

RAISES DESCRIPTION
NewsletterMarkViewedError

If an error occurs while marking the newsletters as viewed.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def newsletter_mark_viewed(
    self, jid: JID, message_server_ids: List[MessageServerID]
):
    """
    Marks the specified newsletters as viewed by the user with the given JID.

    :param jid: The JID (Jabber ID) of the user who has viewed the newsletters.
    :type jid: JID
    :param message_server_ids: List of server IDs of the newsletters that have been viewed.
    :type message_server_ids: List[MessageServerID]
    :raises NewsletterMarkViewedError: If an error occurs while marking the newsletters as viewed.
    """
    servers = struct.pack(f"{len(message_server_ids)}b", *message_server_ids)
    jid_proto = jid.SerializeToString()
    err = self.__client.NewsletterMarkViewed(
        self.uuid, jid_proto, len(jid_proto), servers, len(servers)
    )
    if err:
        raise NewsletterMarkViewedError(err)

newsletter_send_reaction

Python
newsletter_send_reaction(jid: JID, message_server_id: MessageServerID, reaction: str, message_id: str)

Sends a reaction to a newsletter.

PARAMETER DESCRIPTION
jid

The unique identifier for the recipient of the newsletter.

TYPE: JID

message_server_id

The unique identifier for the server where the message is stored.

TYPE: MessageServerID

reaction

The reaction to be sent.

TYPE: str

message_id

The unique identifier for the message to which the reaction is being sent.

TYPE: str

RAISES DESCRIPTION
NewsletterSendReactionError

If an error occurs while sending the reaction.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def newsletter_send_reaction(
    self,
    jid: JID,
    message_server_id: MessageServerID,
    reaction: str,
    message_id: str,
):
    """
    Sends a reaction to a newsletter.

    :param jid: The unique identifier for the recipient of the newsletter.
    :type jid: JID
    :param message_server_id: The unique identifier for the server where the message is stored.
    :type message_server_id: MessageServerID
    :param reaction: The reaction to be sent.
    :type reaction: str
    :param message_id: The unique identifier for the message to which the reaction is being sent.
    :type message_id: str
    :raises NewsletterSendReactionError: If an error occurs while sending the reaction.
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.NewsletterSendReaction(
        self.uuid,
        jid_proto,
        len(jid_proto),
        message_server_id,
        reaction.encode(),
        message_id.encode(),
    )
    if err:
        raise NewsletterSendReactionError(err)
    return

newsletter_subscribe_live_updates

Python
newsletter_subscribe_live_updates(jid: JID) -> int

Subscribes a user to live updates of a newsletter.

PARAMETER DESCRIPTION
jid

The unique identifier of the user subscribing to the newsletter.

TYPE: JID

RETURNS DESCRIPTION
int

The duration for which the subscription is valid.

RAISES DESCRIPTION
NewsletterSubscribeLiveUpdatesError

If there is an error during the subscription process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def newsletter_subscribe_live_updates(self, jid: JID) -> int:
    """Subscribes a user to live updates of a newsletter.

    :param jid: The unique identifier of the user subscribing to the newsletter.
    :type jid: JID
    :raises NewsletterSubscribeLiveUpdatesError: If there is an error during the subscription process.
    :return: The duration for which the subscription is valid.
    :rtype: int
    """
    jid_proto = jid.SerializeToString()
    bytes_ptr = self.__client.NewsletterSubscribeLiveUpdates(
        self.uuid, jid_proto, len(jid_proto)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.NewsletterSubscribeLiveUpdatesReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise NewsletterSubscribeLiveUpdatesError(model.Error)
    return model.Duration

newsletter_toggle_mute

Python
newsletter_toggle_mute(jid: JID, mute: bool)

Toggle the mute status of a given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the user.

TYPE: JID

mute

The desired mute status. If True, the user will be muted. If False, the user will be unmuted.

TYPE: bool

RAISES DESCRIPTION
NewsletterToggleMuteError

If there is an error while toggling the mute status.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def newsletter_toggle_mute(self, jid: JID, mute: bool):
    """Toggle the mute status of a given JID.

    :param jid: The JID (Jabber Identifier) of the user.
    :type jid: JID
    :param mute: The desired mute status. If True, the user will be muted. If False, the user will be unmuted.
    :type mute: bool
    :raises NewsletterToggleMuteError: If there is an error while toggling the mute status.
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.NewsletterToggleMute(
        self.uuid, jid_proto, len(jid_proto), mute
    ).decode()
    if err:
        raise NewsletterToggleMuteError(err)
Python
resolve_business_message_link(code: str) -> neonize_proto.BusinessMessageLinkTarget

Resolves the target of a business message link.

PARAMETER DESCRIPTION
code

The code of the business message link to be resolved.

TYPE: str

RETURNS DESCRIPTION
neonize_proto.BusinessMessageLinkTarget

The target of the business message link.

RAISES DESCRIPTION
ResolveContactQRLinkError

If an error occurs while resolving the link.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def resolve_business_message_link(
    self, code: str
) -> neonize_proto.BusinessMessageLinkTarget:
    """Resolves the target of a business message link.

    :param code: The code of the business message link to be resolved.
    :type code: str
    :raises ResolveContactQRLinkError: If an error occurs while resolving the link.
    :return: The target of the business message link.
    :rtype: neonize_proto.BusinessMessageLinkTarget
    """
    bytes_ptr = self.__client.ResolveBusinessMessageLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.ResolveBusinessMessageLinkReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise ResolveContactQRLinkError(model.Error)
    return model.MessageLinkTarget
Python
resolve_contact_qr_link(code: str) -> neonize_proto.ContactQRLinkTarget

Resolves a QR link for a specific contact.

PARAMETER DESCRIPTION
code

The QR code to be resolved.

TYPE: str

RETURNS DESCRIPTION
neonize_proto.ContactQRLinkTarget

The target contact of the QR link.

RAISES DESCRIPTION
ResolveContactQRLinkError

If an error occurs while resolving the QR link.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def resolve_contact_qr_link(self, code: str) -> neonize_proto.ContactQRLinkTarget:
    """Resolves a QR link for a specific contact.

    :param code: The QR code to be resolved.
    :type code: str
    :raises ResolveContactQRLinkError: If an error occurs while resolving the QR link.
    :return: The target contact of the QR link.
    :rtype: neonize_proto.ContactQRLinkTarget
    """
    bytes_ptr = self.__client.ResolveContactQRLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.ResolveContactQRLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise ResolveContactQRLinkError(model.Error)
    return model.ContactQrLink

send_app_state

Python
send_app_state(patch_info: PatchInfo)

This function serializes the application state and sends it to the client. If there's an error during this process, it raises a SendAppStateError exception.

PARAMETER DESCRIPTION
patch_info

Contains the information about the application state that needs to be patched.

TYPE: PatchInfo

RAISES DESCRIPTION
SendAppStateError

If there's an error while sending the application state, this exception is raised.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def send_app_state(self, patch_info: neonize_proto.PatchInfo):
    """
    This function serializes the application state and sends it to the client. If there's an error during this process,
    it raises a SendAppStateError exception.

    :param patch_info: Contains the information about the application state that needs to be patched.
    :type patch_info: neonize_proto.PatchInfo
    :raises SendAppStateError: If there's an error while sending the application state, this exception is raised.
    """
    patch = patch_info.SerializeToString()
    err = self.__client.SendAppState(self.uuid, patch, len(patch)).decode()
    if err:
        raise SendAppStateError(err)

set_default_disappearing_timer

Python
set_default_disappearing_timer(timer: Union[timedelta, int])

Sets a default disappearing timer for messages. The timer can be specified as a timedelta or an integer. If a timedelta is provided, it is converted to nanoseconds. If an integer is provided, it is used directly as the timer.

PARAMETER DESCRIPTION
timer

The duration for messages to exist before disappearing. Can be a timedelta or an integer.

TYPE: Union[timedelta, int]

RAISES DESCRIPTION
SetDefaultDisappearingTimerError

If an error occurs while setting the disappearing timer.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_default_disappearing_timer(self, timer: typing.Union[timedelta, int]):
    """
    Sets a default disappearing timer for messages. The timer can be specified as a timedelta or an integer.
    If a timedelta is provided, it is converted to nanoseconds. If an integer is provided, it is used directly as the timer.

    :param timer: The duration for messages to exist before disappearing. Can be a timedelta or an integer.
    :type timer: typing.Union[timedelta, int]
    :raises SetDefaultDisappearingTimerError: If an error occurs while setting the disappearing timer.
    """
    timestamp = 0
    if isinstance(timer, timedelta):
        timestamp = int(timer.total_seconds() * 1000**3)
    else:
        timestamp = timer
    err = self.__client.SetDefaultDisappearingTimer(self.uuid, timestamp).decode()
    if err:
        raise SetDefaultDisappearingTimerError(err)

set_disappearing_timer

Python
set_disappearing_timer(jid: JID, timer: Union[timedelta, int], setting_ts: Optional[timedelta] = None)

Set a disappearing timer for a specific JID. The timer can be set as either a timedelta object or an integer. If a timedelta object is provided, it's converted into nanoseconds. If an integer is provided, it's interpreted as nanoseconds.

PARAMETER DESCRIPTION
jid

The JID for which the disappearing timer is to be set

TYPE: JID

timer

The duration for the disappearing timer. Can be a timedelta object or an integer representing nanoseconds.

TYPE: Union[timedelta, int]

RAISES DESCRIPTION
SetDisappearingTimerError

If there is an error in setting the disappearing timer

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_disappearing_timer(
    self,
    jid: JID,
    timer: typing.Union[timedelta, int],
    setting_ts: Optional[timedelta] = None,
):
    """
    Set a disappearing timer for a specific JID. The timer can be set as either a timedelta object or an integer.
    If a timedelta object is provided, it's converted into nanoseconds. If an integer is provided, it's interpreted as nanoseconds.

    :param jid: The JID for which the disappearing timer is to be set
    :type jid: JID
    :param timer: The duration for the disappearing timer. Can be a timedelta object or an integer representing nanoseconds.
    :type timer: typing.Union[timedelta, int]
    :raises SetDisappearingTimerError: If there is an error in setting the disappearing timer
    """
    timestamp = 0
    jid_proto = jid.SerializeToString()
    if isinstance(timer, timedelta):
        timestamp = int(timer.total_seconds() * 1000)
    else:
        timestamp = timer
    setting_ts_ms = 0
    if setting_ts:
        setting_ts_ms = int(time.time() + setting_ts.total_seconds() * 1000)
    err = self.__client.SetDisappearingTimer(
        self.uuid, jid_proto, len(jid_proto), timestamp, setting_ts_ms
    ).decode()
    if err:
        raise SetDisappearingTimerError(err)

set_force_activate_delivery_receipts

Python
set_force_activate_delivery_receipts(active: bool)

This method is used to forcibly activate or deactivate the delivery receipts for a client.

PARAMETER DESCRIPTION
active

This parameter determines whether the delivery receipts should be forcibly activated or deactivated. If it's True, the delivery receipts will be forcibly activated, otherwise, they will be deactivated.

TYPE: bool

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_force_activate_delivery_receipts(self, active: bool):
    """
    This method is used to forcibly activate or deactivate the delivery receipts for a client.

    :param active: This parameter determines whether the delivery receipts should be forcibly activated or deactivated. If it's True, the delivery receipts will be forcibly activated, otherwise, they will be deactivated.
    :type active: bool
    """
    self.__client.SetForceActiveDeliveryReceipts(self.uuid, active)

set_group_announce

Python
set_group_announce(jid: JID, announce: bool)

Sets the announcement status of a group.

PARAMETER DESCRIPTION
jid

The unique identifier of the group

TYPE: JID

announce

The announcement status to be set. If True, announcements are enabled. If False, they are disabled.

TYPE: bool

RAISES DESCRIPTION
SetGroupAnnounceError

If there is an error while setting the announcement status

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_group_announce(self, jid: JID, announce: bool):
    """
    Sets the announcement status of a group.

    :param jid: The unique identifier of the group
    :type jid: JID
    :param announce: The announcement status to be set. If True, announcements are enabled. If False, they are disabled.
    :type announce: bool
    :raises SetGroupAnnounceError: If there is an error while setting the announcement status
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.SetGroupAnnounce(
        self.uuid, jid_proto, len(jid_proto), announce
    ).decode()
    if err:
        raise SetGroupAnnounceError(err)

set_group_locked

Python
set_group_locked(jid: JID, locked: bool)

Sets the locked status of a group identified by the given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group to be locked/unlocked.

TYPE: JID

locked

The new locked status of the group. True to lock the group, False to unlock.

TYPE: bool

RAISES DESCRIPTION
SetGroupLockedError

If the operation fails, an error with the reason for the failure is raised.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_group_locked(self, jid: JID, locked: bool):
    """
    Sets the locked status of a group identified by the given JID.

    :param jid: The JID (Jabber ID) of the group to be locked/unlocked.
    :type jid: JID
    :param locked: The new locked status of the group. True to lock the group, False to unlock.
    :type locked: bool
    :raises SetGroupLockedError: If the operation fails, an error with the reason for the failure is raised.
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.SetGroupLocked(
        self.uuid, jid_proto, len(jid_proto), locked
    ).decode()
    if err:
        raise SetGroupLockedError(err)

set_group_topic

Python
set_group_topic(jid: JID, previous_id: str, new_id: str, topic: str)

Set the topic of a group in a chat application.

PARAMETER DESCRIPTION
jid

The unique identifier of the group

TYPE: JID

previous_id

The previous identifier of the topic

TYPE: str

new_id

The new identifier for the topic

TYPE: str

topic

The new topic to be set

TYPE: str

RAISES DESCRIPTION
SetGroupTopicError

If there is an error setting the group topic

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_group_topic(self, jid: JID, previous_id: str, new_id: str, topic: str):
    """
    Set the topic of a group in a chat application.

    :param jid: The unique identifier of the group
    :type jid: JID
    :param previous_id: The previous identifier of the topic
    :type previous_id: str
    :param new_id: The new identifier for the topic
    :type new_id: str
    :param topic: The new topic to be set
    :type topic: str
    :raises SetGroupTopicError: If there is an error setting the group topic
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.SetGroupTopic(
        self.uuid,
        jid_proto,
        len(jid_proto),
        previous_id.encode(),
        new_id.encode(),
        topic.encode(),
    ).decode()
    if err:
        raise SetGroupTopicError(err)

set_privacy_setting

Python
set_privacy_setting(name: PrivacySettingType, value: PrivacySetting)

This method is used to set the privacy settings of a user.

PARAMETER DESCRIPTION
name

The name of the privacy setting to be changed.

TYPE: PrivacySettingType

value

The new value for the privacy setting.

TYPE: PrivacySetting

RAISES DESCRIPTION
SetPrivacySettingError

If there is an error while setting the privacy setting.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_privacy_setting(self, name: PrivacySettingType, value: PrivacySetting):
    """
    This method is used to set the privacy settings of a user.

    :param name: The name of the privacy setting to be changed.
    :type name: PrivacySettingType
    :param value: The new value for the privacy setting.
    :type value: PrivacySetting
    :raises SetPrivacySettingError: If there is an error while setting the privacy setting.
    """
    err = self.__client.SetPrivacySetting(
        self.uuid, name.value.encode(), value.value.encode()
    ).decode()
    if err:
        raise SetPrivacySettingError(err)

set_passive

Python
set_passive(passive: bool)

Sets the passive mode of the client.

PARAMETER DESCRIPTION
passive

If True, sets the client to passive mode. If False, sets the client to active mode.

TYPE: bool

RAISES DESCRIPTION
SetPassiveError

If an error occurs while setting the client to passive mode.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_passive(self, passive: bool):
    """
    Sets the passive mode of the client.

    :param passive: If True, sets the client to passive mode. If False, sets the client to active mode.
    :type passive: bool
    :raises SetPassiveError: If an error occurs while setting the client to passive mode.
    """
    err = self.__client.SetPassive(self.uuid, passive)
    if err:
        raise SetPassiveError(err)

set_status_message

Python
set_status_message(msg: str)

Sets a status message for a client using the client's UUID.

PARAMETER DESCRIPTION
msg

The status message to be set.

TYPE: str

RAISES DESCRIPTION
SetStatusMessageError

If there is an error while setting the status message.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def set_status_message(self, msg: str):
    """
    Sets a status message for a client using the client's UUID.

    :param msg: The status message to be set.
    :type msg: str
    :raises SetStatusMessageError: If there is an error while setting the status message.
    """
    err = self.__client.SetStatusMessage(self.uuid, msg.encode()).decode()
    if err:
        raise SetStatusMessageError(err)

subscribe_presence

Python
subscribe_presence(jid: JID)

This method is used to subscribe to the presence of a certain JID (Jabber ID).

PARAMETER DESCRIPTION
jid

The Jabber ID (JID) that we want to subscribe to.

TYPE: JID

RAISES DESCRIPTION
SubscribePresenceError

If there is an error while subscribing to the presence of the JID.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def subscribe_presence(self, jid: JID):
    """
    This method is used to subscribe to the presence of a certain JID (Jabber ID).

    :param jid: The Jabber ID (JID) that we want to subscribe to.
    :type jid: JID
    :raises SubscribePresenceError: If there is an error while subscribing to the presence of the JID.
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.SubscribePresence(
        self.uuid, jid_proto, len(jid_proto)
    ).decode()
    if err:
        raise SubscribePresenceError(err)

unfollow_newsletter

Python
unfollow_newsletter(jid: JID)

Unfollows a newsletter by providing the JID (Jabber ID) of the newsletter.

PARAMETER DESCRIPTION
jid

The Jabber ID of the newsletter to unfollow.

TYPE: JID

RAISES DESCRIPTION
UnfollowNewsletterError

If there is an error while attempting to unfollow the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def unfollow_newsletter(self, jid: JID):
    """
    Unfollows a newsletter by providing the JID (Jabber ID) of the newsletter.

    :param jid: The Jabber ID of the newsletter to unfollow.
    :type jid: JID
    :raises UnfollowNewsletterError: If there is an error while attempting to unfollow the newsletter.
    """
    jid_proto = jid.SerializeToString()
    err = self.__client.UnfollowNewsletter(
        self.uuid, jid_proto, len(jid_proto)
    ).decode()
    if err:
        raise UnfollowNewsletterError(err)
Python
unlink_group(parent: JID, child: JID)

This method is used to unlink a child group from a parent group.

PARAMETER DESCRIPTION
parent

The JID of the parent group from which the child group is to be unlinked.

TYPE: JID

child

The JID of the child group which is to be unlinked from the parent group.

TYPE: JID

RAISES DESCRIPTION
UnlinkGroupError

If there is an error while unlinking the child group from the parent group.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def unlink_group(self, parent: JID, child: JID):
    """
    This method is used to unlink a child group from a parent group.

    :param parent: The JID of the parent group from which the child group is to be unlinked.
    :type parent: JID
    :param child: The JID of the child group which is to be unlinked from the parent group.
    :type child: JID
    :raises UnlinkGroupError: If there is an error while unlinking the child group from the parent group.
    """
    parent_proto = parent.SerializeToString()
    child_proto = child.SerializeToString()
    err = self.__client.UnlinkGroup(
        self.uuid, parent_proto, len(parent_proto), child_proto, len(child_proto)
    ).decode()
    if err:
        raise UnlinkGroupError(err)

update_blocklist

Python
update_blocklist(jid: JID, action: BlocklistAction) -> Blocklist

Function to update the blocklist with a given action on a specific JID.

PARAMETER DESCRIPTION
jid

The Jabber ID (JID) of the user to be blocked or unblocked.

TYPE: JID

action

The action to be performed (block or unblock) on the JID.

TYPE: BlocklistAction

RETURNS DESCRIPTION
Blocklist

The updated blocklist.

RAISES DESCRIPTION
UpdateBlocklistError

If there is an error while updating the blocklist.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def update_blocklist(self, jid: JID, action: BlocklistAction) -> Blocklist:
    """
    Function to update the blocklist with a given action on a specific JID.

    :param jid: The Jabber ID (JID) of the user to be blocked or unblocked.
    :type jid: JID
    :param action: The action to be performed (block or unblock) on the JID.
    :type action: BlocklistAction
    :raises UpdateBlocklistError: If there is an error while updating the blocklist.
    :return: The updated blocklist.
    :rtype: Blocklist
    """
    jid_proto = jid.SerializeToString()
    bytes_ptr = self.__client.UpdateBlocklist(
        self.uuid, jid_proto, len(jid_proto), action.value.encode()
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetBlocklistReturnFunction.FromString(protobytes)
    if model.Error:
        raise UpdateBlocklistError(model.Error)
    return model.Blocklist

update_group_participants

Python
update_group_participants(jid: JID, participants_changes: List[JID], action: ParticipantChange) -> RepeatedCompositeFieldContainer[GroupParticipant]

This method is used to update the list of participants in a group. It takes in the group's JID, a list of participant changes, and an action to perform.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group to update.

TYPE: JID

participants_changes

A list of JIDs representing the participants to be added or removed.

TYPE: List[JID]

action

The action to perform (add, remove, promote or demote participants).

TYPE: ParticipantChange

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupParticipant]

A list of the updated group participants.

RAISES DESCRIPTION
UpdateGroupParticipantsError

This error is raised if there is a problem updating the group participants.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def update_group_participants(
    self, jid: JID, participants_changes: List[JID], action: ParticipantChange
) -> RepeatedCompositeFieldContainer[GroupParticipant]:
    """
    This method is used to update the list of participants in a group.
    It takes in the group's JID, a list of participant changes, and an action to perform.

    :param jid: The JID (Jabber ID) of the group to update.
    :type jid: JID
    :param participants_changes: A list of JIDs representing the participants to be added or removed.
    :type participants_changes: List[JID]
    :param action: The action to perform (add, remove, promote or demote participants).
    :type action: ParticipantChange
    :raises UpdateGroupParticipantsError: This error is raised if there is a problem updating the group participants.
    :return: A list of the updated group participants.
    :rtype: RepeatedCompositeFieldContainer[GroupParticipant]
    """
    jid_proto = jid.SerializeToString()
    jids_proto = neonize_proto.JIDArray(
        JIDS=participants_changes
    ).SerializeToString()
    bytes_ptr = self.__client.UpdateGroupParticipants(
        self.uuid,
        jid_proto,
        len(jid_proto),
        jids_proto,
        len(jids_proto),
        action.value.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.UpdateGroupParticipantsReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise UpdateGroupParticipantsError(model.Error)
    return model.participants

upload_newsletter

Python
upload_newsletter(data: bytes, media_type: MediaType) -> UploadResponse

Uploads the newsletter to the server.

PARAMETER DESCRIPTION
data

The newsletter content in bytes.

TYPE: bytes

media_type

The type of media being uploaded.

TYPE: MediaType

RETURNS DESCRIPTION
UploadResponse

The response from the server after the upload.

RAISES DESCRIPTION
UploadError

If there is an error during the upload process.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def upload_newsletter(self, data: bytes, media_type: MediaType) -> UploadResponse:
    """Uploads the newsletter to the server.

    :param data: The newsletter content in bytes.
    :type data: bytes
    :param media_type: The type of media being uploaded.
    :type media_type: MediaType
    :raises UploadError: If there is an error during the upload process.
    :return: The response from the server after the upload.
    :rtype: UploadResponse
    """
    bytes_ptr = self.__client.UploadNewsletter(
        self.uuid, data, len(data), media_type.value
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = UploadReturnFunction.FromString(protobytes)
    if model.Error:
        raise UploadError(model.Error)
    return model.UploadResponse

create_group

Python
create_group(name: str, participants: List[JID] = [], linked_parent: Optional[GroupLinkedParent] = None, group_parent: Optional[GroupParent] = None) -> GroupInfo

Create a new group.

PARAMETER DESCRIPTION
name

The name of the new group.

TYPE: str

participants

Optional. A list of participant JIDs (Jabber Identifiers) to be included in the group. Defaults to an empty list.

TYPE: List[JID] DEFAULT: []

linked_parent

Optional. Information about a linked parent group, if applicable. Defaults to None.

TYPE: Optional[GroupLinkedParent] DEFAULT: None

group_parent

Optional. Information about a parent group, if applicable. Defaults to None.

TYPE: Optional[GroupParent] DEFAULT: None

RETURNS DESCRIPTION
GroupInfo

Information about the newly created group.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def create_group(
    self,
    name: str,
    participants: List[JID] = [],
    linked_parent: Optional[GroupLinkedParent] = None,
    group_parent: Optional[GroupParent] = None,
) -> GroupInfo:
    """Create a new group.

    :param name: The name of the new group.
    :type name: str
    :param participants: Optional. A list of participant JIDs (Jabber Identifiers) to be included in the group. Defaults to an empty list.
    :type participants: List[JID], optional
    :param linked_parent: Optional. Information about a linked parent group, if applicable. Defaults to None.
    :type linked_parent: Optional[GroupLinkedParent], optional
    :param group_parent: Optional. Information about a parent group, if applicable. Defaults to None.
    :type group_parent: Optional[GroupParent], optional
    :return: Information about the newly created group.
    :rtype: GroupInfo
    """
    group_info = ReqCreateGroup(
        name=name, Participants=participants, CreateKey=self.generate_message_id()
    )
    if linked_parent:
        group_info.GroupLinkedParent.MergeFrom(linked_parent)
    if group_parent:
        group_info.GroupParent.MergeFrom(group_parent)
    group_info_buf = group_info.SerializeToString()
    bytes_ptr = self.__client.CreateGroup(
        self.uuid, group_info_buf, len(group_info_buf)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise CreateGroupError(model.Error)
    return model.GroupInfo

get_group_request_participants

Python
get_group_request_participants(jid: JID) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]

Get the participants of a group request.

PARAMETER DESCRIPTION
jid

The JID of the group request.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

A list of JIDs representing the participants of the group request.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_group_request_participants(
    self, jid: JID
) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]:
    """Get the participants of a group request.

    :param jid: The JID of the group request.
    :type jid: JID
    :return: A list of JIDs representing the participants of the group request.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = self.__client.GetGroupRequestParticipants(
        self.uuid, jidbyte, len(jidbyte)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetGroupRequestParticipantsReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetGroupRequestParticipantsError(model.Error)
    return model.Participants

get_joined_groups

Python
get_joined_groups() -> RepeatedCompositeFieldContainer[GroupInfo]

Get the joined groups for the current user.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupInfo]

A list of :class:GroupInfo objects representing the joined groups.

RAISES DESCRIPTION
GetJoinedGroupsError

If there was an error retrieving the joined groups.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_joined_groups(self) -> RepeatedCompositeFieldContainer[GroupInfo]:
    """Get the joined groups for the current user.

    :return: A list of :class:`GroupInfo` objects representing the joined groups.
    :rtype: RepeatedCompositeFieldContainer[GroupInfo]

    :raises GetJoinedGroupsError: If there was an error retrieving the joined groups.
    """
    bytes_ptr = self.__client.GetJoinedGroups(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetJoinedGroupsReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJoinedGroupsError(model.Error)
    return model.Group

create_newsletter

Python
create_newsletter(name: str, description: str, picture: Union[str, bytes]) -> NewsletterMetadata

Create a newsletter with the given name, description, and picture.

PARAMETER DESCRIPTION
name

The name of the newsletter.

TYPE: str

description

The description of the newsletter.

TYPE: str

picture

The picture of the newsletter. It can be either a URL or bytes.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
NewsletterMetadata

The metadata of the created newsletter.

RAISES DESCRIPTION
CreateNewsletterError

If there is an error creating the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def create_newsletter(
    self, name: str, description: str, picture: typing.Union[str, bytes]
) -> NewsletterMetadata:
    """Create a newsletter with the given name, description, and picture.

    :param name: The name of the newsletter.
    :type name: str
    :param description: The description of the newsletter.
    :type description: str
    :param picture: The picture of the newsletter. It can be either a URL or bytes.
    :type picture: Union[str, bytes]
    :return: The metadata of the created newsletter.
    :rtype: NewsletterMetadata
    :raises CreateNewsletterError: If there is an error creating the newsletter.
    """
    protobuf = neonize_proto.CreateNewsletterParams(
        Name=name,
        Description=description,
        Picture=get_bytes_from_name_or_url(picture),
    ).SerializeToString()
    bytes_ptr = self.__client.CreateNewsletter(self.uuid, protobuf, len(protobuf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise CreateNewsletterError(model.Error)
    return model.NewsletterMetadata

follow_newsletter

Python
follow_newsletter(jid: JID)

Follows a newsletter with the given JID.

PARAMETER DESCRIPTION
jid

The JID of the newsletter to follow.

TYPE: JID

RETURNS DESCRIPTION
None

None

RAISES DESCRIPTION
FollowNewsletterError

If there is an error following the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def follow_newsletter(self, jid: JID):
    """Follows a newsletter with the given JID.

    :param jid: The JID of the newsletter to follow.
    :type jid: JID
    :return: None
    :rtype: None
    :raises FollowNewsletterError: If there is an error following the newsletter.
    """

    jidbyte = jid.SerializeToString()
    err = self.__client.FollowNewsletter(self.uuid, jidbyte, len(jidbyte)).decode()
    if err:
        raise FollowNewsletterError(err)

get_newsletter_info_with_invite

Python
get_newsletter_info_with_invite(key: str) -> NewsletterMetadata

Retrieves the newsletter information with an invite using the provided key.

PARAMETER DESCRIPTION
key

The key used to identify the newsletter.

TYPE: str

RETURNS DESCRIPTION
NewsletterMetadata

The newsletter metadata.

RAISES DESCRIPTION
GetNewsletterInfoWithInviteError

If there is an error retrieving the newsletter information.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_newsletter_info_with_invite(self, key: str) -> NewsletterMetadata:
    """Retrieves the newsletter information with an invite using the provided key.

    :param key: The key used to identify the newsletter.
    :type key: str
    :return: The newsletter metadata.
    :rtype: NewsletterMetadata
    :raises GetNewsletterInfoWithInviteError: If there is an error retrieving the newsletter information.
    """
    bytes_ptr = self.__client.GetNewsletterInfoWithInvite(self.uuid, key.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetNewsletterInfoWithInviteError(model.Error)
    return model.NewsletterMetadata

get_newsletter_message_update

Python
get_newsletter_message_update(jid: JID, count: int, since: int, after: int) -> RepeatedCompositeFieldContainer[NewsletterMessage]

Retrieves a list of newsletter messages that have been updated since a given timestamp.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the user.

TYPE: JID

count

The maximum number of messages to retrieve.

TYPE: int

since

The timestamp (in milliseconds) to retrieve messages from.

TYPE: int

after

The timestamp (in milliseconds) to retrieve messages after.

TYPE: int

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[NewsletterMessage]

A list of updated newsletter messages.

RAISES DESCRIPTION
GetNewsletterMessageUpdateError

If there was an error retrieving the newsletter messages.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_newsletter_message_update(
    self, jid: JID, count: int, since: int, after: int
) -> RepeatedCompositeFieldContainer[NewsletterMessage]:
    """Retrieves a list of newsletter messages that have been updated since a given timestamp.

    :param jid: The JID (Jabber ID) of the user.
    :type jid: JID
    :param count: The maximum number of messages to retrieve.
    :type count: int
    :param since: The timestamp (in milliseconds) to retrieve messages from.
    :type since: int
    :param after: The timestamp (in milliseconds) to retrieve messages after.
    :type after: int

    :return: A list of updated newsletter messages.
    :rtype: RepeatedCompositeFieldContainer[NewsletterMessage]

    :raises GetNewsletterMessageUpdateError: If there was an error retrieving the newsletter messages.
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = self.__client.GetNewsletterMessageUpdate(
        self.uuid, jidbyte, len(jidbyte), count, since, after
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetNewsletterMessageUpdateReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetNewsletterMessageUpdateError(model.Error)
    return model.NewsletterMessage

get_newsletter_messages

Python
get_newsletter_messages(jid: JID, count: int, before: MessageServerID) -> RepeatedCompositeFieldContainer[NewsletterMessage]

Retrieves a list of newsletter messages for a given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the user.

TYPE: JID

count

The maximum number of messages to retrieve.

TYPE: int

before

The ID of the message before which to retrieve messages.

TYPE: MessageServerID

RETURNS DESCRIPTION
RepeatedCompositeFieldContaine[NewsletterMessage]

A list of newsletter messages.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_newsletter_messages(
    self, jid: JID, count: int, before: MessageServerID
) -> RepeatedCompositeFieldContainer[NewsletterMessage]:
    """Retrieves a list of newsletter messages for a given JID.

    :param jid: The JID (Jabber Identifier) of the user.
    :type jid: JID
    :param count: The maximum number of messages to retrieve.
    :type count: int
    :param before: The ID of the message before which to retrieve messages.
    :type before: MessageServerID
    :return: A list of newsletter messages.
    :rtype: RepeatedCompositeFieldContaine[NewsletterMessage]
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = self.__client.GetNewsletterMessages(
        self.uuid, jidbyte, len(jidbyte), count, before
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetNewsletterMessageUpdateReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetNewsletterMessagesError(model.Error)
    return model.NewsletterMessage

get_privacy_settings

Python
get_privacy_settings() -> PrivacySettings

This function retrieves the my privacy settings.

RETURNS DESCRIPTION
PrivacySettings

privacy settings

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_privacy_settings(self) -> PrivacySettings:
    """
    This function retrieves the my privacy settings.

    :return: privacy settings
    :rtype: PrivacySettings
    """
    bytes_ptr = self.__client.GetPrivacySettings(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = neonize_proto.PrivacySettings.FromString(protobytes)
    return result

get_profile_picture

Python
get_profile_picture(jid: JID, extra: GetProfilePictureParams = neonize_proto.GetProfilePictureParams()) -> ProfilePictureInfo

This function is used to get the profile picture of a user.

PARAMETER DESCRIPTION
jid

The unique identifier of the user whose profile picture we want to retrieve.

TYPE: JID

extra

Additional parameters, defaults to neonize_proto.GetProfilePictureParams()

TYPE: GetProfilePictureParams DEFAULT: GetProfilePictureParams()

RETURNS DESCRIPTION
ProfilePictureInfo

The information about the profile picture.

RAISES DESCRIPTION
GetProfilePictureError

If there is an error while trying to get the profile picture.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_profile_picture(
    self,
    jid: JID,
    extra: neonize_proto.GetProfilePictureParams = neonize_proto.GetProfilePictureParams(),
) -> ProfilePictureInfo:
    """
    This function is used to get the profile picture of a user.

    :param jid: The unique identifier of the user whose profile picture we want to retrieve.
    :type jid: JID
    :param extra: Additional parameters, defaults to neonize_proto.GetProfilePictureParams()
    :type extra: neonize_proto.GetProfilePictureParams, optional
    :raises GetProfilePictureError: If there is an error while trying to get the profile picture.
    :return: The information about the profile picture.
    :rtype: ProfilePictureInfo
    """
    jid_bytes = jid.SerializeToString()
    extra_bytes = extra.SerializeToString()
    bytes_ptr = self.__client.GetProfilePicture(
        self.uuid,
        jid_bytes,
        len(jid_bytes),
        extra_bytes,
        len(extra_bytes),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetProfilePictureReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetProfilePictureError(model)
    return model.Picture

get_status_privacy

Python
get_status_privacy() -> RepeatedCompositeFieldContainer[StatusPrivacy]

Returns the status privacy settings of the user.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[StatusPrivacy]

The status privacy settings of the user.

RAISES DESCRIPTION
GetStatusPrivacyError

If there is an error in getting the status privacy.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_status_privacy(
    self,
) -> RepeatedCompositeFieldContainer[StatusPrivacy]:
    """Returns the status privacy settings of the user.

    :raises GetStatusPrivacyError: If there is an error in getting the status privacy.
    :return: The status privacy settings of the user.
    :rtype: RepeatedCompositeFieldContainer[StatusPrivacy]
    """
    bytes_ptr = self.__client.GetStatusPrivacy(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetStatusPrivacyReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetStatusPrivacyError(model.Error)
    return model.StatusPrivacy

get_sub_groups

Python
get_sub_groups(community: JID) -> RepeatedCompositeFieldContainer[GroupLinkTarget]

Get the subgroups of a given community.

PARAMETER DESCRIPTION
community

The community for which to get the subgroups.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupLinkTarget]

The subgroups of the given community.

RAISES DESCRIPTION
GetSubGroupsError

If there is an error while getting the subgroups.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_sub_groups(
    self, community: JID
) -> RepeatedCompositeFieldContainer[GroupLinkTarget]:
    """
    Get the subgroups of a given community.

    :param community: The community for which to get the subgroups.
    :type community: JID
    :raises GetSubGroupsError: If there is an error while getting the subgroups.
    :return: The subgroups of the given community.
    :rtype: RepeatedCompositeFieldContainer[GroupLinkTarget]
    """
    jid = community.SerializeToString()
    bytes_ptr = self.__client.GetSubGroups(self.uuid, jid, len(jid))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetSubGroupsReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetSubGroupsError(model.Error)
    return model.GroupLinkTarget

get_subscribed_newletters

Python
get_subscribed_newletters() -> RepeatedCompositeFieldContainer[NewsletterMetadata]

This function retrieves the newsletters the user has subscribed to.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[NewsletterMetadata]

A container with the metadata of each subscribed newsletter

RAISES DESCRIPTION
GetSubscribedNewslettersError

If there is an error while fetching the subscribed newsletters

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_subscribed_newletters(
    self,
) -> RepeatedCompositeFieldContainer[NewsletterMetadata]:
    """
    This function retrieves the newsletters the user has subscribed to.

    :raises GetSubscribedNewslettersError: If there is an error while fetching the subscribed newsletters
    :return: A container with the metadata of each subscribed newsletter
    :rtype: RepeatedCompositeFieldContainer[NewsletterMetadata]
    """
    bytes_ptr = self.__client.GetSubscribedNewsletters(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetSubscribedNewslettersReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetSubscribedNewslettersError(model.Error)
    return model.Newsletter

get_user_devices

Python
get_user_devices(*jids: JID) -> RepeatedCompositeFieldContainer[JID]

Retrieve devices associated with specified user JIDs.

PARAMETER DESCRIPTION
jids

Variable number of JIDs (Jabber Identifiers) of users.

TYPE: JID DEFAULT: ()

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

Devices associated with the specified user JIDs.

RAISES DESCRIPTION
GetUserDevicesError

If there is an error retrieving user devices.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_user_devices(self, *jids: JID) -> RepeatedCompositeFieldContainer[JID]:
    """
    Retrieve devices associated with specified user JIDs.

    :param jids: Variable number of JIDs (Jabber Identifiers) of users.
    :type jids: JID
    :raises GetUserDevicesError: If there is an error retrieving user devices.
    :return: Devices associated with the specified user JIDs.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jids_ = neonize_proto.JIDArray(JIDS=jids).SerializeToString()
    bytes_ptr = self.__client.GetUserDevices(self.uuid, jids_, len(jids_))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetUserDevicesreturnFunction.FromString(protobytes)
    if model.Error:
        raise GetUserDevicesError(model.Error)
    return model.JID

get_blocklist

Python
get_blocklist() -> Blocklist

Retrieves the blocklist from the client.

RETURNS DESCRIPTION
Blocklist

Blocklist: The retrieved blocklist.

RAISES DESCRIPTION
GetBlocklistError

If there was an error retrieving the blocklist.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_blocklist(self) -> Blocklist:
    """Retrieves the blocklist from the client.

    :return: Blocklist: The retrieved blocklist.
    :raises GetBlocklistError: If there was an error retrieving the blocklist.
    """
    bytes_ptr = self.__client.GetBlocklist(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetBlocklistReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetBlocklistError(model.Error)
    return model.Blocklist

get_me

Python
get_me() -> Device

This method is used to get the device information associated with a given UUID.

RETURNS DESCRIPTION
Device

It returns a Device object created from the byte string response from the client's GetMe method.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_me(self) -> Device:
    """
    This method is used to get the device information associated with a given UUID.

    :return: It returns a Device object created from the byte string response from the client's GetMe method.
    :rtype: Device
    """
    bytes_ptr = self.__client.GetMe(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = Device.FromString(protobytes)
    return result
Python
get_contact_qr_link(revoke: bool = False) -> str

This function returns a QR link for a specific contact. If the 'revoke' parameter is set to True, it revokes the existing QR link and generates a new one.

PARAMETER DESCRIPTION
revoke

If set to True, revokes the existing QR link and generates a new one. Defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

The QR link for the contact.

RAISES DESCRIPTION
GetContactQrLinkError

If there is an error in getting the QR link.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_contact_qr_link(self, revoke: bool = False) -> str:
    """
    This function returns a QR link for a specific contact. If the 'revoke' parameter is set to True,
    it revokes the existing QR link and generates a new one.

    :param revoke: If set to True, revokes the existing QR link and generates a new one. Defaults to False.
    :type revoke: bool, optional
    :raises GetContactQrLinkError: If there is an error in getting the QR link.
    :return: The QR link for the contact.
    :rtype: str
    """
    bytes_ptr = self.__client.GetContactQRLink(self.uuid, revoke)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetContactQRLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetContactQrLinkError(model.Error)
    return model.Link

get_linked_group_participants

Python
get_linked_group_participants(community: JID) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]

Fetches the participants of a linked group in a community.

PARAMETER DESCRIPTION
community

The community in which the linked group belongs.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

A list of participants in the linked group.

RAISES DESCRIPTION
GetLinkedGroupParticipantsError

If there is an error while fetching the participants.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_linked_group_participants(
    self, community: JID
) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]:
    """Fetches the participants of a linked group in a community.

    :param community: The community in which the linked group belongs.
    :type community: JID
    :raises GetLinkedGroupParticipantsError: If there is an error while fetching the participants.
    :return: A list of participants in the linked group.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jidbyte = community.SerializeToString()
    bytes_ptr = self.__client.GetLinkedGroupsParticipants(
        self.uuid, jidbyte, len(jidbyte)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetGroupRequestParticipantsReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetLinkedGroupParticipantsError(model.Error)
    return model.Participants

get_newsletter_info

Python
get_newsletter_info(jid: JID) -> neonize_proto.NewsletterMetadata

Fetches the metadata of a specific newsletter using its JID.

PARAMETER DESCRIPTION
jid

The unique identifier of the newsletter

TYPE: JID

RETURNS DESCRIPTION
neonize_proto.NewsletterMetadata

The metadata of the requested newsletter

RAISES DESCRIPTION
GetNewsletterInfoError

If there is an error while fetching the newsletter information

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_newsletter_info(self, jid: JID) -> neonize_proto.NewsletterMetadata:
    """
    Fetches the metadata of a specific newsletter using its JID.

    :param jid: The unique identifier of the newsletter
    :type jid: JID
    :raises GetNewsletterInfoError: If there is an error while fetching the newsletter information
    :return: The metadata of the requested newsletter
    :rtype: neonize_proto.NewsletterMetadata
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = self.__client.GetNewsletterInfo(self.uuid, jidbyte, len(jidbyte))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetNewsletterInfoError(model.Error)
    return model.NewsletterMetadata

PairPhone

Python
PairPhone(phone: str, show_push_notification: bool, client_name: ClientName = ClientName.LINUX, client_type: Optional[ClientType] = None)

Pair a phone with the client. This function will try to connect to the WhatsApp servers and pair the phone. If successful, it will show a push notification on the paired phone.

PARAMETER DESCRIPTION
phone

The phone number to be paired.

TYPE: str

show_push_notification

If true, a push notification will be shown on the paired phone.

TYPE: bool

client_name

The name of the client, defaults to LINUX.

TYPE: ClientName DEFAULT: LINUX

client_type

The type of the client, defaults to None. If None, it will be set to FIREFOX or determined by the device properties.

TYPE: Optional[ClientType] DEFAULT: None

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def PairPhone(
    self,
    phone: str,
    show_push_notification: bool,
    client_name: ClientName = ClientName.LINUX,
    client_type: Optional[ClientType] = None,
):
    """
    Pair a phone with the client. This function will try to connect to the WhatsApp servers and pair the phone.
    If successful, it will show a push notification on the paired phone.

    :param phone: The phone number to be paired.
    :type phone: str
    :param show_push_notification: If true, a push notification will be shown on the paired phone.
    :type show_push_notification: bool
    :param client_name: The name of the client, defaults to LINUX.
    :type client_name: ClientName, optional
    :param client_type: The type of the client, defaults to None. If None, it will be set to FIREFOX or determined by the device properties.
    :type client_type: Optional[ClientType], optional
    """

    if client_type is None:
        if self.device_props is None:
            client_type = ClientType.FIREFOX
        else:
            try:
                client_type = ClientType(self.device_props.platformType)
            except ValueError:
                client_type = ClientType.FIREFOX

    pl = neonize_proto.PairPhoneParams(
        phone=phone,
        clientDisplayName="%s (%s)" % (client_type.name, client_name.name),
        clientType=client_type.value,
        showPushNotification=show_push_notification,
    )
    payload = pl.SerializeToString()
    d = bytearray(list(self.event.list_func))

    _log_.debug("trying connect to whatsapp servers")

    deviceprops = (
        DeviceProps(os="Neonize", platformType=DeviceProps.SAFARI)
        if self.device_props is None
        else self.device_props
    ).SerializeToString()

    jidbuf_size = 0
    jidbuf = b""
    if self.jid:
        jidbuf = self.jid.SerializeToString()
        jidbuf_size = len(jidbuf)

    self.__client.Neonize(
        self.name.encode(),
        self.uuid,
        jidbuf,
        jidbuf_size,
        LogLevel.from_logging(log.level).level,
        func_string(self.__onQr),
        func_string(self.__onLoginStatus),
        func_callback_bytes(self.event.execute),
        func_callback_bytes2(log_whatsmeow),
        (ctypes.c_char * self.event.list_func.__len__()).from_buffer(d),
        len(d),
        deviceprops,
        len(deviceprops),
        payload,
        len(payload),
    )

stop

Python
stop()

Stops the client by disconnecting it from the WhatsApp servers.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def stop(self):
    """
    Stops the client by disconnecting it from the WhatsApp servers.
    """
    _log_.debug("Stopping client and disconnecting from WhatsApp servers.")
    self.__client.stop()

get_message_for_retry

Python
get_message_for_retry(requester: JID, to: JID, message_id: str) -> typing.Union[None, Message]

This function retrieves a specific message for retrying transmission. It communicates with a client to get the message using provided requester, recipient, and message ID.

PARAMETER DESCRIPTION
requester

The JID of the entity requesting the message.

TYPE: JID

to

The JID of the intended recipient of the message.

TYPE: JID

message_id

The unique identifier of the message to be retrieved.

TYPE: str

RETURNS DESCRIPTION
Union[None, Message]

The message to be retried if found, None otherwise.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def get_message_for_retry(
    self, requester: JID, to: JID, message_id: str
) -> typing.Union[None, Message]:
    """
    This function retrieves a specific message for retrying transmission.
    It communicates with a client to get the message using provided requester, recipient, and message ID.

    :param requester: The JID of the entity requesting the message.
    :type requester: JID
    :param to: The JID of the intended recipient of the message.
    :type to: JID
    :param message_id: The unique identifier of the message to be retrieved.
    :type message_id: str
    :return: The message to be retried if found, None otherwise.
    :rtype: Union[None, Message]
    """
    requester_buf = requester.SerializeToString()
    to_buf = to.SerializeToString()
    bytes_ptr = self.__client.GetMessageForRetry(
        self.uuid,
        requester_buf,
        len(requester_buf),
        to_buf,
        len(to_buf),
        message_id.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetMessageForRetryReturnFunction.FromString(protobytes)
    if model.Error:
        raise Exception(model.Error)
    if not model.isEmpty:
        return model.Message

decrypt_poll_vote

Python
decrypt_poll_vote(message: Message) -> PollVoteMessage

Decrypt PollMessage

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def decrypt_poll_vote(self, message: neonize_proto.Message) -> PollVoteMessage:
    """Decrypt PollMessage"""
    msg_buff = message.SerializeToString()
    bytes_ptr = self.__client.DecryptPollVote(self.uuid, msg_buff)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = ReturnFunctionWithError.FromString(protobytes)
    if model.Error:
        raise DecryptPollVoteError(model.Error)
    return model.PollVoteMessage

connect

Python
connect()

Establishes a connection to the WhatsApp servers.

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def connect(self):
    """Establishes a connection to the WhatsApp servers."""
    # Convert the list of functions to a bytearray
    d = bytearray(list(self.event.list_func))
    _log_.debug("🔒 Attempting to connect to the WhatsApp servers.")
    # Set device properties
    deviceprops = (
        DeviceProps(os="Neonize", platformType=DeviceProps.SAFARI)
        if self.device_props is None
        else self.device_props
    ).SerializeToString()

    jidbuf_size = 0
    jidbuf = b""
    if self.jid:
        jidbuf = self.jid.SerializeToString()
        jidbuf_size = len(jidbuf)

    # Initiate connection to the server
    self.__client.Neonize(
        self.name.encode(),
        self.uuid,
        jidbuf,
        jidbuf_size,
        LogLevel.from_logging(log.level).level,
        func_string(self.__onQr),
        func_string(self.__onLoginStatus),
        func_callback_bytes(self.event.execute),
        func_callback_bytes2(log_whatsmeow),
        (ctypes.c_char * len(self.event.list_func)).from_buffer(d),
        len(d),
        deviceprops,
        len(deviceprops),
        b"",
        0,
    )

disconnect

Python
disconnect() -> None

Disconnect the client

Source code in .venv/lib/python3.12/site-packages/neonize/client.py
Python
def disconnect(self) -> None:
    """
    Disconnect the client
    """
    self.__client.Disconnect(self.uuid)

Async Client

neonize.aioze.client.NewAClient

Python
NewAClient(name: str, jid: Optional[JID] = None, props: Optional[DeviceProps] = None, uuid: Optional[str] = None)

Initializes a new client instance.

PARAMETER DESCRIPTION
name

The name or identifier for the new client.

TYPE: str

jid

Optional. The JID (Jabber Identifier) for the client. If not provided, first client is used.

TYPE: Optional[JID] DEFAULT: None

qrCallback

Optional. A callback function for handling QR code updates, defaults to None.

TYPE: (Optional[Callable[[NewClient, bytes], None]], optional)

messageCallback

Optional. A callback function for handling incoming messages, defaults to None.

TYPE: (Optional[Callable[[NewClient, MessageSource, Message], None]], optional)

uuid

Optional. A unique identifier for the client, defaults to None.

TYPE: Optional[str] DEFAULT: None

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
def __init__(
    self,
    name: str,
    jid: Optional[JID] = None,
    props: Optional[DeviceProps] = None,
    uuid: Optional[str] = None,
):
    """Initializes a new client instance.

    :param name: The name or identifier for the new client.
    :type name: str
    :param jid: Optional. The JID (Jabber Identifier) for the client. If not provided, first client is used.
    :param qrCallback: Optional. A callback function for handling QR code updates, defaults to None.
    :type qrCallback: Optional[Callable[[NewClient, bytes], None]], optional
    :param messageCallback: Optional. A callback function for handling incoming messages, defaults to None.
    :type messageCallback: Optional[Callable[[NewClient, MessageSource, Message], None]], optional
    :param uuid: Optional. A unique identifier for the client, defaults to None.
    :type uuid: Optional[str], optional
    """
    self.name = name
    self.device_props = props
    self.jid = jid
    self.uuid = (
        jid.User if jid else (uuid or name)
    ).encode()  # ((jid.User if jid else None) or uuid or name).encode()
    self.__client = async_gocode
    self.event = Event(self)
    self.paircode = self.event.paircode
    self.qr = self.event.qr
    self.contact = ContactStore(self.uuid)
    self.chat_settings = ChatSettingsStore(self.uuid)
    self.connect_task = None
    self.connected = False
    self.loop = event_global_loop
    self.me = None
    _log_.debug("🔨 Creating a NewClient instance")

Attributes

is_connected property

Python
is_connected: bool

Check if the object is currently connected.

RETURNS DESCRIPTION
bool

True if the object is connected, False otherwise.

is_logged_in property

Python
is_logged_in: bool

Check if the user is currently logged in.

RETURNS DESCRIPTION
bool

True if the user is logged in, False otherwise.

Functions

send_message async

Python
send_message(to: JID, message: Union[Message, str], link_preview: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a message to the specified JID.

PARAMETER DESCRIPTION
to

The JID to send the message to.

TYPE: JID

message

The message to send.

TYPE: Union[Message, str]

link_preview

Whether to send a link preview, defaults to False

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

The response from the server.

RAISES DESCRIPTION
SendMessageError

If there was an error sending the message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_message(
    self,
    to: JID,
    message: typing.Union[Message, str],
    link_preview: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Send a message to the specified JID.

    :param to: The JID to send the message to.
    :type to: JID
    :param message: The message to send.
    :type message: typing.Union[Message, str]
    :param link_preview: Whether to send a link preview, defaults to False
    :type link_preview: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :raises SendMessageError: If there was an error sending the message.
    :return: The response from the server.
    :rtype: SendResponse
    """
    to_bytes = to.SerializeToString()
    if isinstance(message, str):
        mentioned_groups = await self._parse_group_mention(message)
        mentioned_jid = self._parse_mention(
            (ghost_mentions or message), mentions_are_lids
        )
        partial_msg = ExtendedTextMessage(
            text=message,
            contextInfo=ContextInfo(
                mentionedJID=mentioned_jid, groupMentions=mentioned_groups
            ),
        )
        if link_preview:
            preview = await self._generate_link_preview(message)
            if preview:
                partial_msg.MergeFrom(preview)
        if partial_msg.previewType is None and not (
            mentioned_groups or mentioned_jid
        ):
            msg = Message(conversation=message)
        else:
            msg = Message(extendedTextMessage=partial_msg)
    else:
        msg = message
    if add_msg_secret:
        # optionally patch message with messageSecret to allow reactions and replies to messages sent to community announcements
        # see:
        # https://github.com/tulir/whatsmeow/issues/509#issuecomment-1842732773
        msg.messageContextInfo.messageSecret = urandom(32)
    message_bytes = msg.SerializeToString()
    bytes_ptr = await self.__client.SendMessage(
        self.uuid, to_bytes, len(to_bytes), message_bytes, len(message_bytes)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SendMessageReturnFunction.FromString(protobytes)
    if model.Error:
        raise SendMessageError(model.Error)
    model.SendResponse.MergeFrom(model.SendResponse.__class__(Message=msg))
    return model.SendResponse

build_reply_message async

Python
build_reply_message(message: Union[str, MessageWithContextInfo], quoted: Message, link_preview: bool = False, reply_privately: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

Send a reply message to a specified JID.

PARAMETER DESCRIPTION
message

The message to be sent. Can be a string or a MessageWithContextInfo object.

TYPE: Union[str, MessageWithContextInfo]

quoted

The message to be quoted in the message being sent.

TYPE: Message

link_preview

If set to True, enables link previews in the message being sent. Defaults to False.

TYPE: bool DEFAULT: False

reply_privately

If set to True, the message is sent as a private reply. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

Response of the send operation.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_reply_message(
    self,
    message: typing.Union[str, MessageWithContextInfo],
    quoted: neonize_proto.Message,
    link_preview: bool = False,
    reply_privately: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """Send a reply message to a specified JID.

    :param message: The message to be sent. Can be a string or a MessageWithContextInfo object.
    :type message: typing.Union[str, MessageWithContextInfo]
    :param quoted: The message to be quoted in the message being sent.
    :type quoted: neonize_proto.Message
    :param link_preview: If set to True, enables link previews in the message being sent. Defaults to False.
    :type link_preview: bool, optional
    :param reply_privately: If set to True, the message is sent as a private reply. Defaults to False.
    :type reply_privately: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :return: Response of the send operation.
    :rtype: SendResponse
    """
    build_message = Message()
    if isinstance(message, str):
        partial_message = ExtendedTextMessage(
            text=message,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or message), mentions_are_lids
                ),
                groupMentions=(await self._parse_group_mention(message)),
            ),
        )
        if link_preview:
            preview = await self._generate_link_preview(message)
            if preview is not None:
                partial_message.MergeFrom(preview)
    else:
        partial_message = message
    field_name = (
        partial_message.__class__.__name__[0].lower()
        + partial_message.__class__.__name__[1:]
    )  # type: ignore
    partial_message.contextInfo.MergeFrom(
        self._make_quoted_message(quoted, reply_privately)
    )
    getattr(build_message, field_name).MergeFrom(partial_message)
    return build_message

reply_message async

Python
reply_message(message: Union[str, MessageWithContextInfo], quoted: Message, to: Optional[JID] = None, link_preview: bool = False, reply_privately: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a reply message to a specified JID.

PARAMETER DESCRIPTION
message

The message to be sent. Can be a string or a MessageWithContextInfo object.

TYPE: Union[str, MessageWithContextInfo]

quoted

The message to be quoted in the message being sent.

TYPE: Message

to

The recipient of the message. If not specified, the message is sent to the default recipient.

TYPE: Optional[JID] DEFAULT: None

link_preview

If set to True, enables link previews in the message being sent. Defaults to False.

TYPE: bool DEFAULT: False

reply_privately

If set to True, the message is sent as a private reply. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

mentions_are_lids

whether mentions contained in message or ghost_mentions are lids, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

If set to True generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

Response of the send operation.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def reply_message(
    self,
    message: typing.Union[str, MessageWithContextInfo],
    quoted: neonize_proto.Message,
    to: Optional[JID] = None,
    link_preview: bool = False,
    reply_privately: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Send a reply message to a specified JID.

    :param message: The message to be sent. Can be a string or a MessageWithContextInfo object.
    :type message: typing.Union[str, MessageWithContextInfo]
    :param quoted: The message to be quoted in the message being sent.
    :type quoted: neonize_proto.Message
    :param to: The recipient of the message. If not specified, the message is sent to the default recipient.
    :type to: Optional[JID], optional
    :param link_preview: If set to True, enables link previews in the message being sent. Defaults to False.
    :type link_preview: bool, optional
    :param reply_privately: If set to True, the message is sent as a private reply. Defaults to False.
    :type reply_privately: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param mentions_are_lids: whether mentions contained in message or ghost_mentions are lids, defaults to False.
    :type mentions_are_lids: bool, optional
    :param add_msg_secret: If set to True generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: Response of the send operation.
    :rtype: SendResponse
    """
    if to is None:
        if reply_privately:
            sender = quoted.Info.MessageSource.Sender
            if jid_is_lid(sender):
                sender = quoted.Info.MessageSource.SenderAlt or sender
            to = JIDToNonAD(sender)
        else:
            to = quoted.Info.MessageSource.Chat
    return await self.send_message(
        to,
        await self.build_reply_message(
            message=message,
            quoted=quoted,
            link_preview=link_preview,
            reply_privately=reply_privately,
            ghost_mentions=ghost_mentions,
            mentions_are_lids=mentions_are_lids,
        ),
        link_preview,
        add_msg_secret=add_msg_secret,
    )

edit_message async

Python
edit_message(chat: JID, message_id: str, new_message: Message) -> SendResponse

Edit a message.

PARAMETER DESCRIPTION
chat

Chat ID

TYPE: JID

message_id

Message ID

TYPE: str

new_message

New message

TYPE: Message

RETURNS DESCRIPTION
SendResponse

Response from server

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def edit_message(
    self, chat: JID, message_id: str, new_message: Message
) -> SendResponse:
    """Edit a message.

    :param chat: Chat ID
    :type chat: JID
    :param message_id: Message ID
    :type message_id: str
    :param new_message: New message
    :type new_message: Message
    :return: Response from server
    :rtype: SendResponse
    """
    return await self.send_message(chat, build_edit(chat, message_id, new_message))

revoke_message async

Python
revoke_message(chat: JID, sender: JID, message_id: str) -> SendResponse

Revoke a message.

PARAMETER DESCRIPTION
chat

Chat ID

TYPE: JID

sender

Sender ID

TYPE: JID

message_id

Message ID

TYPE: str

RETURNS DESCRIPTION
SendResponse

Response from server

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def revoke_message(
    self, chat: JID, sender: JID, message_id: str
) -> SendResponse:
    """Revoke a message.

    :param chat: Chat ID
    :type chat: JID
    :param sender: Sender ID
    :type sender: JID
    :param message_id: Message ID
    :type message_id: str
    :return: Response from server
    :rtype: SendResponse
    """
    return await self.send_message(
        chat, await self.build_revoke(chat, sender, message_id)
    )

build_poll_vote_creation async

Python
build_poll_vote_creation(name: str, options: List[str], selectable_count: VoteType, quoted: Optional[Message] = None) -> Message

Build a poll vote creation message.

PARAMETER DESCRIPTION
name

The name of the poll.

TYPE: str

options

The options for the poll.

TYPE: List[str]

selectable_count

The number of selectable options.

TYPE: VoteType

quoted

A message that the poll message is a reply to, defaults to None

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
Message

The poll vote creation message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_poll_vote_creation(
    self,
    name: str,
    options: List[str],
    selectable_count: VoteType,
    quoted: Optional[neonize_proto.Message] = None,
) -> Message:
    """Build a poll vote creation message.

    :param name: The name of the poll.
    :type name: str
    :param options: The options for the poll.
    :type options: List[str]
    :param selectable_count: The number of selectable options.
    :type selectable_count: int
    :param quoted: A message that the poll message is a reply to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :return: The poll vote creation message.
    :rtype: Message
    """
    options_buf = neonize_proto.ArrayString(data=options).SerializeToString()
    bytes_ptr = await self.__client.BuildPollVoteCreation(
        self.uuid,
        name.encode(),
        options_buf,
        len(options_buf),
        selectable_count.value,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = BuildMessageReturnFunction.FromString(protobytes)
    if model.Error:
        # To be replaced with a custom exception
        raise BuildPollVoteCreationError(model.Error)
    message = model.Message
    # result = Message.FromString(protobytes)
    if quoted:
        message.pollCreationMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

build_poll_vote async

Python
build_poll_vote(poll_info: MessageInfo, option_names: List[str]) -> Message

Builds a poll vote.

PARAMETER DESCRIPTION
poll_info

The information about the poll.

TYPE: MessageInfo

option_names

The names of the options to vote for.

TYPE: List[str]

RETURNS DESCRIPTION
Message

The poll vote message.

RAISES DESCRIPTION
BuildPollVoteError

If there is an error building the poll vote.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_poll_vote(
    self, poll_info: MessageInfo, option_names: List[str]
) -> Message:
    """Builds a poll vote.

    :param poll_info: The information about the poll.
    :type poll_info: MessageInfo
    :param option_names: The names of the options to vote for.
    :type option_names: List[str]
    :return: The poll vote message.
    :rtype: Message
    :raises BuildPollVoteError: If there is an error building the poll vote.
    """
    option_names_proto = neonize_proto.ArrayString(
        data=option_names
    ).SerializeToString()
    poll_info_proto = poll_info.SerializeToString()
    bytes_ptr = await self.__client.BuildPollVote(
        self.uuid,
        poll_info_proto,
        len(poll_info_proto),
        option_names_proto,
        len(option_names_proto),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.BuildPollVoteReturnFunction.FromString(protobytes)
    if model.Error:
        raise BuildPollVoteError(model.Error)
    return model.PollVote

build_reaction async

Python
build_reaction(chat: JID, sender: JID, message_id: str, reaction: str) -> Message

This function builds a reaction message in a chat. It takes the chat and sender IDs, the message ID to which the reaction is being made, and the reaction itself as input. It then serializes the chat and sender IDs to strings, and calls the BuildReaction function of the client with these serialized IDs, the message ID, and the reaction. It finally returns the reaction message.

PARAMETER DESCRIPTION
chat

The ID of the chat in which the reaction is being made

TYPE: JID

sender

The ID of the sender making the reaction

TYPE: JID

message_id

The ID of the message to which the reaction is being made

TYPE: str

reaction

The reaction being made

TYPE: str

RETURNS DESCRIPTION
Message

The reaction message

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_reaction(
    self, chat: JID, sender: JID, message_id: str, reaction: str
) -> Message:
    """
    This function builds a reaction message in a chat. It takes the chat and sender IDs,
    the message ID to which the reaction is being made, and the reaction itself as input.
    It then serializes the chat and sender IDs to strings, and calls the BuildReaction
    function of the client with these serialized IDs, the message ID, and the reaction.
    It finally returns the reaction message.

    :param chat: The ID of the chat in which the reaction is being made
    :type chat: JID
    :param sender: The ID of the sender making the reaction
    :type sender: JID
    :param message_id: The ID of the message to which the reaction is being made
    :type message_id: str
    :param reaction: The reaction being made
    :type reaction: str
    :return: The reaction message
    :rtype: Message
    """
    sender_proto = sender.SerializeToString()
    chat_proto = chat.SerializeToString()
    bytes_ptr = await self.__client.BuildReaction(
        self.uuid,
        chat_proto,
        len(chat_proto),
        sender_proto,
        len(sender_proto),
        message_id.encode(),
        reaction.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = BuildMessageReturnFunction.FromString(protobytes)
    if result.Error:
        raise SendMessageError(result.Error)
    return result.Message

build_revoke async

Python
build_revoke(chat: JID, sender: JID, message_id: str) -> Message

Builds a message to revoke a previous message.

PARAMETER DESCRIPTION
chat

The JID (Jabber Identifier) of the chat where the message should be revoked.

TYPE: JID

sender

The JID of the sender of the message to be revoked.

TYPE: JID

message_id

The unique identifier of the message to be revoked.

TYPE: str

RETURNS DESCRIPTION
Message

The constructed Message object for revoking the specified message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_revoke(self, chat: JID, sender: JID, message_id: str) -> Message:
    """Builds a message to revoke a previous message.

    :param chat: The JID (Jabber Identifier) of the chat where the message should be revoked.
    :type chat: JID
    :param sender: The JID of the sender of the message to be revoked.
    :type sender: JID
    :param message_id: The unique identifier of the message to be revoked.
    :type message_id: str
    :return: The constructed Message object for revoking the specified message.
    :rtype: Message
    """
    return build_revoke(chat, sender, message_id, (await self.get_me()).JID)

build_sticker_message async

Python
build_sticker_message(file: Union[str, bytes], quoted: Optional[Message] = None, name: str = '', packname: str = '', crop: bool = False, enforce_not_broken: bool = False, animated_gif: bool = False, passthrough: bool = False) -> Message

This function builds a sticker message from a given image or video file. The file is converted to a webp format and uploaded to a server. The resulting URL and other metadata are used to construct the sticker message.

PARAMETER DESCRIPTION
file

The path to the image or video file or the file data in bytes

TYPE: Union[str, bytes]

quoted

A message that the sticker message is a reply to, defaults to None

TYPE: Optional[Message] DEFAULT: None

name

The name of the sticker, defaults to ""

TYPE: str DEFAULT: ''

packname

The name of the sticker pack, defaults to ""

TYPE: str DEFAULT: ''

crop

Crop-center the image, defaults to False

TYPE: bool DEFAULT: False

enforce_not_broken

Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False

TYPE: bool DEFAULT: False

animated_gif

Ensure transparent media are properly processed, defaults to False

TYPE: bool DEFAULT: False

passthrough

Don't process sticker, send as is, defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Message

The constructed sticker message

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_sticker_message(
    self,
    file: typing.Union[str, bytes],
    quoted: Optional[neonize_proto.Message] = None,
    name: str = "",
    packname: str = "",
    crop: bool = False,
    enforce_not_broken: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
) -> Message:
    """
    This function builds a sticker message from a given image or video file.
    The file is converted to a webp format and uploaded to a server.
    The resulting URL and other metadata are used to construct the sticker message.

    :param file: The path to the image or video file or the file data in bytes
    :type file: typing.Union[str, bytes]
    :param quoted: A message that the sticker message is a reply to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :param name: The name of the sticker, defaults to ""
    :type name: str, optional
    :param packname: The name of the sticker pack, defaults to ""
    :type packname: str, optional
    :param crop: Crop-center the image, defaults to False
    :type crop: bool, optional
    :param enforce_not_broken: Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
    :type enforce_not_broken: bool, optional
    :param animated_gif: Ensure transparent media are properly processed, defaults to False
    :type animated_gif: bool, optional
    :param passthrough: Don't process sticker, send as is, defaults to False.
    :type passthrough: bool, optional
    :return: The constructed sticker message
    :rtype: Message
    """
    sticker = await get_bytes_from_name_or_url_async(file)
    animated = is_webm = is_webp = is_image = saved_exif = False
    mime = magic.from_buffer(sticker, mime=True)
    if mime == "image/webp":
        is_webp = True
        io_save = BytesIO(sticker)
        img = Image.open(io_save)
        if len(ImageSequence.all_frames(img)) < 2:
            is_image = True
    elif mime == "video/webm":
        is_webm = True
    elif (mime := mime.split("/"))[0] == "image":
        is_image = True
    animated = not (is_image)
    if not passthrough and not animated_gif and is_image:
        io_save = BytesIO(sticker)
        stk = auto_sticker(io_save) if crop else original_sticker(io_save)
        io_save = BytesIO()
        # io_save.seek(0)
    elif not passthrough:
        animated = True
        sticker, saved_exif = await aio_convert_to_sticker(
            sticker, name, packname, enforce_not_broken, animated_gif, is_webm
        )
        if saved_exif:
            io_save = BytesIO(sticker)
        else:
            stk = Image.open(BytesIO(sticker))
            io_save = BytesIO()
    else:
        if not is_webp:
            raise ConvertStickerError(
                "File is not a webp, which is required for passthrough."
            )
    if not (passthrough or saved_exif):
        stk.save(
            io_save,
            format="webp",
            exif=add_exif(name, packname),
            save_all=True,
            loop=0,
        )
    upload = await self.upload(io_save.getvalue())
    message = Message(
        stickerMessage=StickerMessage(
            URL=upload.url,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(io_save.getvalue(), mime=True),
            isAnimated=animated,
        )
    )
    if quoted:
        message.stickerMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_sticker async

Python
send_sticker(to: JID, file: Union[str, bytes], quoted: Optional[Message] = None, name: str = '', packname: str = '', crop: bool = False, enforce_not_broken: bool = False, animated_gif: bool = False, passthrough: bool = False, add_msg_secret: bool = False) -> SendResponse

Send a sticker to a specific JID.

PARAMETER DESCRIPTION
to

The JID to send the sticker to.

TYPE: JID

file

The file path of the sticker or the sticker data in bytes.

TYPE: Union[str, bytes]

quoted

The quoted message, if any, defaults to None.

TYPE: Optional[Message] DEFAULT: None

name

The name of the sticker, defaults to "".

TYPE: str DEFAULT: ''

packname

The name of the sticker pack, defaults to "".

TYPE: str DEFAULT: ''

crop

Whether to crop-center the image, defaults to False

TYPE: bool DEFAULT: False

enforce_not_broken

Whether to enforce non-broken stickers by constraining sticker size to WA limits, defaults to False

TYPE: bool DEFAULT: False

animated_gif

Ensure transparent media are properly processed, defaults to False

TYPE: bool DEFAULT: False

passthrough

Don't process sticker, send as is, defaults to False.

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

The response from the send message function.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_sticker(
    self,
    to: JID,
    file: typing.Union[str, bytes],
    quoted: Optional[neonize_proto.Message] = None,
    name: str = "",
    packname: str = "",
    crop: bool = False,
    enforce_not_broken: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """
    Send a sticker to a specific JID.

    :param to: The JID to send the sticker to.
    :type to: JID
    :param file: The file path of the sticker or the sticker data in bytes.
    :type file: typing.Union[str, bytes]
    :param quoted: The quoted message, if any, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param name: The name of the sticker, defaults to "".
    :type name: str, optional
    :param packname: The name of the sticker pack, defaults to "".
    :type packname: str, optional
    :param crop: Whether to crop-center the image, defaults to False
    :type crop: bool, optional
    :param enforce_not_broken: Whether to enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
    :type enforce_not_broken: bool, optional
    :param animated_gif: Ensure transparent media are properly processed, defaults to False
    :type animated_gif: bool, optional
    :param passthrough: Don't process sticker, send as is, defaults to False.
    :type passthrough: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: The response from the send message function.
    :rtype: SendResponse
    """
    return await self.send_message(
        to,
        await self.build_sticker_message(
            file,
            quoted,
            name,
            packname,
            crop,
            enforce_not_broken,
            animated_gif,
            passthrough,
        ),
        add_msg_secret=add_msg_secret,
    )

send_stickerpack async

Python
send_stickerpack(to: JID, files: list, quoted: Optional[Message] = None, packname: str = 'Sticker pack', publisher: str = '', crop: bool = False, animated_gif: bool = False, passthrough: bool = False, add_msg_secret: bool = False) -> List[SendResponse]

Send a sticker pack to a specific JID.

PARAMETER DESCRIPTION
to

The JID to send the sticker to.

TYPE: JID

files

A list of file paths of the stickers or a list of stickers data in bytes.

TYPE: list

quoted

The quoted message, if any, defaults to None.

TYPE: Optional[Message] DEFAULT: None

packname

The name of the sticker pack, defaults to "Sticker pack".

TYPE: str DEFAULT: 'Sticker pack'

publisher

The name of the publisher, defaults to "".

TYPE: str DEFAULT: ''

crop

Whether to crop-center the image, defaults to False

TYPE: bool DEFAULT: False

add_msg_secret

Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
List[SendResponse]

A list of response(s) from the send message function.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_stickerpack(
    self,
    to: JID,
    files: list,
    quoted: Optional[neonize_proto.Message] = None,
    packname: str = "Sticker pack",
    publisher: str = "",
    crop: bool = False,
    animated_gif: bool = False,
    passthrough: bool = False,
    add_msg_secret: bool = False,
) -> List[SendResponse]:
    """
    Send a sticker pack to a specific JID.

    :param to: The JID to send the sticker to.
    :type to: JID
    :param files:  A list of file paths of the stickers or a list of stickers data in bytes.
    :type file: List[typing.Union[str, bytes]]
    :param quoted: The quoted message, if any, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param packname: The name of the sticker pack, defaults to "Sticker pack".
    :type packname: str, optional
    :param publisher: The name of the publisher, defaults to "".
    :type publisher: str, optional
    :param crop: Whether to crop-center the image, defaults to False
    :type crop: bool, optional
    :param add_msg_secret: Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A list of response(s) from the send message function.
    :rtype: List[SendResponse]
    """
    responses = []
    msgs = await self.build_stickerpack_message(
        files, quoted, packname, publisher, crop, animated_gif, passthrough
    )
    for msg in msgs:
        response = await self.send_message(
            to,
            msg,
            add_msg_secret=add_msg_secret,
        )
        responses.append(response)
    return responses

build_video_message async

Python
build_video_message(file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, gifplayback: bool = False, is_gif: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

This function is used to build a video message. It uploads a video file, extracts necessary information, and constructs a message with the given parameters.

PARAMETER DESCRIPTION
file

The file path or bytes of the video file to be uploaded.

TYPE: str | bytes

caption

The caption to be added to the video message, defaults to None

TYPE: Optional[str] DEFAULT: None

quoted

A message that the video message is in response to, defaults to None

TYPE: Optional[Message] DEFAULT: None

viewonce

A flag indicating if the video message can be viewed only once, defaults to False

TYPE: bool DEFAULT: False

gifplayback

Optional. Whether the video should be sent as gif. Defaults to False.

TYPE: bool DEFAULT: False

is_gif

Optional. Whether the video to be sent is a gif. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Message

A video message with the given parameters.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_video_message(
    self,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    gifplayback: bool = False,
    is_gif: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """
    This function is used to build a video message. It uploads a video file, extracts necessary information,
    and constructs a message with the given parameters.

    :param file: The file path or bytes of the video file to be uploaded.
    :type file: str | bytes
    :param caption: The caption to be added to the video message, defaults to None
    :type caption: Optional[str], optional
    :param quoted: A message that the video message is in response to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :param viewonce: A flag indicating if the video message can be viewed only once, defaults to False
    :type viewonce: bool, optional
    :param gifplayback: Optional. Whether the video should be sent as gif. Defaults to False.
    :type gifplayback: bool, optional
    :param is_gif: Optional. Whether the video to be sent is a gif. Defaults to False.
    :type is_gif: bool, optional
    :return: A video message with the given parameters.
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :rtype: Message
    """
    io = BytesIO(await get_bytes_from_name_or_url_async(file))
    io.seek(0)
    buff = io.read()
    if is_gif:
        async with AFFmpeg(file) as ffmpeg:
            buff = file = await ffmpeg.gif_to_mp4()
    async with AFFmpeg(file) as ffmpeg:
        duration = int((await ffmpeg.extract_info()).format.duration)
        thumbnail = await ffmpeg.extract_thumbnail()
    upload = await self.upload(buff)
    message = Message(
        videoMessage=VideoMessage(
            URL=upload.url,
            caption=caption,
            gifPlayback=gifplayback,
            seconds=duration,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(buff, mime=True),
            JPEGThumbnail=thumbnail,
            thumbnailDirectPath=upload.DirectPath,
            thumbnailEncSHA256=upload.FileEncSHA256,
            thumbnailSHA256=upload.FileSHA256,
            viewOnce=viewonce,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(await self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.videoMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_video async

Python
send_video(to: JID, file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, gifplayback: bool = False, is_gif: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends a video to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the video.

TYPE: str | bytes

caption

Optional. The caption of the video. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the video is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Optional. Whether the video should be viewonce. Defaults to False.

TYPE: bool DEFAULT: False

gifplayback

Optional. Whether the video should be sent as gif. Defaults to False.

TYPE: bool DEFAULT: False

is_gif

Optional. Whether the video to be sent is a gif. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the video sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_video(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    gifplayback: bool = False,
    is_gif: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends a video to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the video.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the video. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the video is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param viewonce: Optional. Whether the video should be viewonce. Defaults to False.
    :type viewonce: bool, optional
    :param gifplayback: Optional. Whether the video should be sent as gif. Defaults to False.
    :type gifplayback: bool, optional
    :param is_gif: Optional. Whether the video to be sent is a gif. Defaults to False.
    :type is_gif: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the video sending process.
    :rtype: SendResponse
    """
    return await self.send_message(
        to,
        await self.build_video_message(
            file,
            caption,
            quoted,
            viewonce,
            gifplayback,
            is_gif,
            ghost_mentions,
            mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

build_image_message async

Python
build_image_message(file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False) -> Message

This function builds an image message. It takes a file (either a string or bytes), an optional caption, an optional quoted message, and a boolean indicating whether the message should be viewed once. It then uploads the image, generates a thumbnail, and constructs the message with the given parameters and the information from the uploaded image.

PARAMETER DESCRIPTION
file

The image file to be uploaded and sent, either as a string URL or bytes.

TYPE: str | bytes

caption

The caption for the image message, defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

The message to be quoted in the image message, defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Whether the image message should be viewable only once, defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Message

The constructed image message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_image_message(
    self,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
) -> Message:
    """
    This function builds an image message. It takes a file (either a string or bytes),
    an optional caption, an optional quoted message, and a boolean indicating whether
    the message should be viewed once. It then uploads the image, generates a thumbnail,
    and constructs the message with the given parameters and the information from the
    uploaded image.

    :param file: The image file to be uploaded and sent, either as a string URL or bytes.
    :type file: str | bytes
    :param caption: The caption for the image message, defaults to None.
    :type caption: Optional[str], optional
    :param quoted: The message to be quoted in the image message, defaults to None.
    :type quoted: Optional[neonize_proto.Message], optional
    :param viewonce: Whether the image message should be viewable only once, defaults to False.
    :type viewonce: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :return: The constructed image message.
    :rtype: Message
    """
    n_file = await get_bytes_from_name_or_url_async(file)
    img = Image.open(BytesIO(n_file))
    img.thumbnail(AspectRatioMethod(*img.size, res=200))
    thumbnail = BytesIO()
    img_saveable = img if img.mode == "RGB" else img.convert("RGB")
    img_saveable.save(thumbnail, format="jpeg")
    upload = await self.upload(n_file)
    message = Message(
        imageMessage=ImageMessage(
            URL=upload.url,
            caption=caption,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(n_file, mime=True),
            JPEGThumbnail=thumbnail.getvalue(),
            thumbnailDirectPath=upload.DirectPath,
            thumbnailEncSHA256=upload.FileEncSHA256,
            thumbnailSHA256=upload.FileSHA256,
            viewOnce=viewonce,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(await self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.imageMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_image async

Python
send_image(to: JID, file: str | bytes, caption: Optional[str] = None, quoted: Optional[Message] = None, viewonce: bool = False, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends an image to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the image.

TYPE: str | bytes

caption

Optional. The caption of the image. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the image is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

viewonce

Optional. Whether the image should be viewonce. Defaults to False.

TYPE: bool DEFAULT: False

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the image sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_image(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    viewonce: bool = False,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends an image to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the image.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the image. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the image is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param viewonce: Optional. Whether the image should be viewonce. Defaults to False.
    :type viewonce: bool, optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the image sending process.
    :rtype: SendResponse
    """
    return await self.send_message(
        to,
        await self.build_image_message(
            file,
            caption,
            quoted,
            viewonce=viewonce,
            ghost_mentions=ghost_mentions,
            mentions_are_lids=mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

send_album async

Python
send_album(to: JID, files: list, caption: Optional[str] = None, quoted: Optional[Message] = None, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> List[SendResponse, List[SendResponse]]

Sends an album containing images, videos or both to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

files

A list containing either a file path (str), url (str) or binary data (bytes) representing the image/video.

TYPE: list

caption

Optional. The caption of the first media in the album. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the album is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
List[SendResponse, List[SendResponse]]

A function for handling the result of the album sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_album(
    self,
    to: JID,
    files: list,
    caption: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> List[SendResponse, List[SendResponse]]:
    """Sends an album containing images, videos or both to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param files: A list containing either a file path (str), url (str) or binary data (bytes) representing the image/video.
    :type file: List[typing.Union[str | bytes]]
    :param caption: Optional. The caption of the first media in the album. Defaults to None.
    :type caption: Optional[str], optional
    :param quoted: Optional. The message to which the album is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the album sending process.
    :rtype: List[SendResponse, List[SendResponse]]
    """
    image_count = video_count = 0
    medias = []
    for file in files:
        file = await get_bytes_from_name_or_url_async(file)
        mime = magic.from_buffer(file, mime=True)
        media_type = mime.split("/")[0]
        if media_type == "image":
            image_count += 1
        elif media_type == "video":
            video_count += 1
        else:
            _log_.warning(
                f"File with mime_type: {mime} was wrongly passed to send_album_message, ignoring…"
            )
            continue
        medias.append((file, media_type))
    if not (image_count or video_count):
        raise SendMessageError("No media found to send!")
    elif len(medias) < 2:
        raise SendMessageError("No enough media to send an album")
    message = Message(
        albumMessage=AlbumMessage(
            expectedImageCount=image_count,
            expectedVideoCount=video_count,
            contextInfo=ContextInfo(
                mentionedJID=self._parse_mention(
                    (ghost_mentions or caption), mentions_are_lids
                ),
                groupMentions=(await self._parse_group_mention(caption)),
            ),
        )
    )
    if quoted:
        message.albumMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    response = await self.send_message(to, message, add_msg_secret=add_msg_secret)
    msg_association = MessageAssociation(
        associationType=MessageAssociation.AssociationType.MEDIA_ALBUM,
        parentMessageKey=MessageKey(
            remoteJID=Jid2String(to),
            fromMe=True,
            ID=response.ID,
        ),
    )
    funcs = [
        self.build_album_content(
            file,
            media_type,
            msg_association,
            caption=caption,
            quoted=quoted,
            ghost_mentions=ghost_mentions,
            mentions_are_lids=mentions_are_lids,
        )
        for file, media_type in medias[:1]
    ]
    funcs.extend(
        [
            self.build_album_content(
                file, media_type, msg_association, quoted=quoted
            )
            for file, media_type in medias[1:]
        ]
    )
    messages = await asyncio.gather(*funcs)
    funcs = [
        self.send_message(to, message, add_msg_secret=add_msg_secret)
        for message in messages
    ]
    responses = await asyncio.gather(*funcs)
    return [response, responses]

build_audio_message async

Python
build_audio_message(file: str | bytes, ptt: bool = False, quoted: Optional[Message] = None) -> Message

This method builds an audio message from a given file or bytes.

PARAMETER DESCRIPTION
file

The audio file in string or bytes format to be converted into an audio message

TYPE: str | bytes

ptt

A boolean indicating if the audio message is a 'push to talk' message, defaults to False

TYPE: bool DEFAULT: False

quoted

A message that the audio message may be replying to, defaults to None

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
Message

The audio message built from the given parameters

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def build_audio_message(
    self,
    file: str | bytes,
    ptt: bool = False,
    quoted: Optional[neonize_proto.Message] = None,
) -> Message:
    """
    This method builds an audio message from a given file or bytes.

    :param file: The audio file in string or bytes format to be converted into an audio message
    :type file: str | bytes
    :param ptt: A boolean indicating if the audio message is a 'push to talk' message, defaults to False
    :type ptt: bool, optional
    :param quoted: A message that the audio message may be replying to, defaults to None
    :type quoted: Optional[neonize_proto.Message], optional
    :return: The audio message built from the given parameters
    :rtype: Message
    """
    io = BytesIO(await get_bytes_from_name_or_url_async(file))
    io.seek(0)
    buff = io.read()
    upload = await self.upload(buff)
    async with AFFmpeg(io.getvalue()) as ffmpeg:
        duration = int((await ffmpeg.extract_info()).format.duration)
    message = Message(
        audioMessage=AudioMessage(
            URL=upload.url,
            seconds=duration,
            directPath=upload.DirectPath,
            fileEncSHA256=upload.FileEncSHA256,
            fileLength=upload.FileLength,
            fileSHA256=upload.FileSHA256,
            mediaKey=upload.MediaKey,
            mimetype=magic.from_buffer(buff, mime=True),
            PTT=ptt,
        )
    )
    if quoted:
        message.audioMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return message

send_audio async

Python
send_audio(to: JID, file: str | bytes, ptt: bool = False, quoted: Optional[Message] = None, add_msg_secret: bool = False) -> SendResponse

Sends an audio to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the audio.

TYPE: str | bytes

ptt

Optional. Whether the audio should be ptt. Defaults to False.

TYPE: bool DEFAULT: False

quoted

Optional. The message to which the audio is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the audio sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_audio(
    self,
    to: JID,
    file: str | bytes,
    ptt: bool = False,
    quoted: Optional[neonize_proto.Message] = None,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends an audio to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the audio.
    :type file: typing.Union[str | bytes]
    :param ptt: Optional. Whether the audio should be ptt. Defaults to False.
    :type ptt: bool, optional
    :param quoted: Optional. The message to which the audio is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param add_msg_secret: Optional. Whether to  generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the audio sending process.
    :rtype: SendResponse
    """

    return await self.send_message(
        to,
        await self.build_audio_message(file, ptt, quoted),
        add_msg_secret=add_msg_secret,
    )

send_document async

Python
send_document(to: JID, file: str | bytes, caption: Optional[str] = None, title: Optional[str] = None, filename: Optional[str] = None, mimetype: Optional[str] = None, quoted: Optional[Message] = None, ghost_mentions: Optional[str] = None, mentions_are_lids: bool = False, add_msg_secret: bool = False) -> SendResponse

Sends a document to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

file

Either a file path (str), url (str) or binary data (bytes) representing the document.

TYPE: str | bytes

caption

Optional. The caption of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

title

Optional. The title of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

filename

Optional. The filename of the document. Defaults to None.

TYPE: Optional[str] DEFAULT: None

quoted

Optional. The message to which the document is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

ghost_mentions

List of users to tag silently (Takes precedence over auto detected mentions)

TYPE: Optional[str] DEFAULT: None

add_msg_secret

Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the document sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_document(
    self,
    to: JID,
    file: str | bytes,
    caption: Optional[str] = None,
    title: Optional[str] = None,
    filename: Optional[str] = None,
    mimetype: Optional[str] = None,
    quoted: Optional[neonize_proto.Message] = None,
    ghost_mentions: Optional[str] = None,
    mentions_are_lids: bool = False,
    add_msg_secret: bool = False,
) -> SendResponse:
    """Sends a document to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param file: Either a file path (str), url (str) or binary data (bytes) representing the document.
    :type file: typing.Union[str | bytes]
    :param caption: Optional. The caption of the document. Defaults to None.
    :type caption: Optional[str], optional
    :param title: Optional. The title of the document. Defaults to None.
    :type title: Optional[str], optional
    :param filename: Optional. The filename of the document. Defaults to None.
    :type filename: Optional[str], optional
    :param quoted: Optional. The message to which the document is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :param ghost_mentions: List of users to tag silently (Takes precedence over auto detected mentions)
    :type ghost_mentions: str, optional
    :param add_msg_secret: Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
    :type add_msg_secret: bool, optional
    :return: A function for handling the result of the document sending process.
    :rtype: SendResponse
    """
    return await self.send_message(
        to,
        await self.build_document_message(
            file,
            caption,
            title,
            filename,
            mimetype,
            quoted,
            ghost_mentions,
            mentions_are_lids,
        ),
        add_msg_secret=add_msg_secret,
    )

send_contact async

Python
send_contact(to: JID, contact_name: str, contact_number: str, quoted: Optional[Message] = None) -> SendResponse

Sends a contact to the specified recipient.

PARAMETER DESCRIPTION
to

The JID (Jabber Identifier) of the recipient.

TYPE: JID

contact_name

The name of the contact.

TYPE: str

contact_number

The number of the contact.

TYPE: str

quoted

Optional. The message to which the contact is a reply. Defaults to None.

TYPE: Optional[Message] DEFAULT: None

RETURNS DESCRIPTION
SendResponse

A function for handling the result of the contact sending process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_contact(
    self,
    to: JID,
    contact_name: str,
    contact_number: str,
    quoted: Optional[neonize_proto.Message] = None,
) -> SendResponse:
    """Sends a contact to the specified recipient.

    :param to: The JID (Jabber Identifier) of the recipient.
    :type to: JID
    :param contact_name: The name of the contact.
    :type contact_name: str
    :param contact_number: The number of the contact.
    :type contact_number: str
    :param quoted: Optional. The message to which the contact is a reply. Defaults to None.
    :type quoted: Optional[Message], optional
    :return: A function for handling the result of the contact sending process.
    :rtype: SendResponse
    """
    message = Message(
        contactMessage=ContactMessage(
            displayName=contact_name,
            vcard=gen_vcard(contact_name, contact_number),
        )
    )
    if quoted:
        message.contactMessage.contextInfo.MergeFrom(
            self._make_quoted_message(quoted)
        )
    return await self.send_message(to, message)

upload async

Python
upload(binary: bytes, media_type: Optional[MediaType] = None) -> UploadResponse

Uploads media content.

PARAMETER DESCRIPTION
binary

The binary data to be uploaded.

TYPE: bytes

media_type

Optional. The media type of the binary data, defaults to None.

TYPE: Optional[MediaType] DEFAULT: None

RETURNS DESCRIPTION
UploadResponse

An UploadResponse containing information about the upload.

RAISES DESCRIPTION
UploadError

Raised if there is an issue with the upload.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def upload(
    self, binary: bytes, media_type: Optional[MediaType] = None
) -> UploadResponse:
    """Uploads media content.

    :param binary: The binary data to be uploaded.
    :type binary: bytes
    :param media_type: Optional. The media type of the binary data, defaults to None.
    :type media_type: Optional[MediaType], optional
    :raises UploadError: Raised if there is an issue with the upload.
    :return: An UploadResponse containing information about the upload.
    :rtype: UploadResponse
    """
    if not media_type:
        mime = MediaType.from_magic(binary)
    else:
        mime = media_type
    bytes_ptr = await self.__client.Upload(
        self.uuid, binary, len(binary), mime.value
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    upload_model = UploadReturnFunction.FromString(protobytes)
    if upload_model.Error:
        raise UploadError(upload_model.Error)
    return upload_model.UploadResponse

download_any async

Python
download_any(message: Message) -> bytes
Python
download_any(message: Message, path: str) -> None
Python
download_any(message: Message, path: Optional[str] = None) -> typing.Union[None, bytes]

Downloads content from a message.

PARAMETER DESCRIPTION
message

The message containing the content to download.

TYPE: Message

path

Optional. The local path to save the downloaded content, defaults to None.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Union[None, bytes]

The downloaded content as bytes, or None if the content is not available.

RAISES DESCRIPTION
DownloadException

Raised if there is an issue with the download.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def download_any(
    self, message: Message, path: Optional[str] = None
) -> typing.Union[None, bytes]:
    """Downloads content from a message.

    :param message: The message containing the content to download.
    :type message: Message
    :param path: Optional. The local path to save the downloaded content, defaults to None.
    :type path: Optional[str], optional
    :raises DownloadException: Raised if there is an issue with the download.
    :return: The downloaded content as bytes, or None if the content is not available.
    :rtype: Union[None, bytes]
    """
    msg_protobuf = message.SerializeToString()
    bytes_ptr = await self.__client.DownloadAny(
        self.uuid, msg_protobuf, len(msg_protobuf)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    media = DownloadReturnFunction.FromString(protobytes)
    if media.Error:
        raise DownloadError(media.Error)
    if path:
        with open(path, "wb") as file:
            file.write(media.Binary)
    else:
        return media.Binary
    return None

download_media_with_path async

Python
download_media_with_path(direct_path: str, enc_file_hash: bytes, file_hash: bytes, media_key: bytes, file_length: int, media_type: MediaType, mms_type: MediaTypeToMMS) -> bytes

Downloads media with the given parameters and path. The media is downloaded from the path specified.

PARAMETER DESCRIPTION
direct_path

The direct path to the media to be downloaded.

TYPE: str

enc_file_hash

The encrypted hash of the file.

TYPE: bytes

file_hash

The hash of the file.

TYPE: bytes

media_key

The key of the media to be downloaded.

TYPE: bytes

file_length

The length of the file to be downloaded.

TYPE: int

media_type

The type of the media to be downloaded.

TYPE: MediaType

mms_type

The type of the MMS to be downloaded.

TYPE: MediaTypeToMMS

RETURNS DESCRIPTION
bytes

The downloaded media in bytes.

RAISES DESCRIPTION
DownloadError

If there is an error in the download process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def download_media_with_path(
    self,
    direct_path: str,
    enc_file_hash: bytes,
    file_hash: bytes,
    media_key: bytes,
    file_length: int,
    media_type: MediaType,
    mms_type: MediaTypeToMMS,
) -> bytes:
    """
    Downloads media with the given parameters and path. The media is downloaded from the path specified.

    :param direct_path: The direct path to the media to be downloaded.
    :type direct_path: str
    :param enc_file_hash: The encrypted hash of the file.
    :type enc_file_hash: bytes
    :param file_hash: The hash of the file.
    :type file_hash: bytes
    :param media_key: The key of the media to be downloaded.
    :type media_key: bytes
    :param file_length: The length of the file to be downloaded.
    :type file_length: int
    :param media_type: The type of the media to be downloaded.
    :type media_type: MediaType
    :param mms_type: The type of the MMS to be downloaded.
    :type mms_type: str
    :raises DownloadError: If there is an error in the download process.
    :return: The downloaded media in bytes.
    :rtype: bytes
    """
    bytes_ptr = await self.__client.DownloadMediaWithPath(
        self.uuid,
        direct_path.encode(),
        enc_file_hash,
        len(enc_file_hash),
        file_hash,
        len(file_hash),
        media_key,
        len(media_key),
        file_length,
        media_type.value,
        mms_type.value.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.DownloadReturnFunction.FromString(protobytes)
    if model.Error:
        raise DownloadError(model.Error)
    return model.Binary

generate_message_id async

Python
generate_message_id() -> str

Generates a unique identifier for a message.

RETURNS DESCRIPTION
str

A string representing the unique identifier for the message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def generate_message_id(self) -> str:
    """Generates a unique identifier for a message.

    :return: A string representing the unique identifier for the message.
    :rtype: str
    """
    return (await self.__client.GenerateMessageID(self.uuid)).decode()

send_chat_presence async

Python
send_chat_presence(jid: JID, state: ChatPresence, media: ChatPresenceMedia) -> str

Sends chat presence information.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the chat.

TYPE: JID

state

The chat presence state.

TYPE: ChatPresence

media

The chat presence media information.

TYPE: ChatPresenceMedia

RETURNS DESCRIPTION
str

A string indicating the result or status of the presence information sending.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_chat_presence(
    self, jid: JID, state: ChatPresence, media: ChatPresenceMedia
) -> str:
    """Sends chat presence information.

    :param jid: The JID (Jabber Identifier) of the chat.
    :type jid: JID
    :param state: The chat presence state.
    :type state: ChatPresence
    :param media: The chat presence media information.
    :type media: ChatPresenceMedia
    :return: A string indicating the result or status of the presence information sending.
    :rtype: str
    """
    jidbyte = jid.SerializeToString()
    return (
        await self.__client.SendChatPresence(
            self.uuid, jidbyte, len(jidbyte), state.value, media.value
        )
    ).decode()

is_on_whatsapp async

Python
is_on_whatsapp(*numbers: str) -> Sequence[IsOnWhatsAppResponse]

This function checks if the provided phone numbers are registered with WhatsApp.

PARAMETER DESCRIPTION
numbers

A series of phone numbers to be checked.

TYPE: str DEFAULT: ()

RETURNS DESCRIPTION
Sequence[IsOnWhatsAppResponse]

A list of responses, each indicating whether the corresponding number is registered with WhatsApp.

RAISES DESCRIPTION
IsOnWhatsAppError

If an error occurs while verifying the phone numbers.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def is_on_whatsapp(self, *numbers: str) -> Sequence[IsOnWhatsAppResponse]:
    """
    This function checks if the provided phone numbers are registered with WhatsApp.

    :param numbers: A series of phone numbers to be checked.
    :type numbers: str
    :raises IsOnWhatsAppError: If an error occurs while verifying the phone numbers.
    :return: A list of responses, each indicating whether the corresponding number is registered with WhatsApp.
    :rtype: Sequence[IsOnWhatsAppResponse]
    """
    if numbers:
        numbers_buf = " ".join(numbers).encode()
        bytes_ptr = await self.__client.IsOnWhatsApp(
            self.uuid, numbers_buf, len(numbers_buf)
        )
        protobytes = bytes_ptr.contents.get_bytes()
        free_bytes(bytes_ptr)
        model = IsOnWhatsAppReturnFunction.FromString(protobytes)
        if model.Error:
            raise IsOnWhatsAppError(model.Error)
        return model.IsOnWhatsAppResponse
    return []

get_user_info async

Python
get_user_info(*jid: JID) -> RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]

This function retrieves user information given a set of JID. It serializes the JID into a string, gets the user information from the client, deserializes the returned information, checks for any errors, and finally returns the user information.

PARAMETER DESCRIPTION
jid

JID of the users to retrieve information from

TYPE: JID DEFAULT: ()

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]

The user information for each JID

RAISES DESCRIPTION
GetUserInfoError

If there is an error in the model returned by the client

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_user_info(
    self, *jid: JID
) -> RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]:
    """
    This function retrieves user information given a set of JID. It serializes the JID into a string,
    gets the user information from the client, deserializes the returned information, checks for any errors,
    and finally returns the user information.

    :param jid: JID of the users to retrieve information from
    :type jid: JID
    :raises GetUserInfoError: If there is an error in the model returned by the client
    :return: The user information for each JID
    :rtype: RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]
    """
    jidbuf = JIDArray(JIDS=jid).SerializeToString()
    bytes_ptr = await self.__client.GetUserInfo(self.uuid, jidbuf, len(jidbuf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetUserInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetUserInfoError(model.Error)
    return model.UsersInfo

get_group_info async

Python
get_group_info(jid: JID) -> GroupInfo

Retrieves information about a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

RETURNS DESCRIPTION
GroupInfo

Information about the specified group.

RAISES DESCRIPTION
GetGroupInfoError

Raised if there is an issue retrieving group information.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_group_info(self, jid: JID) -> GroupInfo:
    """Retrieves information about a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :raises GetGroupInfoError: Raised if there is an issue retrieving group information.
    :return: Information about the specified group.
    :rtype: GroupInfo
    """
    jidbuf = jid.SerializeToString()
    bytes_ptr = await self.__client.GetGroupInfo(
        self.uuid,
        jidbuf,
        len(jidbuf),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo
Python
get_group_info_from_link(code: str) -> GroupInfo

Retrieves group information from a given link.

PARAMETER DESCRIPTION
code

The link code.

TYPE: str

RETURNS DESCRIPTION
GroupInfo

An object containing the group information.

RAISES DESCRIPTION
GetGroupInfoError

If there is an error retrieving the group information.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_group_info_from_link(self, code: str) -> GroupInfo:
    """Retrieves group information from a given link.

    :param code: The link code.
    :type code: str
    :return: An object containing the group information.
    :rtype: GroupInfo
    :raises GetGroupInfoError: If there is an error retrieving the group information.
    """
    bytes_ptr = await self.__client.GetGroupInfoFromLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo

get_group_info_from_invite async

Python
get_group_info_from_invite(jid: JID, inviter: JID, code: str, expiration: int) -> GroupInfo

Retrieves group information from an invite.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group.

TYPE: JID

inviter

The JID of the user who sent the invite.

TYPE: JID

code

The invite code.

TYPE: str

expiration

The expiration time of the invite.

TYPE: int

RETURNS DESCRIPTION
GroupInfo

The group information.

RAISES DESCRIPTION
GetGroupInfoError

If there is an error retrieving the group information.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_group_info_from_invite(
    self, jid: JID, inviter: JID, code: str, expiration: int
) -> GroupInfo:
    """Retrieves group information from an invite.

    :param jid: The JID (Jabber ID) of the group.
    :type jid: JID
    :param inviter: The JID of the user who sent the invite.
    :type inviter: JID
    :param code: The invite code.
    :type code: str
    :param expiration: The expiration time of the invite.
    :type expiration: int

    :return: The group information.
    :rtype: GroupInfo

    :raises GetGroupInfoError: If there is an error retrieving the group information.
    """
    jidbyte = jid.SerializeToString()
    inviterbyte = inviter.SerializeToString()
    bytes_ptr = await self.__client.GetGroupInfoFromInvite(
        self.uuid,
        jidbyte,
        len(jidbyte),
        inviterbyte,
        len(inviterbyte),
        code.encode(),
        expiration,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInfoError(model.Error)
    return model.GroupInfo

set_group_name async

Python
set_group_name(jid: JID, name: str) -> str

Sets the name of a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

name

The new name to be set for the group.

TYPE: str

RETURNS DESCRIPTION
str

A string indicating the result or an error status. Empty string if successful.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_group_name(self, jid: JID, name: str) -> str:
    """Sets the name of a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param name: The new name to be set for the group.
    :type name: str
    :return: A string indicating the result or an error status. Empty string if successful.
    :rtype: str
    """
    jidbuf = jid.SerializeToString()
    return (
        await self.__client.SetGroupName(
            self.uuid,
            jidbuf,
            len(jidbuf),
            ctypes.create_string_buffer(name.encode()),
        )
    ).decode()

set_group_photo async

Python
set_group_photo(jid: JID, file_or_bytes: Union[str, bytes]) -> str

Sets the photo of a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

file_or_bytes

Either a file path (str) or binary data (bytes) representing the group photo.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
str

A string indicating the result or an error status.

RAISES DESCRIPTION
SetGroupPhotoError

Raised if there is an issue setting the group photo.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_group_photo(
    self, jid: JID, file_or_bytes: typing.Union[str, bytes]
) -> str:
    """Sets the photo of a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param file_or_bytes: Either a file path (str) or binary data (bytes) representing the group photo.
    :type file_or_bytes: typing.Union[str, bytes]
    :raises SetGroupPhotoError: Raised if there is an issue setting the group photo.
    :return: A string indicating the result or an error status.
    :rtype: str
    """
    data = get_bytes_from_name_or_url(file_or_bytes)
    jid_buf = jid.SerializeToString()
    bytes_ptr = await self.__client.SetGroupPhoto(
        self.uuid, jid_buf, len(jid_buf), data, len(data)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SetGroupPhotoReturnFunction.FromString(protobytes)
    if model.Error:
        raise SetGroupPhotoError(model.Error)
    return model.PictureID

set_profile_photo async

Python
set_profile_photo(file_or_bytes: Union[str, bytes]) -> str

Sets profile photo.

PARAMETER DESCRIPTION
file_or_bytes

Either a file path (str) or binary data (bytes) representing the group photo.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
str

A string indicating the result or an error status.

RAISES DESCRIPTION
SetGroupPhotoError

Raised if there is an issue setting the profile photo.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_profile_photo(self, file_or_bytes: typing.Union[str, bytes]) -> str:
    """Sets profile photo.

    :param file_or_bytes: Either a file path (str) or binary data (bytes) representing the group photo.
    :type file_or_bytes: typing.Union[str, bytes]
    :raises SetGroupPhotoError: Raised if there is an issue setting the profile photo.
    :return: A string indicating the result or an error status.
    :rtype: str
    """
    data = get_bytes_from_name_or_url(file_or_bytes)
    bytes_ptr = await self.__client.SetProfilePhoto(self.uuid, data, len(data))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SetGroupPhotoReturnFunction.FromString(protobytes)
    if model.Error:
        raise SetGroupPhotoError(model.Error)
    return model.PictureID

get_lid_from_pn async

Python
get_lid_from_pn(jid: JID) -> JID

Retrieves the matching lid from the supplied jid.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) (pn) of the target user.

TYPE: JID

RETURNS DESCRIPTION
JID

The lid (hidden user) matching the supplied jid.

RAISES DESCRIPTION
GetJIDFromStoreError

Raised if there is an issue getting the lid from the given jid.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_lid_from_pn(self, jid: JID) -> JID:
    """Retrieves the matching lid from the supplied jid.

    :param jid: The JID (Jabber Identifier) (pn) of the target user.
    :type jid: JID
    :raises GetJIDFromStoreError: Raised if there is an issue getting the lid from the given jid.
    :return: The lid (hidden user) matching the supplied jid.
    :rtype: JID
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = await self.__client.GetLIDFromPN(self.uuid, jid_buf, len(jid_buf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetJIDFromStoreReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJIDFromStoreError(model.Error)
    return model.Jid

get_pn_from_lid async

Python
get_pn_from_lid(jid: JID) -> JID

Retrieves the matching jid from the supplied lid.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) (lid) of the target user.

TYPE: JID

RETURNS DESCRIPTION
JID

The jid (phone number) matching the supplied lid.

RAISES DESCRIPTION
GetJIDFromStoreError

Raised if there is an issue getting the jid from the given lid.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_pn_from_lid(self, jid: JID) -> JID:
    """Retrieves the matching jid from the supplied lid.

    :param jid: The JID (Jabber Identifier) (lid) of the target user.
    :type jid: JID
    :raises GetJIDFromStoreError: Raised if there is an issue getting the jid from the given lid.
    :return: The jid (phone number) matching the supplied lid.
    :rtype: JID
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = await self.__client.GetPNFromLID(self.uuid, jid_buf, len(jid_buf))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetJIDFromStoreReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJIDFromStoreError(model.Error)
    return model.Jid

pin_message async

Python
pin_message(chat_jid: JID, sender_jid: JID, message_id: str, seconds: int)

Currently Non-functional

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def pin_message(
    self, chat_jid: JID, sender_jid: JID, message_id: str, seconds: int
):
    """
    Currently Non-functional
    """
    chat_buf = chat_jid.SerializeToString()
    sender_buf = sender_jid.SerializeToString()
    bytes_ptr = await self.__client.PinMessage(
        self.uuid,
        chat_buf,
        len(chat_buf),
        sender_buf,
        len(sender_buf),
        message_id.encode(),
        seconds,
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = SendMessageReturnFunction.FromString(protobytes)
    if model.Error:
        raise SendMessageError(model.Error)
    return model.SendResponse

leave_group async

Python
leave_group(jid: JID) -> str

Leaves a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the target group.

TYPE: JID

RETURNS DESCRIPTION
str

A string indicating the result or an error status. Empty string if successful.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def leave_group(self, jid: JID) -> str:
    """Leaves a group.

    :param jid: The JID (Jabber Identifier) of the target group.
    :type jid: JID
    :return: A string indicating the result or an error status. Empty string if successful.
    :rtype: str
    """
    jid_buf = jid.SerializeToString()
    return (
        await self.__client.LeaveGroup(self.uuid, jid_buf, len(jid_buf))
    ).decode()
Python
get_group_invite_link(jid: JID, revoke: bool = False) -> str

Gets or revokes the invite link for a group.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the group.

TYPE: JID

revoke

Optional. If True, revokes the existing invite link; if False, gets the invite link. Defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

The group invite link or an error status.

RAISES DESCRIPTION
GetGroupInviteLinkError

Raised if there is an issue getting or revoking the invite link.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_group_invite_link(self, jid: JID, revoke: bool = False) -> str:
    """Gets or revokes the invite link for a group.

    :param jid: The JID (Jabber Identifier) of the group.
    :type jid: JID
    :param revoke: Optional. If True, revokes the existing invite link; if False, gets the invite link. Defaults to False.
    :type revoke: bool, optional
    :raises GetGroupInviteLinkError: Raised if there is an issue getting or revoking the invite link.
    :return: The group invite link or an error status.
    :rtype: str
    """
    jid_buf = jid.SerializeToString()
    bytes_ptr = await self.__client.GetGroupInviteLink(
        self.uuid, jid_buf, len(jid_buf), revoke
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInviteLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetGroupInviteLinkError(model.Error)
    return model.InviteLink
Python
join_group_with_link(code: str) -> JID

Join a group using an invite link.

PARAMETER DESCRIPTION
code

The invite code or link for joining the group.

TYPE: str

RETURNS DESCRIPTION
JID

The JID (Jabber Identifier) of the joined group.

RAISES DESCRIPTION
InviteLinkError

Raised if the group membership is pending approval or if the link is invalid.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def join_group_with_link(self, code: str) -> JID:
    """Join a group using an invite link.

    :param code: The invite code or link for joining the group.
    :type code: str
    :raises InviteLinkError: Raised if the group membership is pending approval or if the link is invalid.
    :return: The JID (Jabber Identifier) of the joined group.
    :rtype: JID
    """
    bytes_ptr = await self.__client.JoinGroupWithLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = JoinGroupWithLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise InviteLinkError(model.Error)
    return model.Jid

join_group_with_invite async

Python
join_group_with_invite(jid: JID, inviter: JID, code: str, expiration: int)

This function allows a user to join a group in a chat application using an invite. It uses the JID (Jabber ID) of the group, the JID of the inviter, an invitation code, and an expiration time for the code.

PARAMETER DESCRIPTION
jid

The JID of the group to join.

TYPE: JID

inviter

The JID of the person who sent the invite.

TYPE: JID

code

The invitation code.

TYPE: str

expiration

The expiration time of the invitation code in seconds.

TYPE: int

RAISES DESCRIPTION
JoinGroupWithInviteError

If there is an error in joining the group, such as an invalid code or expired invitation.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def join_group_with_invite(
    self, jid: JID, inviter: JID, code: str, expiration: int
):
    """
    This function allows a user to join a group in a chat application using an invite.
    It uses the JID (Jabber ID) of the group, the JID of the inviter, an invitation code, and an expiration time for the code.

    :param jid: The JID of the group to join.
    :type jid: JID
    :param inviter: The JID of the person who sent the invite.
    :type inviter: JID
    :param code: The invitation code.
    :type code: str
    :param expiration: The expiration time of the invitation code in seconds.
    :type expiration: int
    :raises JoinGroupWithInviteError: If there is an error in joining the group, such as an invalid code or expired invitation.
    """
    jidbytes = jid.SerializeToString()
    inviterbytes = inviter.SerializeToString()
    err = (
        await self.__client.JoinGroupWithInvite(
            self.uuid,
            jidbytes,
            len(jidbytes),
            inviterbytes,
            len(inviterbytes),
            code.encode(),
            expiration,
        )
    ).decode()
    if err:
        raise JoinGroupWithInviteError(err)
Python
link_group(parent: JID, child: JID)

Links a child group to a parent group.

PARAMETER DESCRIPTION
parent

The JID of the parent group

TYPE: JID

child

The JID of the child group

TYPE: JID

RAISES DESCRIPTION
LinkGroupError

If there is an error while linking the groups

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def link_group(self, parent: JID, child: JID):
    """
    Links a child group to a parent group.

    :param parent: The JID of the parent group
    :type parent: JID
    :param child: The JID of the child group
    :type child: JID
    :raises LinkGroupError: If there is an error while linking the groups
    """
    parent_bytes = parent.SerializeToString()
    child_bytes = child.SerializeToString()
    err = (
        await self.__client.LinkGroup(
            self.uuid,
            parent_bytes,
            len(parent_bytes),
            child_bytes,
            len(child_bytes),
        )
    ).decode()
    if err:
        raise LinkGroupError(err)

mark_read async

Python
mark_read(*message_ids: str, chat: JID, sender: JID, receipt: ReceiptType, timestamp: Optional[int] = None)

Marks the specified messages as read.

PARAMETER DESCRIPTION
message_ids

Identifiers of the messages to mark as read.

TYPE: str DEFAULT: ()

chat

The JID of the chat.

TYPE: JID

sender

The JID of the sender.

TYPE: JID

receipt

The type of receipt indicating the message status.

TYPE: ReceiptType

timestamp

The timestamp of the read action, defaults to None.

TYPE: Optional[int] DEFAULT: None

RAISES DESCRIPTION
MarkReadError

If there is an error marking messages as read.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def mark_read(
    self,
    *message_ids: str,
    chat: JID,
    sender: JID,
    receipt: ReceiptType,
    timestamp: Optional[int] = None,
):
    """Marks the specified messages as read.

    :param message_ids: Identifiers of the messages to mark as read.
    :type message_ids: str
    :param chat: The JID of the chat.
    :type chat: JID
    :param sender: The JID of the sender.
    :type sender: JID
    :param receipt: The type of receipt indicating the message status.
    :type receipt: ReceiptType
    :param timestamp: The timestamp of the read action, defaults to None.
    :type timestamp: Optional[int], optional
    :raises MarkReadError: If there is an error marking messages as read.
    """
    chat_proto = chat.SerializeToString()
    sender_proto = sender.SerializeToString()
    timestamp_args = int(time.time()) if timestamp is None else timestamp
    err = await self.__client.MarkRead(
        self.uuid,
        " ".join(message_ids).encode(),
        timestamp_args,
        chat_proto,
        len(chat_proto),
        sender_proto,
        len(sender_proto),
        receipt.value,
    )
    if err:
        raise MarkReadError(err.decode())

newsletter_mark_viewed async

Python
newsletter_mark_viewed(jid: JID, message_server_ids: List[MessageServerID])

Marks the specified newsletters as viewed by the user with the given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the user who has viewed the newsletters.

TYPE: JID

message_server_ids

List of server IDs of the newsletters that have been viewed.

TYPE: List[MessageServerID]

RAISES DESCRIPTION
NewsletterMarkViewedError

If an error occurs while marking the newsletters as viewed.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def newsletter_mark_viewed(
    self, jid: JID, message_server_ids: List[MessageServerID]
):
    """
    Marks the specified newsletters as viewed by the user with the given JID.

    :param jid: The JID (Jabber ID) of the user who has viewed the newsletters.
    :type jid: JID
    :param message_server_ids: List of server IDs of the newsletters that have been viewed.
    :type message_server_ids: List[MessageServerID]
    :raises NewsletterMarkViewedError: If an error occurs while marking the newsletters as viewed.
    """
    servers = struct.pack(f"{len(message_server_ids)}b", *message_server_ids)
    jid_proto = jid.SerializeToString()
    err = await self.__client.NewsletterMarkViewed(
        self.uuid, jid_proto, len(jid_proto), servers, len(servers)
    )
    if err:
        raise NewsletterMarkViewedError(err)

newsletter_send_reaction async

Python
newsletter_send_reaction(jid: JID, message_server_id: MessageServerID, reaction: str, message_id: str)

Sends a reaction to a newsletter.

PARAMETER DESCRIPTION
jid

The unique identifier for the recipient of the newsletter.

TYPE: JID

message_server_id

The unique identifier for the server where the message is stored.

TYPE: MessageServerID

reaction

The reaction to be sent.

TYPE: str

message_id

The unique identifier for the message to which the reaction is being sent.

TYPE: str

RAISES DESCRIPTION
NewsletterSendReactionError

If an error occurs while sending the reaction.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def newsletter_send_reaction(
    self,
    jid: JID,
    message_server_id: MessageServerID,
    reaction: str,
    message_id: str,
):
    """
    Sends a reaction to a newsletter.

    :param jid: The unique identifier for the recipient of the newsletter.
    :type jid: JID
    :param message_server_id: The unique identifier for the server where the message is stored.
    :type message_server_id: MessageServerID
    :param reaction: The reaction to be sent.
    :type reaction: str
    :param message_id: The unique identifier for the message to which the reaction is being sent.
    :type message_id: str
    :raises NewsletterSendReactionError: If an error occurs while sending the reaction.
    """
    jid_proto = jid.SerializeToString()
    err = await self.__client.NewsletterSendReaction(
        self.uuid,
        jid_proto,
        len(jid_proto),
        message_server_id,
        reaction.encode(),
        message_id.encode(),
    )
    if err:
        raise NewsletterSendReactionError(err)
    return

newsletter_subscribe_live_updates async

Python
newsletter_subscribe_live_updates(jid: JID) -> int

Subscribes a user to live updates of a newsletter.

PARAMETER DESCRIPTION
jid

The unique identifier of the user subscribing to the newsletter.

TYPE: JID

RETURNS DESCRIPTION
int

The duration for which the subscription is valid.

RAISES DESCRIPTION
NewsletterSubscribeLiveUpdatesError

If there is an error during the subscription process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def newsletter_subscribe_live_updates(self, jid: JID) -> int:
    """Subscribes a user to live updates of a newsletter.

    :param jid: The unique identifier of the user subscribing to the newsletter.
    :type jid: JID
    :raises NewsletterSubscribeLiveUpdatesError: If there is an error during the subscription process.
    :return: The duration for which the subscription is valid.
    :rtype: int
    """
    jid_proto = jid.SerializeToString()
    bytes_ptr = await self.__client.NewsletterSubscribeLiveUpdates(
        self.uuid, jid_proto, len(jid_proto)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.NewsletterSubscribeLiveUpdatesReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise NewsletterSubscribeLiveUpdatesError(model.Error)
    return model.Duration

newsletter_toggle_mute async

Python
newsletter_toggle_mute(jid: JID, mute: bool)

Toggle the mute status of a given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the user.

TYPE: JID

mute

The desired mute status. If True, the user will be muted. If False, the user will be unmuted.

TYPE: bool

RAISES DESCRIPTION
NewsletterToggleMuteError

If there is an error while toggling the mute status.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def newsletter_toggle_mute(self, jid: JID, mute: bool):
    """Toggle the mute status of a given JID.

    :param jid: The JID (Jabber Identifier) of the user.
    :type jid: JID
    :param mute: The desired mute status. If True, the user will be muted. If False, the user will be unmuted.

    :type mute: bool
    :raises NewsletterToggleMuteError: If there is an error while toggling the mute status.
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.NewsletterToggleMute(
            self.uuid, jid_proto, len(jid_proto), mute
        )
    ).decode()
    if err:
        raise NewsletterToggleMuteError(err)
Python
resolve_business_message_link(code: str) -> neonize_proto.BusinessMessageLinkTarget

Resolves the target of a business message link.

PARAMETER DESCRIPTION
code

The code of the business message link to be resolved.

TYPE: str

RETURNS DESCRIPTION
neonize_proto.BusinessMessageLinkTarget

The target of the business message link.

RAISES DESCRIPTION
ResolveContactQRLinkError

If an error occurs while resolving the link.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def resolve_business_message_link(
    self, code: str
) -> neonize_proto.BusinessMessageLinkTarget:
    """Resolves the target of a business message link.

    :param code: The code of the business message link to be resolved.
    :type code: str
    :raises ResolveContactQRLinkError: If an error occurs while resolving the link.
    :return: The target of the business message link.
    :rtype: neonize_proto.BusinessMessageLinkTarget
    """
    bytes_ptr = await self.__client.ResolveBusinessMessageLink(
        self.uuid, code.encode()
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.ResolveBusinessMessageLinkReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise ResolveContactQRLinkError(model.Error)
    return model.MessageLinkTarget
Python
resolve_contact_qr_link(code: str) -> neonize_proto.ContactQRLinkTarget

Resolves a QR link for a specific contact.

PARAMETER DESCRIPTION
code

The QR code to be resolved.

TYPE: str

RETURNS DESCRIPTION
neonize_proto.ContactQRLinkTarget

The target contact of the QR link.

RAISES DESCRIPTION
ResolveContactQRLinkError

If an error occurs while resolving the QR link.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def resolve_contact_qr_link(
    self, code: str
) -> neonize_proto.ContactQRLinkTarget:
    """Resolves a QR link for a specific contact.

    :param code: The QR code to be resolved.
    :type code: str
    :raises ResolveContactQRLinkError: If an error occurs while resolving the QR link.
    :return: The target contact of the QR link.
    :rtype: neonize_proto.ContactQRLinkTarget
    """
    bytes_ptr = await self.__client.ResolveContactQRLink(self.uuid, code.encode())
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.ResolveContactQRLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise ResolveContactQRLinkError(model.Error)
    return model.ContactQrLink

send_app_state async

Python
send_app_state(patch_info: PatchInfo)

This function serializes the application state and sends it to the client. If there's an error during this process, it raises a SendAppStateError exception.

PARAMETER DESCRIPTION
patch_info

Contains the information about the application state that needs to be patched.

TYPE: PatchInfo

RAISES DESCRIPTION
SendAppStateError

If there's an error while sending the application state, this exception is raised.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def send_app_state(self, patch_info: neonize_proto.PatchInfo):
    """
    This function serializes the application state and sends it to the client. If there's an error during this process,
    it raises a SendAppStateError exception.

    :param patch_info: Contains the information about the application state that needs to be patched.
    :type patch_info: neonize_proto.PatchInfo
    :raises SendAppStateError: If there's an error while sending the application state, this exception is raised.
    """
    patch = patch_info.SerializeToString()
    err = (await self.__client.SendAppState(self.uuid, patch, len(patch))).decode()
    if err:
        raise SendAppStateError(err)

set_default_disappearing_timer async

Python
set_default_disappearing_timer(timer: Union[timedelta, int])

Sets a default disappearing timer for messages. The timer can be specified as a timedelta or an integer. If a timedelta is provided, it is converted to nanoseconds. If an integer is provided, it is used directly as the timer.

PARAMETER DESCRIPTION
timer

The duration for messages to exist before disappearing. Can be a timedelta or an integer.

TYPE: Union[timedelta, int]

RAISES DESCRIPTION
SetDefaultDisappearingTimerError

If an error occurs while setting the disappearing timer.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_default_disappearing_timer(self, timer: typing.Union[timedelta, int]):
    """
    Sets a default disappearing timer for messages. The timer can be specified as a timedelta or an integer.
    If a timedelta is provided, it is converted to nanoseconds. If an integer is provided, it is used directly as the timer.

    :param timer: The duration for messages to exist before disappearing. Can be a timedelta or an integer.
    :type timer: typing.Union[timedelta, int]
    :raises SetDefaultDisappearingTimerError: If an error occurs while setting the disappearing timer.
    """
    timestamp = 0
    if isinstance(timer, timedelta):
        timestamp = int(timer.total_seconds() * 1000**3)
    else:
        timestamp = timer
    err = (
        await self.__client.SetDefaultDisappearingTimer(self.uuid, timestamp)
    ).decode()
    if err:
        raise SetDefaultDisappearingTimerError(err)

set_disappearing_timer async

Python
set_disappearing_timer(jid: JID, timer: Union[timedelta, int], setting_ts: Optional[timedelta] = None)

Set a disappearing timer for a specific JID. The timer can be set as either a timedelta object or an integer. If a timedelta object is provided, it's converted into nanoseconds. If an integer is provided, it's interpreted as nanoseconds.

PARAMETER DESCRIPTION
jid

The JID for which the disappearing timer is to be set

TYPE: JID

timer

The duration for the disappearing timer. Can be a timedelta object or an integer representing nanoseconds.

TYPE: Union[timedelta, int]

RAISES DESCRIPTION
SetDisappearingTimerError

If there is an error in setting the disappearing timer

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_disappearing_timer(
    self,
    jid: JID,
    timer: typing.Union[timedelta, int],
    setting_ts: Optional[timedelta] = None,
):
    """
    Set a disappearing timer for a specific JID. The timer can be set as either a timedelta object or an integer.
    If a timedelta object is provided, it's converted into nanoseconds. If an integer is provided, it's interpreted as nanoseconds.

    :param jid: The JID for which the disappearing timer is to be set
    :type jid: JID
    :param timer: The duration for the disappearing timer. Can be a timedelta object or an integer representing nanoseconds.
    :type timer: typing.Union[timedelta, int]
    :raises SetDisappearingTimerError: If there is an error in setting the disappearing timer
    """
    timestamp = 0
    jid_proto = jid.SerializeToString()
    if isinstance(timer, timedelta):
        timestamp = int(timer.total_seconds() * 1000)
    else:
        timestamp = timer
    setting_ts_ms = 0
    if setting_ts:
        setting_ts_ms = int(time.time() + setting_ts.total_seconds() * 1000)
    err = (
        await self.__client.SetDisappearingTimer(
            self.uuid, jid_proto, len(jid_proto), timestamp, setting_ts_ms
        )
    ).decode()
    if err:
        raise SetDisappearingTimerError(err)

set_force_activate_delivery_receipts async

Python
set_force_activate_delivery_receipts(active: bool)

This method is used to forcibly activate or deactivate the delivery receipts for a client.

PARAMETER DESCRIPTION
active

This parameter determines whether the delivery receipts should be forcibly activated or deactivated. If it's True, the delivery receipts will be forcibly activated, otherwise, they will be deactivated.

TYPE: bool

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_force_activate_delivery_receipts(self, active: bool):
    """
    This method is used to forcibly activate or deactivate the delivery receipts for a client.

    :param active: This parameter determines whether the delivery receipts should be forcibly activated or deactivated. If it's True, the delivery receipts will be forcibly activated, otherwise, they will be deactivated.
    :type active: bool
    """
    await self.__client.SetForceActiveDeliveryReceipts(self.uuid, active)

set_group_announce async

Python
set_group_announce(jid: JID, announce: bool)

Sets the announcement status of a group.

PARAMETER DESCRIPTION
jid

The unique identifier of the group

TYPE: JID

announce

The announcement status to be set. If True, announcements are enabled. If False, they are disabled.

TYPE: bool

RAISES DESCRIPTION
SetGroupAnnounceError

If there is an error while setting the announcement status

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_group_announce(self, jid: JID, announce: bool):
    """
    Sets the announcement status of a group.

    :param jid: The unique identifier of the group
    :type jid: JID
    :param announce: The announcement status to be set. If True, announcements are enabled. If False, they are disabled.
    :type announce: bool
    :raises SetGroupAnnounceError: If there is an error while setting the announcement status
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.SetGroupAnnounce(
            self.uuid, jid_proto, len(jid_proto), announce
        )
    ).decode()
    if err:
        raise SetGroupAnnounceError(err)

set_group_locked async

Python
set_group_locked(jid: JID, locked: bool)

Sets the locked status of a group identified by the given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group to be locked/unlocked.

TYPE: JID

locked

The new locked status of the group. True to lock the group, False to unlock.

TYPE: bool

RAISES DESCRIPTION
SetGroupLockedError

If the operation fails, an error with the reason for the failure is raised.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_group_locked(self, jid: JID, locked: bool):
    """
    Sets the locked status of a group identified by the given JID.

    :param jid: The JID (Jabber ID) of the group to be locked/unlocked.
    :type jid: JID
    :param locked: The new locked status of the group. True to lock the group, False to unlock.
    :type locked: bool
    :raises SetGroupLockedError: If the operation fails, an error with the reason for the failure is raised.
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.SetGroupLocked(
            self.uuid, jid_proto, len(jid_proto), locked
        )
    ).decode()
    if err:
        raise SetGroupLockedError(err)

set_group_topic async

Python
set_group_topic(jid: JID, previous_id: str, new_id: str, topic: str)

Set the topic of a group in a chat application.

PARAMETER DESCRIPTION
jid

The unique identifier of the group

TYPE: JID

previous_id

The previous identifier of the topic

TYPE: str

new_id

The new identifier for the topic

TYPE: str

topic

The new topic to be set

TYPE: str

RAISES DESCRIPTION
SetGroupTopicError

If there is an error setting the group topic

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_group_topic(
    self, jid: JID, previous_id: str, new_id: str, topic: str
):
    """
    Set the topic of a group in a chat application.

    :param jid: The unique identifier of the group
    :type jid: JID
    :param previous_id: The previous identifier of the topic
    :type previous_id: str
    :param new_id: The new identifier for the topic
    :type new_id: str
    :param topic: The new topic to be set
    :type topic: str
    :raises SetGroupTopicError: If there is an error setting the group topic
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.SetGroupTopic(
            self.uuid,
            jid_proto,
            len(jid_proto),
            previous_id.encode(),
            new_id.encode(),
            topic.encode(),
        )
    ).decode()
    if err:
        raise SetGroupTopicError(err)

set_privacy_setting async

Python
set_privacy_setting(name: PrivacySettingType, value: PrivacySetting)

This method is used to set the privacy settings of a user.

PARAMETER DESCRIPTION
name

The name of the privacy setting to be changed.

TYPE: PrivacySettingType

value

The new value for the privacy setting.

TYPE: PrivacySetting

RAISES DESCRIPTION
SetPrivacySettingError

If there is an error while setting the privacy setting.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_privacy_setting(
    self, name: PrivacySettingType, value: PrivacySetting
):
    """
    This method is used to set the privacy settings of a user.

    :param name: The name of the privacy setting to be changed.
    :type name: PrivacySettingType
    :param value: The new value for the privacy setting.
    :type value: PrivacySetting
    :raises SetPrivacySettingError: If there is an error while setting the privacy setting.
    """
    err = (
        await self.__client.SetPrivacySetting(
            self.uuid, name.value.encode(), value.value.encode()
        )
    ).decode()
    if err:
        raise SetPrivacySettingError(err)

set_passive async

Python
set_passive(passive: bool)

Sets the passive mode of the client.

PARAMETER DESCRIPTION
passive

If True, sets the client to passive mode. If False, sets the client to active mode.

TYPE: bool

RAISES DESCRIPTION
SetPassiveError

If an error occurs while setting the client to passive mode.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_passive(self, passive: bool):
    """
    Sets the passive mode of the client.

    :param passive: If True, sets the client to passive mode. If False, sets the client to active mode.
    :type passive: bool
    :raises SetPassiveError: If an error occurs while setting the client to passive mode.
    """
    err = await self.__client.SetPassive(self.uuid, passive)
    if err:
        raise SetPassiveError(err)

set_status_message async

Python
set_status_message(msg: str)

Sets a status message for a client using the client's UUID.

PARAMETER DESCRIPTION
msg

The status message to be set.

TYPE: str

RAISES DESCRIPTION
SetStatusMessageError

If there is an error while setting the status message.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def set_status_message(self, msg: str):
    """
    Sets a status message for a client using the client's UUID.

    :param msg: The status message to be set.
    :type msg: str
    :raises SetStatusMessageError: If there is an error while setting the status message.
    """
    err = (await self.__client.SetStatusMessage(self.uuid, msg.encode())).decode()
    if err:
        raise SetStatusMessageError(err)

subscribe_presence async

Python
subscribe_presence(jid: JID)

This method is used to subscribe to the presence of a certain JID (Jabber ID).

PARAMETER DESCRIPTION
jid

The Jabber ID (JID) that we want to subscribe to.

TYPE: JID

RAISES DESCRIPTION
SubscribePresenceError

If there is an error while subscribing to the presence of the JID.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def subscribe_presence(self, jid: JID):
    """
    This method is used to subscribe to the presence of a certain JID (Jabber ID).

    :param jid: The Jabber ID (JID) that we want to subscribe to.
    :type jid: JID
    :raises SubscribePresenceError: If there is an error while subscribing to the presence of the JID.
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.SubscribePresence(self.uuid, jid_proto, len(jid_proto))
    ).decode()
    if err:
        raise SubscribePresenceError(err)

unfollow_newsletter async

Python
unfollow_newsletter(jid: JID)

Unfollows a newsletter by providing the JID (Jabber ID) of the newsletter.

PARAMETER DESCRIPTION
jid

The Jabber ID of the newsletter to unfollow.

TYPE: JID

RAISES DESCRIPTION
UnfollowNewsletterError

If there is an error while attempting to unfollow the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def unfollow_newsletter(self, jid: JID):
    """
    Unfollows a newsletter by providing the JID (Jabber ID) of the newsletter.

    :param jid: The Jabber ID of the newsletter to unfollow.
    :type jid: JID
    :raises UnfollowNewsletterError: If there is an error while attempting to unfollow the newsletter.
    """
    jid_proto = jid.SerializeToString()
    err = (
        await self.__client.UnfollowNewsletter(self.uuid, jid_proto, len(jid_proto))
    ).decode()
    if err:
        raise UnfollowNewsletterError(err)
Python
unlink_group(parent: JID, child: JID)

This method is used to unlink a child group from a parent group.

PARAMETER DESCRIPTION
parent

The JID of the parent group from which the child group is to be unlinked.

TYPE: JID

child

The JID of the child group which is to be unlinked from the parent group.

TYPE: JID

RAISES DESCRIPTION
UnlinkGroupError

If there is an error while unlinking the child group from the parent group.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def unlink_group(self, parent: JID, child: JID):
    """
    This method is used to unlink a child group from a parent group.

    :param parent: The JID of the parent group from which the child group is to be unlinked.
    :type parent: JID
    :param child: The JID of the child group which is to be unlinked from the parent group.
    :type child: JID
    :raises UnlinkGroupError: If there is an error while unlinking the child group from the parent group.
    """
    parent_proto = parent.SerializeToString()
    child_proto = child.SerializeToString()
    err = (
        await self.__client.UnlinkGroup(
            self.uuid,
            parent_proto,
            len(parent_proto),
            child_proto,
            len(child_proto),
        )
    ).decode()
    if err:
        raise UnlinkGroupError(err)

update_blocklist async

Python
update_blocklist(jid: JID, action: BlocklistAction) -> Blocklist

Function to update the blocklist with a given action on a specific JID.

PARAMETER DESCRIPTION
jid

The Jabber ID (JID) of the user to be blocked or unblocked.

TYPE: JID

action

The action to be performed (block or unblock) on the JID.

TYPE: BlocklistAction

RETURNS DESCRIPTION
Blocklist

The updated blocklist.

RAISES DESCRIPTION
UpdateBlocklistError

If there is an error while updating the blocklist.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def update_blocklist(self, jid: JID, action: BlocklistAction) -> Blocklist:
    """
    Function to update the blocklist with a given action on a specific JID.

    :param jid: The Jabber ID (JID) of the user to be blocked or unblocked.
    :type jid: JID
    :param action: The action to be performed (block or unblock) on the JID.
    :type action: BlocklistAction
    :raises UpdateBlocklistError: If there is an error while updating the blocklist.
    :return: The updated blocklist.
    :rtype: Blocklist
    """
    jid_proto = jid.SerializeToString()
    bytes_ptr = await self.__client.UpdateBlocklist(
        self.uuid, jid_proto, len(jid_proto), action.value.encode()
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetBlocklistReturnFunction.FromString(protobytes)
    if model.Error:
        raise UpdateBlocklistError(model.Error)
    return model.Blocklist

update_group_participants async

Python
update_group_participants(jid: JID, participants_changes: List[JID], action: ParticipantChange) -> RepeatedCompositeFieldContainer[GroupParticipant]

This method is used to update the list of participants in a group. It takes in the group's JID, a list of participant changes, and an action to perform.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the group to update.

TYPE: JID

participants_changes

A list of JIDs representing the participants to be added or removed.

TYPE: List[JID]

action

The action to perform (add, remove, promote or demote participants).

TYPE: ParticipantChange

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupParticipant]

A list of the updated group participants.

RAISES DESCRIPTION
UpdateGroupParticipantsError

This error is raised if there is a problem updating the group participants.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def update_group_participants(
    self, jid: JID, participants_changes: List[JID], action: ParticipantChange
) -> RepeatedCompositeFieldContainer[GroupParticipant]:
    """
    This method is used to update the list of participants in a group.
    It takes in the group's JID, a list of participant changes, and an action to perform.

    :param jid: The JID (Jabber ID) of the group to update.
    :type jid: JID
    :param participants_changes: A list of JIDs representing the participants to be added or removed.
    :type participants_changes: List[JID]
    :param action: The action to perform (add, remove, promote or demote participants).
    :type action: ParticipantChange
    :raises UpdateGroupParticipantsError: This error is raised if there is a problem updating the group participants.
    :return: A list of the updated group participants.
    :rtype: RepeatedCompositeFieldContainer[GroupParticipant]
    """
    jid_proto = jid.SerializeToString()
    jids_proto = neonize_proto.JIDArray(
        JIDS=participants_changes
    ).SerializeToString()
    bytes_ptr = await self.__client.UpdateGroupParticipants(
        self.uuid,
        jid_proto,
        len(jid_proto),
        jids_proto,
        len(jids_proto),
        action.value.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.UpdateGroupParticipantsReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise UpdateGroupParticipantsError(model.Error)
    return model.participants

upload_newsletter async

Python
upload_newsletter(data: bytes, media_type: MediaType) -> UploadResponse

Uploads the newsletter to the server.

PARAMETER DESCRIPTION
data

The newsletter content in bytes.

TYPE: bytes

media_type

The type of media being uploaded.

TYPE: MediaType

RETURNS DESCRIPTION
UploadResponse

The response from the server after the upload.

RAISES DESCRIPTION
UploadError

If there is an error during the upload process.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def upload_newsletter(
    self, data: bytes, media_type: MediaType
) -> UploadResponse:
    """Uploads the newsletter to the server.

    :param data: The newsletter content in bytes.
    :type data: bytes
    :param media_type: The type of media being uploaded.
    :type media_type: MediaType
    :raises UploadError: If there is an error during the upload process.
    :return: The response from the server after the upload.
    :rtype: UploadResponse
    """
    bytes_ptr = await self.__client.UploadNewsletter(
        self.uuid, data, len(data), media_type.value
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = UploadReturnFunction.FromString(protobytes)
    if model.Error:
        raise UploadError(model.Error)
    return model.UploadResponse

create_group async

Python
create_group(name: str, participants: List[JID] = [], linked_parent: Optional[GroupLinkedParent] = None, group_parent: Optional[GroupParent] = None) -> GroupInfo

Create a new group.

PARAMETER DESCRIPTION
name

The name of the new group.

TYPE: str

participants

Optional. A list of participant JIDs (Jabber Identifiers) to be included in the group. Defaults to an empty list.

TYPE: List[JID] DEFAULT: []

linked_parent

Optional. Information about a linked parent group, if applicable. Defaults to None.

TYPE: Optional[GroupLinkedParent] DEFAULT: None

group_parent

Optional. Information about a parent group, if applicable. Defaults to None.

TYPE: Optional[GroupParent] DEFAULT: None

RETURNS DESCRIPTION
GroupInfo

Information about the newly created group.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def create_group(
    self,
    name: str,
    participants: List[JID] = [],
    linked_parent: Optional[GroupLinkedParent] = None,
    group_parent: Optional[GroupParent] = None,
) -> GroupInfo:
    """Create a new group.

    :param name: The name of the new group.
    :type name: str
    :param participants: Optional. A list of participant JIDs (Jabber Identifiers) to be included in the group. Defaults to an empty list.
    :type participants: List[JID], optional
    :param linked_parent: Optional. Information about a linked parent group, if applicable. Defaults to None.
    :type linked_parent: Optional[GroupLinkedParent], optional
    :param group_parent: Optional. Information about a parent group, if applicable. Defaults to None.
    :type group_parent: Optional[GroupParent], optional
    :return: Information about the newly created group.
    :rtype: GroupInfo
    """
    group_info = ReqCreateGroup(
        name=name,
        Participants=participants,
        CreateKey=await self.generate_message_id(),
    )
    if linked_parent:
        group_info.GroupLinkedParent.MergeFrom(linked_parent)
    if group_parent:
        group_info.GroupParent.MergeFrom(group_parent)
    group_info_buf = group_info.SerializeToString()
    bytes_ptr = await self.__client.CreateGroup(
        self.uuid, group_info_buf, len(group_info_buf)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = GetGroupInfoReturnFunction.FromString(protobytes)
    if model.Error:
        raise CreateGroupError(model.Error)
    return model.GroupInfo

get_group_request_participants async

Python
get_group_request_participants(jid: JID) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]

Get the participants of a group request.

PARAMETER DESCRIPTION
jid

The JID of the group request.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

A list of JIDs representing the participants of the group request.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_group_request_participants(
    self, jid: JID
) -> RepeatedCompositeFieldContainer[GroupParticipantRequest]:
    """Get the participants of a group request.

    :param jid: The JID of the group request.
    :type jid: JID
    :return: A list of JIDs representing the participants of the group request.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = await self.__client.GetGroupRequestParticipants(
        self.uuid, jidbyte, len(jidbyte)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetGroupRequestParticipantsReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetGroupRequestParticipantsError(model.Error)
    return model.Participants

get_joined_groups async

Python
get_joined_groups() -> RepeatedCompositeFieldContainer[GroupInfo]

Get the joined groups for the current user.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupInfo]

A list of :class:GroupInfo objects representing the joined groups.

RAISES DESCRIPTION
GetJoinedGroupsError

If there was an error retrieving the joined groups.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_joined_groups(self) -> RepeatedCompositeFieldContainer[GroupInfo]:
    """Get the joined groups for the current user.

    :return: A list of :class:`GroupInfo` objects representing the joined groups.
    :rtype: RepeatedCompositeFieldContainer[GroupInfo]

    :raises GetJoinedGroupsError: If there was an error retrieving the joined groups.
    """
    bytes_ptr = await self.__client.GetJoinedGroups(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetJoinedGroupsReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetJoinedGroupsError(model.Error)
    return model.Group

create_newsletter async

Python
create_newsletter(name: str, description: str, picture: Union[str, bytes]) -> NewsletterMetadata

Create a newsletter with the given name, description, and picture.

PARAMETER DESCRIPTION
name

The name of the newsletter.

TYPE: str

description

The description of the newsletter.

TYPE: str

picture

The picture of the newsletter. It can be either a URL or bytes.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
NewsletterMetadata

The metadata of the created newsletter.

RAISES DESCRIPTION
CreateNewsletterError

If there is an error creating the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def create_newsletter(
    self, name: str, description: str, picture: typing.Union[str, bytes]
) -> NewsletterMetadata:
    """Create a newsletter with the given name, description, and picture.

    :param name: The name of the newsletter.
    :type name: str
    :param description: The description of the newsletter.
    :type description: str
    :param picture: The picture of the newsletter. It can be either a URL or bytes.
    :type picture: Union[str, bytes]
    :return: The metadata of the created newsletter.
    :rtype: NewsletterMetadata
    :raises CreateNewsletterError: If there is an error creating the newsletter.
    """
    protobuf = neonize_proto.CreateNewsletterParams(
        Name=name,
        Description=description,
        Picture=get_bytes_from_name_or_url(picture),
    ).SerializeToString()
    bytes_ptr = await self.__client.CreateNewsletter(
        self.uuid, protobuf, len(protobuf)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise CreateNewsletterError(model.Error)
    return model.NewsletterMetadata

follow_newsletter async

Python
follow_newsletter(jid: JID)

Follows a newsletter with the given JID.

PARAMETER DESCRIPTION
jid

The JID of the newsletter to follow.

TYPE: JID

RETURNS DESCRIPTION
None

None

RAISES DESCRIPTION
FollowNewsletterError

If there is an error following the newsletter.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def follow_newsletter(self, jid: JID):
    """Follows a newsletter with the given JID.

    :param jid: The JID of the newsletter to follow.
    :type jid: JID
    :return: None
    :rtype: None
    :raises FollowNewsletterError: If there is an error following the newsletter.
    """

    jidbyte = jid.SerializeToString()
    err = (
        await self.__client.FollowNewsletter(self.uuid, jidbyte, len(jidbyte))
    ).decode()
    if err:
        raise FollowNewsletterError(err)

get_newsletter_info_with_invite async

Python
get_newsletter_info_with_invite(key: str) -> NewsletterMetadata

Retrieves the newsletter information with an invite using the provided key.

PARAMETER DESCRIPTION
key

The key used to identify the newsletter.

TYPE: str

RETURNS DESCRIPTION
NewsletterMetadata

The newsletter metadata.

RAISES DESCRIPTION
GetNewsletterInfoWithInviteError

If there is an error retrieving the newsletter information.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_newsletter_info_with_invite(self, key: str) -> NewsletterMetadata:
    """Retrieves the newsletter information with an invite using the provided key.

    :param key: The key used to identify the newsletter.
    :type key: str
    :return: The newsletter metadata.
    :rtype: NewsletterMetadata
    :raises GetNewsletterInfoWithInviteError: If there is an error retrieving the newsletter information.
    """
    bytes_ptr = await self.__client.GetNewsletterInfoWithInvite(
        self.uuid, key.encode()
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetNewsletterInfoWithInviteError(model.Error)
    return model.NewsletterMetadata

get_newsletter_message_update async

Python
get_newsletter_message_update(jid: JID, count: int, since: int, after: int) -> RepeatedCompositeFieldContainer[NewsletterMessage]

Retrieves a list of newsletter messages that have been updated since a given timestamp.

PARAMETER DESCRIPTION
jid

The JID (Jabber ID) of the user.

TYPE: JID

count

The maximum number of messages to retrieve.

TYPE: int

since

The timestamp (in milliseconds) to retrieve messages from.

TYPE: int

after

The timestamp (in milliseconds) to retrieve messages after.

TYPE: int

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[NewsletterMessage]

A list of updated newsletter messages.

RAISES DESCRIPTION
GetNewsletterMessageUpdateError

If there was an error retrieving the newsletter messages.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_newsletter_message_update(
    self, jid: JID, count: int, since: int, after: int
) -> RepeatedCompositeFieldContainer[NewsletterMessage]:
    """Retrieves a list of newsletter messages that have been updated since a given timestamp.

    :param jid: The JID (Jabber ID) of the user.
    :type jid: JID
    :param count: The maximum number of messages to retrieve.
    :type count: int
    :param since: The timestamp (in milliseconds) to retrieve messages from.
    :type since: int
    :param after: The timestamp (in milliseconds) to retrieve messages after.
    :type after: int

    :return: A list of updated newsletter messages.
    :rtype: RepeatedCompositeFieldContainer[NewsletterMessage]

    :raises GetNewsletterMessageUpdateError: If there was an error retrieving the newsletter messages.
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = await self.__client.GetNewsletterMessageUpdate(
        self.uuid, jidbyte, len(jidbyte), count, since, after
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetNewsletterMessageUpdateReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetNewsletterMessageUpdateError(model.Error)
    return model.NewsletterMessage

get_newsletter_messages async

Python
get_newsletter_messages(jid: JID, count: int, before: MessageServerID) -> RepeatedCompositeFieldContainer[NewsletterMessage]

Retrieves a list of newsletter messages for a given JID.

PARAMETER DESCRIPTION
jid

The JID (Jabber Identifier) of the user.

TYPE: JID

count

The maximum number of messages to retrieve.

TYPE: int

before

The ID of the message before which to retrieve messages.

TYPE: MessageServerID

RETURNS DESCRIPTION
RepeatedCompositeFieldContaine[NewsletterMessage]

A list of newsletter messages.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_newsletter_messages(
    self, jid: JID, count: int, before: MessageServerID
) -> RepeatedCompositeFieldContainer[NewsletterMessage]:
    """Retrieves a list of newsletter messages for a given JID.

    :param jid: The JID (Jabber Identifier) of the user.
    :type jid: JID
    :param count: The maximum number of messages to retrieve.
    :type count: int
    :param before: The ID of the message before which to retrieve messages.
    :type before: MessageServerID
    :return: A list of newsletter messages.
    :rtype: RepeatedCompositeFieldContaine[NewsletterMessage]
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = await self.__client.GetNewsletterMessages(
        self.uuid, jidbyte, len(jidbyte), count, before
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetNewsletterMessageUpdateReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetNewsletterMessagesError(model.Error)
    return model.NewsletterMessage

get_privacy_settings async

Python
get_privacy_settings() -> PrivacySettings

This function retrieves the my privacy settings.

RETURNS DESCRIPTION
PrivacySettings

privacy settings

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_privacy_settings(self) -> PrivacySettings:
    """
    This function retrieves the my privacy settings.

    :return: privacy settings
    :rtype: PrivacySettings
    """
    bytes_ptr = await self.__client.GetPrivacySettings(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = neonize_proto.PrivacySettings.FromString(protobytes)
    return result

get_profile_picture async

Python
get_profile_picture(jid: JID, extra: GetProfilePictureParams = neonize_proto.GetProfilePictureParams()) -> ProfilePictureInfo

This function is used to get the profile picture of a user.

PARAMETER DESCRIPTION
jid

The unique identifier of the user whose profile picture we want to retrieve.

TYPE: JID

extra

Additional parameters, defaults to neonize_proto.GetProfilePictureParams()

TYPE: GetProfilePictureParams DEFAULT: GetProfilePictureParams()

RETURNS DESCRIPTION
ProfilePictureInfo

The information about the profile picture.

RAISES DESCRIPTION
GetProfilePictureError

If there is an error while trying to get the profile picture.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_profile_picture(
    self,
    jid: JID,
    extra: neonize_proto.GetProfilePictureParams = neonize_proto.GetProfilePictureParams(),
) -> ProfilePictureInfo:
    """
    This function is used to get the profile picture of a user.

    :param jid: The unique identifier of the user whose profile picture we want to retrieve.
    :type jid: JID
    :param extra: Additional parameters, defaults to neonize_proto.GetProfilePictureParams()
    :type extra: neonize_proto.GetProfilePictureParams, optional
    :raises GetProfilePictureError: If there is an error while trying to get the profile picture.
    :return: The information about the profile picture.
    :rtype: ProfilePictureInfo
    """
    jid_bytes = jid.SerializeToString()
    extra_bytes = extra.SerializeToString()
    bytes_ptr = await self.__client.GetProfilePicture(
        self.uuid,
        jid_bytes,
        len(jid_bytes),
        extra_bytes,
        len(extra_bytes),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetProfilePictureReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetProfilePictureError(model)
    return model.Picture

get_status_privacy async

Python
get_status_privacy() -> RepeatedCompositeFieldContainer[StatusPrivacy]

Returns the status privacy settings of the user.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[StatusPrivacy]

The status privacy settings of the user.

RAISES DESCRIPTION
GetStatusPrivacyError

If there is an error in getting the status privacy.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_status_privacy(
    self,
) -> RepeatedCompositeFieldContainer[StatusPrivacy]:
    """Returns the status privacy settings of the user.

    :raises GetStatusPrivacyError: If there is an error in getting the status privacy.
    :return: The status privacy settings of the user.
    :rtype: RepeatedCompositeFieldContainer[StatusPrivacy]
    """
    bytes_ptr = await self.__client.GetStatusPrivacy(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetStatusPrivacyReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetStatusPrivacyError(model.Error)
    return model.StatusPrivacy

get_sub_groups async

Python
get_sub_groups(community: JID) -> RepeatedCompositeFieldContainer[GroupLinkTarget]

Get the subgroups of a given community.

PARAMETER DESCRIPTION
community

The community for which to get the subgroups.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[GroupLinkTarget]

The subgroups of the given community.

RAISES DESCRIPTION
GetSubGroupsError

If there is an error while getting the subgroups.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_sub_groups(
    self, community: JID
) -> RepeatedCompositeFieldContainer[GroupLinkTarget]:
    """
    Get the subgroups of a given community.

    :param community: The community for which to get the subgroups.
    :type community: JID
    :raises GetSubGroupsError: If there is an error while getting the subgroups.
    :return: The subgroups of the given community.
    :rtype: RepeatedCompositeFieldContainer[GroupLinkTarget]
    """
    jid = community.SerializeToString()
    bytes_ptr = await self.__client.GetSubGroups(self.uuid, jid, len(jid))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetSubGroupsReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetSubGroupsError(model.Error)
    return model.GroupLinkTarget

get_subscribed_newletters async

Python
get_subscribed_newletters() -> RepeatedCompositeFieldContainer[NewsletterMetadata]

This function retrieves the newsletters the user has subscribed to.

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[NewsletterMetadata]

A container with the metadata of each subscribed newsletter

RAISES DESCRIPTION
GetSubscribedNewslettersError

If there is an error while fetching the subscribed newsletters

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_subscribed_newletters(
    self,
) -> RepeatedCompositeFieldContainer[NewsletterMetadata]:
    """
    This function retrieves the newsletters the user has subscribed to.

    :raises GetSubscribedNewslettersError: If there is an error while fetching the subscribed newsletters
    :return: A container with the metadata of each subscribed newsletter
    :rtype: RepeatedCompositeFieldContainer[NewsletterMetadata]
    """
    bytes_ptr = await self.__client.GetSubscribedNewsletters(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetSubscribedNewslettersReturnFunction.FromString(
        protobytes
    )
    if model.Error:
        raise GetSubscribedNewslettersError(model.Error)
    return model.Newsletter

get_user_devices async

Python
get_user_devices(*jids: JID) -> RepeatedCompositeFieldContainer[JID]

Retrieve devices associated with specified user JIDs.

PARAMETER DESCRIPTION
jids

Variable number of JIDs (Jabber Identifiers) of users.

TYPE: JID DEFAULT: ()

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

Devices associated with the specified user JIDs.

RAISES DESCRIPTION
GetUserDevicesError

If there is an error retrieving user devices.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_user_devices(
    self, *jids: JID
) -> RepeatedCompositeFieldContainer[JID]:
    """
    Retrieve devices associated with specified user JIDs.

    :param jids: Variable number of JIDs (Jabber Identifiers) of users.
    :type jids: JID
    :raises GetUserDevicesError: If there is an error retrieving user devices.
    :return: Devices associated with the specified user JIDs.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jids_ = neonize_proto.JIDArray(JIDS=jids).SerializeToString()
    bytes_ptr = await self.__client.GetUserDevices(self.uuid, jids_, len(jids_))
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetUserDevicesreturnFunction.FromString(protobytes)
    if model.Error:
        raise GetUserDevicesError(model.Error)
    return model.JID

get_blocklist async

Python
get_blocklist() -> Blocklist

Retrieves the blocklist from the client.

RETURNS DESCRIPTION
Blocklist

Blocklist: The retrieved blocklist.

RAISES DESCRIPTION
GetBlocklistError

If there was an error retrieving the blocklist.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_blocklist(self) -> Blocklist:
    """Retrieves the blocklist from the client.

    :return: Blocklist: The retrieved blocklist.
    :raises GetBlocklistError: If there was an error retrieving the blocklist.
    """
    bytes_ptr = await self.__client.GetBlocklist(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetBlocklistReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetBlocklistError(model.Error)
    return model.Blocklist

get_me async

Python
get_me() -> Device

This method is used to get the device information associated with a given UUID.

RETURNS DESCRIPTION
Device

It returns a Device object created from the byte string response from the client's GetMe method.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_me(self) -> Device:
    """
    This method is used to get the device information associated with a given UUID.

    :return: It returns a Device object created from the byte string response from the client's GetMe method.
    :rtype: Device
    """
    bytes_ptr = await self.__client.GetMe(self.uuid)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    result = Device.FromString(protobytes)
    return result
Python
get_contact_qr_link(revoke: bool = False) -> str

This function returns a QR link for a specific contact. If the 'revoke' parameter is set to True, it revokes the existing QR link and generates a new one.

PARAMETER DESCRIPTION
revoke

If set to True, revokes the existing QR link and generates a new one. Defaults to False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
str

The QR link for the contact.

RAISES DESCRIPTION
GetContactQrLinkError

If there is an error in getting the QR link.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_contact_qr_link(self, revoke: bool = False) -> str:
    """
    This function returns a QR link for a specific contact. If the 'revoke' parameter is set to True,
    it revokes the existing QR link and generates a new one.

    :param revoke: If set to True, revokes the existing QR link and generates a new one. Defaults to False.
    :type revoke: bool, optional
    :raises GetContactQrLinkError: If there is an error in getting the QR link.
    :return: The QR link for the contact.
    :rtype: str
    """
    bytes_ptr = await self.__client.GetContactQRLink(self.uuid, revoke)
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetContactQRLinkReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetContactQrLinkError(model.Error)
    return model.Link

get_linked_group_participants async

Python
get_linked_group_participants(community: JID) -> neonize_proto.JIDArray

Fetches the participants of a linked group in a community.

PARAMETER DESCRIPTION
community

The community in which the linked group belongs.

TYPE: JID

RETURNS DESCRIPTION
RepeatedCompositeFieldContainer[JID]

A list of participants in the linked group.

RAISES DESCRIPTION
GetLinkedGroupParticipantsError

If there is an error while fetching the participants.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_linked_group_participants(
    self, community: JID
) -> neonize_proto.JIDArray:
    """Fetches the participants of a linked group in a community.

    :param community: The community in which the linked group belongs.
    :type community: JID
    :raises GetLinkedGroupParticipantsError: If there is an error while fetching the participants.
    :return: A list of participants in the linked group.
    :rtype: RepeatedCompositeFieldContainer[JID]
    """
    jidbyte = community.SerializeToString()
    bytes_ptr = await self.__client.GetLinkedGroupsParticipants(
        self.uuid, jidbyte, len(jidbyte)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.ReturnFunctionWithError.FromString(protobytes)
    if model.Error:
        raise GetLinkedGroupParticipantsError(model.Error)
    return model.GetLinkedGroupsParticipants

get_newsletter_info async

Python
get_newsletter_info(jid: JID) -> neonize_proto.NewsletterMetadata

Fetches the metadata of a specific newsletter using its JID.

PARAMETER DESCRIPTION
jid

The unique identifier of the newsletter

TYPE: JID

RETURNS DESCRIPTION
neonize_proto.NewsletterMetadata

The metadata of the requested newsletter

RAISES DESCRIPTION
GetNewsletterInfoError

If there is an error while fetching the newsletter information

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_newsletter_info(self, jid: JID) -> neonize_proto.NewsletterMetadata:
    """
    Fetches the metadata of a specific newsletter using its JID.

    :param jid: The unique identifier of the newsletter
    :type jid: JID
    :raises GetNewsletterInfoError: If there is an error while fetching the newsletter information
    :return: The metadata of the requested newsletter
    :rtype: neonize_proto.NewsletterMetadata
    """
    jidbyte = jid.SerializeToString()
    bytes_ptr = await self.__client.GetNewsletterInfo(
        self.uuid, jidbyte, len(jidbyte)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.CreateNewsLetterReturnFunction.FromString(protobytes)
    if model.Error:
        raise GetNewsletterInfoError(model.Error)
    return model.NewsletterMetadata

PairPhone async

Python
PairPhone(phone: str, show_push_notification: bool, client_name: ClientName = ClientName.LINUX, client_type: Optional[ClientType] = None)

Pair a phone with the client. This function will try to connect to the WhatsApp servers and pair the phone. If successful, it will show a push notification on the paired phone.

PARAMETER DESCRIPTION
phone

The phone number to be paired.

TYPE: str

show_push_notification

If true, a push notification will be shown on the paired phone.

TYPE: bool

client_name

The name of the client, defaults to LINUX.

TYPE: ClientName DEFAULT: LINUX

client_type

The type of the client, defaults to None. If None, it will be set to FIREFOX or determined by the device properties.

TYPE: Optional[ClientType] DEFAULT: None

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def PairPhone(
    self,
    phone: str,
    show_push_notification: bool,
    client_name: ClientName = ClientName.LINUX,
    client_type: Optional[ClientType] = None,
):
    """
    Pair a phone with the client. This function will try to connect to the WhatsApp servers and pair the phone.
    If successful, it will show a push notification on the paired phone.

    :param phone: The phone number to be paired.
    :type phone: str
    :param show_push_notification: If true, a push notification will be shown on the paired phone.
    :type show_push_notification: bool
    :param client_name: The name of the client, defaults to LINUX.
    :type client_name: ClientName, optional
    :param client_type: The type of the client, defaults to None. If None, it will be set to FIREFOX or determined by the device properties.
    :type client_type: Optional[ClientType], optional
    """

    if client_type is None:
        if self.device_props is None:
            client_type = ClientType.FIREFOX
        else:
            try:
                client_type = ClientType(self.device_props.platformType)
            except ValueError:
                client_type = ClientType.FIREFOX

    pl = neonize_proto.PairPhoneParams(
        phone=phone,
        clientDisplayName="%s (%s)" % (client_type.name, client_name.name),
        clientType=client_type.value,
        showPushNotification=show_push_notification,
    )
    payload = pl.SerializeToString()
    d = bytearray(list(self.event.list_func))

    _log_.debug("trying connect to whatsapp servers")

    deviceprops = (
        DeviceProps(os="Neonize", platformType=DeviceProps.SAFARI)
        if self.device_props is None
        else self.device_props
    ).SerializeToString()

    jidbuf_size = 0
    jidbuf = b""
    if self.jid:
        jidbuf = self.jid.SerializeToString()
        jidbuf_size = len(jidbuf)

    task = self.__client.Neonize(
        self.name.encode(),
        self.uuid,
        jidbuf,
        jidbuf_size,
        LogLevel.from_logging(log.level).level,
        func_string(self.__onQr),
        func_string(self.__onLoginStatus),
        func_callback_bytes(self.event.execute),
        func_callback_bytes2(log_whatsmeow),
        (ctypes.c_char * self.event.list_func.__len__()).from_buffer(d),
        len(d),
        deviceprops,
        len(deviceprops),
        payload,
        len(payload),
    )
    self.connect_task = connect_task = self.loop.create_task(task)
    return connect_task

idle async

Python
idle()

Idles the client

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def idle(self):
    """
    Idles the client
    """
    await self.connect_task

stop async

Python
stop()

Stops the client and disconnects from the WhatsApp servers.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def stop(self):
    """
    Stops the client and disconnects from the WhatsApp servers.
    """
    await self.__client.Stop(self.uuid)

get_message_for_retry async

Python
get_message_for_retry(requester: JID, to: JID, message_id: str) -> typing.Union[None, Message]

This function retrieves a specific message for retrying transmission. It communicates with a client to get the message using provided requester, recipient, and message ID.

PARAMETER DESCRIPTION
requester

The JID of the entity requesting the message.

TYPE: JID

to

The JID of the intended recipient of the message.

TYPE: JID

message_id

The unique identifier of the message to be retrieved.

TYPE: str

RETURNS DESCRIPTION
Union[None, Message]

The message to be retried if found, None otherwise.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def get_message_for_retry(
    self, requester: JID, to: JID, message_id: str
) -> typing.Union[None, Message]:
    """
    This function retrieves a specific message for retrying transmission.
    It communicates with a client to get the message using provided requester, recipient, and message ID.

    :param requester: The JID of the entity requesting the message.
    :type requester: JID
    :param to: The JID of the intended recipient of the message.
    :type to: JID
    :param message_id: The unique identifier of the message to be retrieved.
    :type message_id: str
    :return: The message to be retried if found, None otherwise.
    :rtype: Union[None, Message]
    """
    requester_buf = requester.SerializeToString()
    to_buf = to.SerializeToString()
    bytes_ptr = await self.__client.GetMessageForRetry(
        self.uuid,
        requester_buf,
        len(requester_buf),
        to_buf,
        len(to_buf),
        message_id.encode(),
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = neonize_proto.GetMessageForRetryReturnFunction.FromString(protobytes)
    if model.Error:
        raise Exception(model.Error)
    if not model.isEmpty:
        return model.Message

decrypt_poll_vote async

Python
decrypt_poll_vote(message: Message) -> PollVoteMessage

Decrypt PollMessage

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def decrypt_poll_vote(
    self, message: neonize_proto.Message
) -> PollVoteMessage:
    """Decrypt PollMessage"""
    msg_buff = message.SerializeToString()
    bytes_ptr = await self.__client.DecryptPollVote(
        self.uuid, msg_buff, len(msg_buff), len(msg_buff)
    )
    protobytes = bytes_ptr.contents.get_bytes()
    free_bytes(bytes_ptr)
    model = ReturnFunctionWithError.FromString(protobytes)
    if model.Error:
        raise DecryptPollVoteError(model.Error)
    return model.PollVoteMessage

connect async

Python
connect()

Establishes a connection to the WhatsApp servers.

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def connect(self):
    """Establishes a connection to the WhatsApp servers."""
    # Convert the list of functions to a bytearray
    d = bytearray(list(self.event.list_func))
    _log_.debug("🔒 Attempting to connect to the WhatsApp servers.")
    # Set device properties
    deviceprops = (
        DeviceProps(os="Neonize", platformType=DeviceProps.SAFARI)
        if self.device_props is None
        else self.device_props
    ).SerializeToString()

    jidbuf_size = 0
    jidbuf = b""
    if self.jid:
        jidbuf = self.jid.SerializeToString()
        jidbuf_size = len(jidbuf)

    # Initiate connection to the server
    task = self.__client.Neonize(
        self.name.encode(),
        self.uuid,
        jidbuf,
        jidbuf_size,
        LogLevel.from_logging(log.level).level,
        func_string(self.__onQr),
        func_string(self.__onLoginStatus),
        func_callback_bytes(self.event.execute),
        func_callback_bytes2(log_whatsmeow),
        (ctypes.c_char * len(self.event.list_func)).from_buffer(d),
        len(d),
        deviceprops,
        len(deviceprops),
        b"",
        0,
    )
    self.connect_task = connect_task = self.loop.create_task(task)
    return connect_task

disconnect async

Python
disconnect() -> None

Disconnect the client

Source code in .venv/lib/python3.12/site-packages/neonize/aioze/client.py
Python
async def disconnect(self) -> None:
    """
    Disconnect the client
    """
    await self.__client.Disconnect(self.uuid)

Events

neonize.events

Classes

EventsManager

Python
EventsManager(client_factory: ClientFactory)
Source code in .venv/lib/python3.12/site-packages/neonize/events.py
Python
def __init__(self, client_factory: ClientFactory):
    self.client_factory = client_factory
    self.list_func: Dict[int, Callable[[NewClient, Message], None]] = {}

Event

Python
Event(client: NewClient)

Initializes the Event class with a client of type NewClient. Also sets up a default blocking function and an empty dictionary for list functions.

PARAMETER DESCRIPTION
client

An instance of the NewClient class

TYPE: NewClient

Source code in .venv/lib/python3.12/site-packages/neonize/events.py
Python
def __init__(self, client: NewClient):
    """
    Initializes the Event class with a client of type NewClient.
    Also sets up a default blocking function and an empty dictionary for list functions.

    :param client: An instance of the NewClient class
    :type client: NewClient
    """
    self.client = client
    self.paircode_cb = self.paircode(self.default_paircode_cb)
    self.list_func: Dict[int, Callable[[NewClient, Message], None]] = {}
    self._qr = self.__onqr
Functions
execute
Python
execute(uuid: int, binary: int, size: int, code: int)

Executes a function from the list of functions based on the given code.

PARAMETER DESCRIPTION
binary

The binary data to be processed by the function.

TYPE: int

size

The size of the binary data.

TYPE: int

code

The index of the function to be executed from the list of functions.

TYPE: int

Source code in .venv/lib/python3.12/site-packages/neonize/events.py
Python
def execute(
    self, uuid: int, binary: int, size: int, code: int
):  # Demands Attention
    """Executes a function from the list of functions based on the given code.

    :param binary: The binary data to be processed by the function.
    :type binary: int
    :param size: The size of the binary data.
    :type size: int
    :param code: The index of the function to be executed from the list of functions.
    :type code: int
    """
    if code not in INT_TO_EVENT:
        raise UnsupportedEvent()
    message = INT_TO_EVENT[code].FromString(ctypes.string_at(binary, size))
    if code == 0:
        self.client.me = message
        return
    elif code == 3:
        self.client.connected = True
    self.list_func[code](self.client, message)
qr
Python
qr(f: Callable[[NewClient, bytes], None])

Sets a callback function for handling QR code data.

PARAMETER DESCRIPTION
f

The callback function that takes a NewClient instance and QR code data in bytes.

TYPE: Callable[[NewClient, bytes], None]

Source code in .venv/lib/python3.12/site-packages/neonize/events.py
Python
def qr(self, f: Callable[[NewClient, bytes], None]):
    """
    Sets a callback function for handling QR code data.

    :param f: The callback function that takes a NewClient instance and QR code data in bytes.
    :type f: Callable[[NewClient, bytes], None]
    """
    self._qr = f

Types

neonize.types

Utilities

neonize.utils

Classes

BlocklistAction

Bases: Enum

Enumeration of blocklist actions.

Attributes: BLOCK (str): Block action. UNBLOCK (str): Unblock action.

ChatPresence

Bases: Enum

Enum representing the presence status in a chat.

Attributes: CHAT_PRESENCE_COMPOSING (int): Indicates that the user is currently composing a message. CHAT_PRESENCE_PAUSED (int): Indicates that the user has paused composing a message.

ChatPresenceMedia

Bases: Enum

Enum representing the type of media being used in a chat.

Attributes: CHAT_PRESENCE_MEDIA_TEXT (int): Indicates that the chat media type is text. CHAT_PRESENCE_MEDIA_AUDIO (int): Indicates that the chat media type is audio.

ClientName

Bases: Enum

Enumeration of client names.

Attributes: LINUX (str): Linux operating system. WINDOWS (str): Windows operating system. ANDROID (str): Android operating system.

Attributes
name property
Python
name: str

Returns the title-cased name of the client.

RETURNS DESCRIPTION
str

The title-cased name.

ClientType

Bases: Enum

Enumeration of client types.

Attributes: UNKNOWN (int): Unknown client type. CHROME (int): Chrome browser. EDGE (int): Microsoft Edge browser. FIREFOX (int): Mozilla Firefox browser. IE (int): Internet Explorer browser. OPERA (int): Opera browser. SAFARI (int): Safari browser. ELECTRON (int): Electron framework. UWP (int): Universal Windows Platform. OTHER (int): Other client types.

Attributes
name property
Python
name: str

Returns the title-cased name of the client type.

RETURNS DESCRIPTION
str

The title-cased name.

MediaType

Bases: Enum

Functions
to_mms
Python
to_mms() -> MediaTypeToMMS

Converts the MediaType to its corresponding MediaTypeToMMS enum member.

RETURNS DESCRIPTION
MediaTypeToMMS

The corresponding MediaTypeToMMS enum member.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/enum.py
Python
def to_mms(self) -> MediaTypeToMMS:
    """Converts the MediaType to its corresponding MediaTypeToMMS enum member.

    :return: The corresponding MediaTypeToMMS enum member.
    :rtype: MediaTypeToMMS
    """
    return {
        self.MediaImage: MediaTypeToMMS.MediaImage,
        self.MediaVideo: MediaTypeToMMS.MediaVideo,
        self.MediaAudio: MediaTypeToMMS.MediaAudio,
        self.MediaDocument: MediaTypeToMMS.MediaDocument,
        self.MediaHistory: MediaTypeToMMS.MediaHistory,
        self.MediaAppState: MediaTypeToMMS.MediaAppState,
        self.MediaLinkThumbnail: MediaTypeToMMS.MediaLinkThumbnail,
        self.MediaStickerPack: MediaTypeToMMS.MediaStickerPack,
    }[self]
from_magic classmethod
Python
from_magic(fn_or_bytes: Union[str, bytes]) -> MediaType

Returns the MediaType based on file magic bytes or file extension.

PARAMETER DESCRIPTION
fn_or_bytes

Either a file path (str) or binary data (bytes) for determining the MediaType.

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
MediaType

The determined MediaType.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/enum.py
Python
@classmethod
def from_magic(cls, fn_or_bytes: typing.Union[str, bytes]) -> MediaType:
    """Returns the MediaType based on file magic bytes or file extension.

    :param fn_or_bytes: Either a file path (str) or binary data (bytes) for determining the MediaType.
    :type fn_or_bytes: typing.Union[str, bytes]
    :return: The determined MediaType.
    :rtype: MediaType
    """
    magic_func = (
        magic.from_file if isinstance(fn_or_bytes, str) else magic.from_buffer
    )
    mime = magic_func(fn_or_bytes, mime=True).split("/")[0]
    match mime:
        case "image":
            return cls.MediaImage
        case "video":
            return cls.MediaVideo
        case "audio":
            return cls.MediaAudio
        case _:
            return cls.MediaDocument

ParticipantChange

Bases: Enum

Enumeration of participant change actions.

Attributes: ADD (str): Add participant action. REMOVE (str): Remove participant action. PROMOTE (str): Promote participant action. DEMOTE (str): Demote participant action.

ParticipantRequestChange

Bases: Enum

Enumeration of participant request change actions.

Attributes: APPROVE (str): Approve participant request action. REJECT (str): Reject participant request action.

PrivacySetting

Bases: Enum

Enumeration of privacy settings.

Attributes: UNDEFINED (str): Undefined privacy setting. ALL (str): All privacy setting. CONTACTS (str): Contacts privacy setting. CONTACTS_BLACKLIST (str): Contacts blacklist privacy setting. MATCH_LAST_SEEN (str): Match last seen privacy setting. KNOWN (str): Known privacy setting. NONE (str): None privacy setting.

PrivacySettingType

Bases: Enum

Enumeration of privacy setting types.

Attributes: GROUP_ADD (str): Group add privacy setting. LAST_SEEN (str): Last seen privacy setting. STATUS (str): Status privacy setting. PROFILE (str): Profile privacy setting. READ_RECEIPTS (str): Read receipts privacy setting. ONLINE (str): Online privacy setting. CALL_ADD (str): Call add privacy setting.

ReceiptType

Bases: Enum

Enum representing different types of message receipts.

Attributes: DELIVERED (bytes): Indicates that the message has been delivered. SENDER (bytes): Indicates that the message is from the sender. RETRY (bytes): Indicates a retry receipt. READ (bytes): Indicates that the message has been read. READ_SELF (bytes): Indicates that the message has been read by the sender themselves. PLAYED (bytes): Indicates that the message has been played (e.g., for audio messages). PLAYED_SELF (bytes): Indicates that the message has been played by the sender themselves. SERVER_ERROR (bytes): Indicates a server error receipt. INACTIVE (bytes): Indicates that the recipient is inactive. PEER_MSG (bytes): Indicates a peer message receipt. HISTORY_SYNC (str): Indicates that the message is part of a history sync.

FFmpeg

Python
FFmpeg(data: bytes | str, prefix: Optional[str] = None)

Initializes the FFmpeg class. If the data is a URL, it retrieves the data from the URL and writes it to a temporary file. If the data is a string that is not a URL, it treats the string as a filename. If the data is bytes, it writes the bytes to a temporary file.

PARAMETER DESCRIPTION
data

The input data. This can be a URL, a filename, or bytes.

TYPE: bytes | str

prefix

The prefix for the temporary file, if one is created. If None, no prefix is used.

TYPE: Optional[str] DEFAULT: None

Source code in .venv/lib/python3.12/site-packages/neonize/utils/ffmpeg.py
Python
def __init__(self, data: bytes | str, prefix: Optional[str] = None) -> None:
    """
    Initializes the FFmpeg class. If the data is a URL, it retrieves the data from the URL
    and writes it to a temporary file. If the data is a string that is not a URL, it treats
    the string as a filename. If the data is bytes, it writes the bytes to a temporary file.

    :param data: The input data. This can be a URL, a filename, or bytes.
    :type data: bytes | str
    :param prefix: The prefix for the temporary file, if one is created. If None, no prefix is used.
    :type prefix: Optional[str], optional
    """
    if isinstance(data, str):
        if URL_MATCH.match(data):
            self.filename = TemporaryFile(prefix=prefix, touch=False).__enter__()
            with open(self.filename.path, "wb") as file:
                file.write(get_bytes_from_name_or_url(data))
        else:
            self.filename = data
    else:
        self.filename = TemporaryFile(prefix=prefix, touch=False).__enter__()
        with open(self.filename.path, "wb") as file:
            file.write(data)
Functions
cv_to_webp
Python
cv_to_webp(animated: bool = True, enforce_not_broken: bool = False, animated_gif: bool = False, max_sticker_size: int = 0, is_webm=False) -> bytes

This function converts a given file to webp format using ffmpeg. If the animated flag is set to True, it will only convert the first 6 seconds of the file.

PARAMETER DESCRIPTION
animated

If True, only the first 6 seconds of the file will be converted, defaults to True

TYPE: bool DEFAULT: True

enforce_not_broken

Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
bytes

The converted file in bytes

Source code in .venv/lib/python3.12/site-packages/neonize/utils/ffmpeg.py
Python
def cv_to_webp(
    self,
    animated: bool = True,
    enforce_not_broken: bool = False,
    animated_gif: bool = False,
    max_sticker_size: int = 0,
    is_webm=False,
) -> bytes:
    """
    This function converts a given file to webp format using ffmpeg.
    If the animated flag is set to True, it will only convert the first 6 seconds of the file.

    :param animated: If True, only the first 6 seconds of the file will be converted, defaults to True
    :type animated: bool, optional
    :param enforce_not_broken: Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
    :type enforce_not_broken: bool, optional
    :return: The converted file in bytes
    :rtype: bytes
    """
    MAX_STICKER_FILESIZE = max_sticker_size or 512000
    temp = tempfile.gettempdir() + "/" + uuid.uuid4().__str__() + ".webp"
    duration = int((self.extract_info()).format.duration or 0)
    if not duration:
        duration = 1
    if duration > 6 and animated:
        duration = 6
    elif duration < 6:
        animated = False
    ffmpeg_command = ["ffmpeg"]
    if is_webm:
        decoder = "-c:v libvpx"
        codec = (self.extract_info()).streams[0].codec_name
        if codec == "vp9":
            decoder += "-vp9"
        ffmpeg_command.extend(decoder.split())
    ffmpeg_command.extend(
        [
            "-i",
            self.filepath,
        ]
    )
    if animated:
        ffmpeg_command.extend(
            [
                "-ss",
                "00:00:00.0",
                "-t",
                "00:00:06.0",
            ]
        )
    ffmpeg_command.extend(
        [
            "-vcodec",
            "libwebp_anim" if animated_gif else "libwebp",
            "-vf",
            (
                "scale='if(gt(iw,ih),512,-1)':'if(gt(iw,ih),-1,512)',fps=15, "
                "pad=512:512:-1:-1:color=white@0.0, split [a][b]; [a] "
                "palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse"
            ),
        ]
    )
    if enforce_not_broken:
        bitrate = f"{MAX_STICKER_FILESIZE // duration}k"
        ffmpeg_command.extend(
            [
                "-loop",
                "0",
                "-preset",
                "picture",
                "-fs",
                f"{MAX_STICKER_FILESIZE}",
                "-q:v",
                bitrate,
            ]
        )
    ffmpeg_command.append(temp)
    self.call(ffmpeg_command)
    with open(temp, "rb") as file:
        buf = file.read()
    os.remove(temp)
    return buf
gif_to_mp4
Python
gif_to_mp4() -> bytes

This function convertes a gif to mp4 format.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/ffmpeg.py
Python
def gif_to_mp4(self) -> bytes:
    """
    This function convertes a gif to mp4 format.
    """
    temp = tempfile.gettempdir() + "/" + uuid.uuid4().__str__() + ".mp4"
    self.call(
        [
            "ffmpeg",
            "-i",
            self.filepath,
            "-movflags",
            "faststart",
            "-pix_fmt",
            "yuv420p",
            "-vf",
            "scale=trunc(iw/2)*2:trunc(ih/2)*2",
            "-crf",
            "17",
            temp,
        ]
    )
    with open(temp, "rb") as file:
        buf = file.read()
    os.remove(temp)
    return buf
extract_thumbnail
Python
extract_thumbnail(format: ImageFormat = ImageFormat.JPG, size: Optional[Tuple[int, int] | int] = 200) -> bytes

Extracts a thumbnail from a video file.

PARAMETER DESCRIPTION
format

The format of the output thumbnail, defaults to ImageFormat.JPG

TYPE: ImageFormat DEFAULT: JPG

size

The size of the output thumbnail. If an integer is provided, the thumbnail will be scaled while maintaining the aspect ratio. If a tuple of two integers is provided, it will be used as the exact dimensions for the thumbnail, defaults to 200

TYPE: Optional[Tuple[int, int] | int] DEFAULT: 200

RETURNS DESCRIPTION
bytes

The bytes representing the thumbnail image.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/ffmpeg.py
Python
def extract_thumbnail(
    self,
    format: ImageFormat = ImageFormat.JPG,
    size: Optional[Tuple[int, int] | int] = 200,
) -> bytes:
    """
    Extracts a thumbnail from a video file.

    :param format: The format of the output thumbnail, defaults to ImageFormat.JPG
    :type format: ImageFormat, optional
    :param size: The size of the output thumbnail. If an integer is provided, the thumbnail will be scaled
                 while maintaining the aspect ratio. If a tuple of two integers is provided, it will be used
                 as the exact dimensions for the thumbnail, defaults to 200
    :type size: Optional[Tuple[int, int]  |  int], optional
    :return: The bytes representing the thumbnail image.
    :rtype: bytes
    """
    extra = []
    if isinstance(size, int):
        for stream in self.extract_info().streams:
            if stream.codec_type == "video":
                extra.extend(
                    [
                        "-vf",
                        "scale='if(gt(iw,ih),%i,-1)':'if(gt(iw,ih),-1,%i)'"
                        % (size, size),
                    ]
                )
    elif isinstance(size, Tuple):
        extra.extend(["-s", "x".join(map(str, size))])
    return self.call(
        [
            "ffmpeg",
            "-i",
            self.filepath,
            "-vframes",
            "1",
            "-an",
            *extra,
            "-f",
            format.value,
            "-",
        ]
    )
extract_info
Python
extract_info() -> FFProbeInfo

Extracts media file information using ffprobe tool.

This method uses ffprobe, a tool from the FFmpeg package, to extract information about a media file. It returns the information in the form of an FFProbeInfo object, which contains the format and streams of the media file.

RETURNS DESCRIPTION
FFProbeInfo

An FFProbeInfo object containing the format and streams of the media file.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/ffmpeg.py
Python
def extract_info(self) -> FFProbeInfo:
    """
    Extracts media file information using ffprobe tool.

    This method uses ffprobe, a tool from the FFmpeg package, to extract
    information about a media file. It returns the information in the form of
    an FFProbeInfo object, which contains the format and streams of the media file.

    :return: An FFProbeInfo object containing the format and streams of the media file.
    :rtype: FFProbeInfo
    """
    data = json.loads(
        self.call(
            [
                "ffprobe",
                "-i",
                self.filepath,
                "-print_format",
                "json",
                "-show_format",
                "-show_streams",
            ]
        )
    )
    streams: List[dict] = data["streams"]
    format: dict = data["format"]
    return FFProbeInfo(
        format=Format(
            **{
                i: format.get(i, None)
                for i, _ in Format.__dataclass_fields__.items()
            }
        ),
        streams=[
            Stream(
                **{
                    field: data.get(field, None)
                    for field, _ in Stream.__dataclass_fields__.items()
                }
            )
            for data in streams
        ],
    )

Functions

AspectRatioMethod

Python
AspectRatioMethod(width: int | float, height: int | float, res: int = 1280) -> Tuple[int, int]

Calculate the aspect ratio of a given width and height with respect to a resolution.

PARAMETER DESCRIPTION
width

The width of the given area.

TYPE: int | float

height

The height of the given area.

TYPE: int | float

res

The resolution to calculate the aspect ratio with, defaults to 1280.

TYPE: int DEFAULT: 1280

RETURNS DESCRIPTION
Tuple[int, int]

A tuple containing the calculated width and height based on the aspect ratio.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/calc.py
Python
def AspectRatioMethod(
    width: int | float, height: int | float, res: int = 1280
) -> Tuple[int, int]:
    """Calculate the aspect ratio of a given width and height with respect to a resolution.

    :param width: The width of the given area.
    :type width: int | float
    :param height: The height of the given area.
    :type height: int | float
    :param res: The resolution to calculate the aspect ratio with, defaults to 1280.
    :type res: int, optional
    :return: A tuple containing the calculated width and height based on the aspect ratio.
    :rtype: Tuple[int, int]
    """
    if width > height:
        return (res, int(width / (width / res)))
    elif width < height:
        return (int(width / (height / res)), res)
    return (res, res)

get_bytes_from_name_or_url

Python
get_bytes_from_name_or_url(args: Union[str, bytes]) -> bytes

Gets bytes from either a file name or a URL.

PARAMETER DESCRIPTION
args

Either a file name (str) or binary data (bytes).

TYPE: Union[str, bytes]

RETURNS DESCRIPTION
bytes

The bytes extracted from the specified file name or URL.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/iofile.py
Python
def get_bytes_from_name_or_url(args: typing.Union[str, bytes]) -> bytes:
    """Gets bytes from either a file name or a URL.

    :param args: Either a file name (str) or binary data (bytes).
    :type args: typing.Union[str, bytes]
    :return: The bytes extracted from the specified file name or URL.
    :rtype: bytes
    """
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
        "(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
    }
    if isinstance(args, str):
        if URL_MATCH.match(args):
            return requests.get(args, headers=headers).content
        else:
            with open(args, "rb") as file:
                return file.read()
    else:
        return args

Jid2String

Python
Jid2String(jid: JID) -> str

Converts a Jabber Identifier (JID) to a string.

PARAMETER DESCRIPTION
jid

The Jabber Identifier (JID) to be converted.

TYPE: JID

RETURNS DESCRIPTION
str

The string representation of the JID.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/jid.py
Python
def Jid2String(jid: JID) -> str:
    """Converts a Jabber Identifier (JID) to a string.

    :param jid: The Jabber Identifier (JID) to be converted.
    :type jid: JID
    :return: The string representation of the JID.
    :rtype: str
    """
    if jid.RawAgent > 0:
        return "%s.%s:%d@%s" % (jid.User, jid.RawAgent, jid.Device, jid.Server)
    elif jid.Device > 0:
        return "%s:%d@%s" % (jid.User, jid.Device, jid.Server)
    elif len(jid.User) > 0:
        return "%s@%s" % (jid.User, jid.Server)
    return jid.Server

JIDToNonAD

Python
JIDToNonAD(jid: JID) -> JID

Converts a JID (Jabber ID) to a non-AD (Active Directory) format by setting RawAgent and Device to 0.

PARAMETER DESCRIPTION
jid

The JID to be converted.

TYPE: JID

RETURNS DESCRIPTION
JID

A new JID object with RawAgent and Device set to 0.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/jid.py
Python
def JIDToNonAD(jid: JID) -> JID:
    """
    Converts a JID (Jabber ID) to a non-AD (Active Directory) format by setting RawAgent and Device to 0.

    :param jid: The JID to be converted.
    :type jid: JID
    :return: A new JID object with RawAgent and Device set to 0.
    :rtype: JID
    """
    new_jid = copy.deepcopy(jid)
    new_jid.RawAgent = 0
    new_jid.Device = 0
    return new_jid

build_jid

Python
build_jid(phone_number: str, server: str = 's.whatsapp.net') -> JID

Builds a JID (Jabber ID) from a phone number.

PARAMETER DESCRIPTION
phone_number

The phone number to be used for building the JID.

TYPE: str

RETURNS DESCRIPTION
JID

A JID object constructed from the given phone number.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/jid.py
Python
def build_jid(phone_number: str, server: str = "s.whatsapp.net") -> JID:
    """
    Builds a JID (Jabber ID) from a phone number.

    :param phone_number: The phone number to be used for building the JID.
    :type phone_number: str
    :return: A JID object constructed from the given phone number.
    :rtype: JID
    """
    return JID(
        User=phone_number,
        Device=0,
        Integrator=0,
        IsEmpty=False,
        RawAgent=0,
        Server=server,
    )

extract_text

Python
extract_text(message: Message)

Extracts text content from a message.

PARAMETER DESCRIPTION
message

The message object.

TYPE: Message

RETURNS DESCRIPTION
str

The extracted text content.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/message.py
Python
def extract_text(message: Message):
    """
    Extracts text content from a message.

    :param message: The message object.
    :type message: Message
    :return: The extracted text content.
    :rtype: str
    """
    if message.imageMessage.ListFields():
        imageMessage: ImageMessage = message.imageMessage
        return imageMessage.caption
    elif message.extendedTextMessage.ListFields():
        extendedTextMessage: ExtendedTextMessage = message.extendedTextMessage
        return extendedTextMessage.text
    elif message.videoMessage.ListFields():
        videoMessage: VideoMessage = message.videoMessage
        return videoMessage.caption
    elif message.documentMessage.ListFields():
        documentMessage: DocumentMessage = message.documentMessage
        return documentMessage.caption
    elif message.conversation:
        return message.conversation
    return ""

get_message_type

Python
get_message_type(message: Message) -> MediaMessageType | TextMessageType

Determines the type of message.

PARAMETER DESCRIPTION
message

The message object.

TYPE: Message

RETURNS DESCRIPTION
MediaMessageType | TextMessageType

The type of the message.

RAISES DESCRIPTION
IndexError

If the message type cannot be determined.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/message.py
Python
def get_message_type(message: Message) -> MediaMessageType | TextMessageType:
    """
    Determines the type of message.

    :param message: The message object.
    :type message: Message
    :raises IndexError: If the message type cannot be determined.
    :return: The type of the message.
    :rtype: MediaMessageType | TextMessageType
    """
    for field_name, v in message.ListFields():
        if field_name.name.endswith(("Message", "MessageV2", "MessageV3")):
            return v
        elif field_name.name == "conversation":
            return v
    raise IndexError()

add_exif

Python
add_exif(name: str = '', packname: str = '') -> bytes

Adds EXIF metadata to a sticker pack.

PARAMETER DESCRIPTION
name

Name of the sticker pack, defaults to an empty string.

TYPE: str DEFAULT: ''

packname

Publisher of the sticker pack, defaults to an empty string.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
bytes

Byte array containing the EXIF metadata.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/sticker.py
Python
def add_exif(name: str = "", packname: str = "") -> bytes:
    """
    Adds EXIF metadata to a sticker pack.

    :param name: Name of the sticker pack, defaults to an empty string.
    :type name: str, optional
    :param packname: Publisher of the sticker pack, defaults to an empty string.
    :type packname: str, optional
    :return: Byte array containing the EXIF metadata.
    :rtype: bytes
    """
    json_data = {
        "sticker-pack-id": "com.snowcorp.stickerly.android.stickercontentprovider b5e7275f-f1de-4137-961f-57becfad34f2",
        "sticker-pack-name": name,
        "sticker-pack-publisher": packname,
        "android-app-store-link": "https://play.google.com/store/apps/details?id=com.marsvard.stickermakerforwhatsapp",
        "ios-app-store-link": "https://itunes.apple.com/app/sticker-maker-studio/id1443326857",
    }

    exif_attr = bytes.fromhex(
        "49 49 2A 00 08 00 00 00 01 00 41 57 07 00 00 00 00 00 16 00 00 00"
    )
    json_buffer = json.dumps(json_data).encode("utf-8")
    exif = exif_attr + json_buffer
    exif_length = len(json_buffer)
    exif = exif[:14] + exif_length.to_bytes(4, "little") + exif[18:]
    return exif

gen_vcard

Python
gen_vcard(name: str, phone_number: str) -> str

Generates a vCard string for a contact.

PARAMETER DESCRIPTION
name

Name of the contact.

TYPE: str

phone_number

Phone number of the contact.

TYPE: str

RETURNS DESCRIPTION
str

vCard string for the contact.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/__init__.py
Python
def gen_vcard(name: str, phone_number: str) -> str:
    """
    Generates a vCard string for a contact.

    :param name: Name of the contact.
    :type name: str
    :param phone_number: Phone number of the contact.
    :type phone_number: str
    :return: vCard string for the contact.
    :rtype: str
    """
    inter_phone_number = format_number(
        parse(f"{'+' if phone_number[0] != '+' else ''}{phone_number}"),
        PhoneNumberFormat.INTERNATIONAL,
    )
    return (
        f"BEGIN:VCARD\nVERSION:3.0\nFN:{name}\nitem1.TEL;waid={phone_number}"
        f":{inter_phone_number}\nitem1.X-ABLabel:Ponsel\nEND:VCARD"
    )
Python
validate_link(link) -> bool

Validates if the provided link is a valid URL.

PARAMETER DESCRIPTION
link

The URL to validate.

TYPE: str

RETURNS DESCRIPTION
bool

True if the URL is valid, False otherwise.

Source code in .venv/lib/python3.12/site-packages/neonize/utils/__init__.py
Python
def validate_link(link) -> bool:
    """
    Validates if the provided link is a valid URL.

    :param link: The URL to validate.
    :type link: str
    :return: True if the URL is valid, False otherwise.
    :rtype: bool
    """
    url_pattern = re.compile(
        r"^(https?|ftp)://"
        r"(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|"
        r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|"
        r"\[?[A-F0-9]*:[A-F0-9:]+]?)"
        r"(?::\d+)?"
        r"(?:/?|[/?]\S+)$",
        re.IGNORECASE,
    )

    return bool(re.match(url_pattern, link))

Exceptions

neonize.exc