neonize.aioze package¶
Submodules¶
neonize.aioze.client module¶
- class neonize.aioze.client.ChatSettingsStore(uuid)[source]¶
Bases:
object
- async get_chat_settings(user)[source]¶
Retrieve the chat settings for a user.
- Parameters:
user (JID) – The user whose chat settings are to be retrieved.
- Raises:
GetChatSettingsError – If there is an error while retrieving the chat settings.
- Returns:
The chat settings for the specified user.
- Return type:
LocalChatSettings
- async put_archived(user, archived)[source]¶
Archive or unarchive a user.
- Parameters:
user (JID) – The user to be archived or unarchived.
archived (bool) – True if the user should be archived, False otherwise.
- Raises:
PutArchivedError – If there is an error while archiving the user.
- async put_muted_until(user, until)[source]¶
Mute a user until a specified time.
- Parameters:
user (JID) – The user to be muted.
until (timedelta) – The duration until when the user will be muted.
- Raises:
PutMutedUntilError – If there is an error while muting the user.
- async put_pinned(user, pinned)[source]¶
Pin or unpin a user.
- Parameters:
user (JID) – The user to be pinned or unpinned.
pinned (bool) – True if the user should be pinned, False otherwise.
- Raises:
PutPinnedError – If there is an error while pinning the user.
- class neonize.aioze.client.ClientFactory(database_name='neonize.db')[source]¶
Bases:
object
- get_all_devices()[source]¶
Retrieves all devices associated with the current account from the database.
- Return type:
List
[Device
]
- static get_all_devices_from_db(db)[source]¶
Retrieves all devices associated with the current account. :type db:
str
:param db: The name of the database to retrieve the devices from. :return: A list of Device-like objects representing all associated devices. :rtype: List[neonize_proto.Device]
- new_client(jid=None, uuid=None, props=None)[source]¶
This function creates a new instance of the client. If the jid parameter is not provided, a new client will be created. :param name: The name of the client. :type name: str :type uuid:
Optional
[str
] :param uuid: The unique identifier of the client. :type uuid: str :type jid:Optional
[JID
] :param jid: The JID of the client. :type jid: JID :type props:Optional
[DeviceProps
] :param props: The device properties of the client. :type props: Optional[DeviceProps]- Return type:
- class neonize.aioze.client.ContactStore(uuid)[source]¶
Bases:
object
- async get_all_contacts()[source]¶
This function retrieves all contacts from the client. It deserializes the response from the client, checks for any errors, and if there are no errors, returns the contacts.
- Raises:
ContactStoreError – If there is an error in the response from the client.
- Returns:
A list of all contacts.
- Return type:
RepeatedCompositeFieldContainer[Contact]
- async get_contact(user)[source]¶
This method retrieves a user’s contact information based on their JID (Jabber Identifier).
- Parameters:
user (JID) – The Jabber Identifier of the user whose contact information is to be retrieved.
- Raises:
ContactStoreError – If there is an error while retrieving the contact information.
- Returns:
The contact information of the user.
- Return type:
ContactInfo
- async put_all_contact_name(contact_entry)[source]¶
This method serializes a list of ContactEntry objects and sends them to a remote service using the client’s PutAllContactNames method. If the service returns an error, it raises a ContactStoreError with the error message.
- Parameters:
contact_entry (List[ContactEntry]) – List of ContactEntry objects to be serialized and sent
- Raises:
ContactStoreError – If the remote service returns an error message
- async put_contact_name(user, fullname, firstname)[source]¶
This method is used to update the contact name in the contact store. It takes the user’s JID, full name and first name as input parameters, then calls the PutContactName method of the client with the user’s JID, full name and first name. If there is an error, it returns a ContactStoreError with the error message.
- Parameters:
user (JID) – The JID of the user whose contact name is to be updated
fullname (str) – The full name of the user
firstname (str) – The first name of the user
- Returns:
If there is an error, return a ContactStoreError with the error message, else None
- Return type:
ContactStoreError or None
- async put_pushname(user, pushname)[source]¶
Updates the pushname of a specific user.
- Parameters:
user (JID) – The JID (Jabber ID) of the user whose pushname needs to be updated.
pushname (str) – The new pushname for the user.
- Raises:
ContactStoreError – If there is any error updating the pushname.
- Returns:
The updated contact model after the pushname has been updated.
- Return type:
ContactsPutPushNameReturnFunction
- class neonize.aioze.client.NewAClient(name, jid=None, props=None, uuid=None)[source]¶
Bases:
object
- async PairPhone(phone, show_push_notification, client_name=ClientName.Linux, client_type=None)[source]¶
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.
- Parameters:
phone (str) – The phone number to be paired.
show_push_notification (bool) – If true, a push notification will be shown on the paired phone.
client_name (ClientName, optional) – The name of the client, defaults to LINUX.
client_type (Optional[ClientType], optional) – The type of the client, defaults to None. If None, it will be set to FIREFOX or determined by the device properties.
- async build_album_content(file, media_type, msg_association, **kwargs)[source]¶
- Return type:
Message
- async build_audio_message(file, ptt=False, quoted=None)[source]¶
This method builds an audio message from a given file or bytes.
- Parameters:
file (str | bytes) – The audio file in string or bytes format to be converted into an audio message
ptt (bool, optional) – A boolean indicating if the audio message is a ‘push to talk’ message, defaults to False
quoted (Optional[neonize_proto.Message], optional) – A message that the audio message may be replying to, defaults to None
- Returns:
The audio message built from the given parameters
- Return type:
Message
- async build_document_message(file, caption=None, title=None, filename=None, mimetype=None, quoted=None, ghost_mentions=None, mentions_are_lids=False)[source]¶
- async build_image_message(file, caption=None, quoted=None, viewonce=False, ghost_mentions=None, mentions_are_lids=False)[source]¶
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.
- Parameters:
file (str | bytes) – The image file to be uploaded and sent, either as a string URL or bytes.
caption (Optional[str], optional) – The caption for the image message, defaults to None.
quoted (Optional[neonize_proto.Message], optional) – The message to be quoted in the image message, defaults to None.
viewonce (bool, optional) – Whether the image message should be viewable only once, defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
- Returns:
The constructed image message.
- Return type:
Message
- async build_poll_vote(poll_info, option_names)[source]¶
Builds a poll vote.
- Parameters:
poll_info (MessageInfo) – The information about the poll.
option_names (List[str]) – The names of the options to vote for.
- Returns:
The poll vote message.
- Return type:
Message
- Raises:
BuildPollVoteError – If there is an error building the poll vote.
- async build_poll_vote_creation(name, options, selectable_count, quoted=None)[source]¶
Build a poll vote creation message.
- Parameters:
name (str) – The name of the poll.
options (List[str]) – The options for the poll.
selectable_count (int) – The number of selectable options.
quoted (Optional[neonize_proto.Message], optional) – A message that the poll message is a reply to, defaults to None
- Returns:
The poll vote creation message.
- Return type:
Message
- async build_reaction(chat, sender, message_id, reaction)[source]¶
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.
- Parameters:
chat (JID) – The ID of the chat in which the reaction is being made
sender (JID) – The ID of the sender making the reaction
message_id (str) – The ID of the message to which the reaction is being made
reaction (str) – The reaction being made
- Returns:
The reaction message
- Return type:
Message
- async build_reply_message(message, quoted, link_preview=False, reply_privately=False, ghost_mentions=None, mentions_are_lids=False)[source]¶
Send a reply message to a specified JID.
- Parameters:
message (Union[str, MessageWithContextInfo]) – The message to be sent. Can be a string or a MessageWithContextInfo object.
quoted (neonize_proto.Message) – The message to be quoted in the message being sent.
link_preview (bool, optional) – If set to True, enables link previews in the message being sent. Defaults to False.
reply_privately (bool, optional) – If set to True, the message is sent as a private reply. Defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
mentions_are_lids (bool, optional) – whether mentions contained in message or ghost_mentions are lids, defaults to False.
- Returns:
Response of the send operation.
- Return type:
SendResponse
- async build_revoke(chat, sender, message_id)[source]¶
Builds a message to revoke a previous message.
- Parameters:
chat (JID) – The JID (Jabber Identifier) of the chat where the message should be revoked.
sender (JID) – The JID of the sender of the message to be revoked.
message_id (str) – The unique identifier of the message to be revoked.
- Returns:
The constructed Message object for revoking the specified message.
- Return type:
Message
- async build_sticker_message(file, quoted=None, name='', packname='', crop=False, enforce_not_broken=False, animated_gif=False, passthrough=False)[source]¶
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.
- Parameters:
file (Union[str, bytes]) – The path to the image or video file or the file data in bytes
quoted (Optional[neonize_proto.Message], optional) – A message that the sticker message is a reply to, defaults to None
name (str, optional) – The name of the sticker, defaults to “”
packname (str, optional) – The name of the sticker pack, defaults to “”
crop (bool, optional) – Crop-center the image, defaults to False
enforce_not_broken (bool, optional) – Enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
animated_gif (bool, optional) – Ensure transparent media are properly processed, defaults to False
passthrough (bool, optional) – Don’t process sticker, send as is, defaults to False.
- Returns:
The constructed sticker message
- Return type:
Message
- async build_stickerpack_message(files, quoted=None, packname='Sticker pack', publisher='', crop=False, animated_gif=False, passthrough=False)[source]¶
- Return type:
List
[Message
]
- async build_video_message(file, caption=None, quoted=None, viewonce=False, gifplayback=False, is_gif=False, ghost_mentions=None, mentions_are_lids=False)[source]¶
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.
- Parameters:
file (str | bytes) – The file path or bytes of the video file to be uploaded.
caption (Optional[str], optional) – The caption to be added to the video message, defaults to None
quoted (Optional[neonize_proto.Message], optional) – A message that the video message is in response to, defaults to None
viewonce (bool, optional) – A flag indicating if the video message can be viewed only once, defaults to False
gifplayback (bool, optional) – Optional. Whether the video should be sent as gif. Defaults to False.
is_gif (bool, optional) – Optional. Whether the video to be sent is a gif. Defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
- Returns:
A video message with the given parameters.
- Return type:
Message
- async create_group(name, participants=[], linked_parent=None, group_parent=None)[source]¶
Create a new group.
- Parameters:
name (str) – The name of the new group.
participants (List[JID], optional) – Optional. A list of participant JIDs (Jabber Identifiers) to be included in the group. Defaults to an empty list.
linked_parent (Optional[GroupLinkedParent], optional) – Optional. Information about a linked parent group, if applicable. Defaults to None.
group_parent (Optional[GroupParent], optional) – Optional. Information about a parent group, if applicable. Defaults to None.
- Returns:
Information about the newly created group.
- Return type:
GroupInfo
- async create_newsletter(name, description, picture)[source]¶
Create a newsletter with the given name, description, and picture.
- Parameters:
name (str) – The name of the newsletter.
description (str) – The description of the newsletter.
picture (Union[str, bytes]) – The picture of the newsletter. It can be either a URL or bytes.
- Returns:
The metadata of the created newsletter.
- Return type:
NewsletterMetadata
- Raises:
CreateNewsletterError – If there is an error creating the newsletter.
- async download_any(message, path=None)[source]¶
Downloads content from a message.
- Parameters:
message (Message) – The message containing the content to download.
path (Optional[str], optional) – Optional. The local path to save the downloaded content, defaults to None.
- Raises:
DownloadException – Raised if there is an issue with the download.
- Returns:
The downloaded content as bytes, or None if the content is not available.
- Return type:
Union[None, bytes]
- async download_media_with_path(direct_path, enc_file_hash, file_hash, media_key, file_length, media_type, mms_type)[source]¶
Downloads media with the given parameters and path. The media is downloaded from the path specified.
- Parameters:
direct_path (str) – The direct path to the media to be downloaded.
enc_file_hash (bytes) – The encrypted hash of the file.
file_hash (bytes) – The hash of the file.
media_key (bytes) – The key of the media to be downloaded.
file_length (int) – The length of the file to be downloaded.
media_type (MediaType) – The type of the media to be downloaded.
mms_type (str) – The type of the MMS to be downloaded.
- Raises:
DownloadError – If there is an error in the download process.
- Returns:
The downloaded media in bytes.
- Return type:
bytes
- async edit_message(chat, message_id, new_message)[source]¶
Edit a message.
- Parameters:
chat (JID) – Chat ID
message_id (str) – Message ID
new_message (Message) – New message
- Returns:
Response from server
- Return type:
SendResponse
- async follow_newsletter(jid)[source]¶
Follows a newsletter with the given JID.
- Parameters:
jid (JID) – The JID of the newsletter to follow.
- Returns:
None
- Return type:
None
- Raises:
FollowNewsletterError – If there is an error following the newsletter.
- async generate_message_id()[source]¶
Generates a unique identifier for a message.
- Returns:
A string representing the unique identifier for the message.
- Return type:
str
- async get_blocklist()[source]¶
Retrieves the blocklist from the client.
- Return type:
Blocklist
- Returns:
Blocklist: The retrieved blocklist.
- Raises:
GetBlocklistError – If there was an error retrieving the blocklist.
- async get_contact_qr_link(revoke=False)[source]¶
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.
- Parameters:
revoke (bool, optional) – If set to True, revokes the existing QR link and generates a new one. Defaults to False.
- Raises:
GetContactQrLinkError – If there is an error in getting the QR link.
- Returns:
The QR link for the contact.
- Return type:
str
- async get_group_info(jid)[source]¶
Retrieves information about a group.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the group.
- Raises:
GetGroupInfoError – Raised if there is an issue retrieving group information.
- Returns:
Information about the specified group.
- Return type:
GroupInfo
- async get_group_info_from_invite(jid, inviter, code, expiration)[source]¶
Retrieves group information from an invite.
- Parameters:
jid (JID) – The JID (Jabber ID) of the group.
inviter (JID) – The JID of the user who sent the invite.
code (str) – The invite code.
expiration (int) – The expiration time of the invite.
- Returns:
The group information.
- Return type:
GroupInfo
- Raises:
GetGroupInfoError – If there is an error retrieving the group information.
- async get_group_info_from_link(code)[source]¶
Retrieves group information from a given link.
- Parameters:
code (str) – The link code.
- Returns:
An object containing the group information.
- Return type:
GroupInfo
- Raises:
GetGroupInfoError – If there is an error retrieving the group information.
- async get_group_invite_link(jid, revoke=False)[source]¶
Gets or revokes the invite link for a group.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the group.
revoke (bool, optional) – Optional. If True, revokes the existing invite link; if False, gets the invite link. Defaults to False.
- Raises:
GetGroupInviteLinkError – Raised if there is an issue getting or revoking the invite link.
- Returns:
The group invite link or an error status.
- Return type:
str
- async get_group_request_participants(jid)[source]¶
Get the participants of a group request.
- Parameters:
jid (JID) – The JID of the group request.
- Returns:
A list of JIDs representing the participants of the group request.
- Return type:
RepeatedCompositeFieldContainer[JID]
- async get_joined_groups()[source]¶
Get the joined groups for the current user.
- Returns:
A list of
GroupInfo
objects representing the joined groups.- Return type:
RepeatedCompositeFieldContainer[GroupInfo]
- Raises:
GetJoinedGroupsError – If there was an error retrieving the joined groups.
- async get_lid_from_pn(jid)[source]¶
Retrieves the matching lid from the supplied jid.
- Parameters:
jid (JID) – The JID (Jabber Identifier) (pn) of the target user.
- Raises:
GetJIDFromStoreError – Raised if there is an issue getting the lid from the given jid.
- Returns:
The lid (hidden user) matching the supplied jid.
- Return type:
JID
- async get_linked_group_participants(community)[source]¶
Fetches the participants of a linked group in a community.
- Parameters:
community (JID) – The community in which the linked group belongs.
- Raises:
GetLinkedGroupParticipantsError – If there is an error while fetching the participants.
- Returns:
A list of participants in the linked group.
- Return type:
RepeatedCompositeFieldContainer[JID]
- async get_me()[source]¶
This method is used to get the device information associated with a given UUID.
- Returns:
It returns a Device object created from the byte string response from the client’s GetMe method.
- Return type:
Device
- async get_message_for_retry(requester, to, message_id)[source]¶
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.
- Parameters:
requester (JID) – The JID of the entity requesting the message.
to (JID) – The JID of the intended recipient of the message.
message_id (str) – The unique identifier of the message to be retrieved.
- Returns:
The message to be retried if found, None otherwise.
- Return type:
Union[None, Message]
- async get_newsletter_info(jid)[source]¶
Fetches the metadata of a specific newsletter using its JID.
- Parameters:
jid (JID) – The unique identifier of the newsletter
- Raises:
GetNewsletterInfoError – If there is an error while fetching the newsletter information
- Returns:
The metadata of the requested newsletter
- Return type:
neonize_proto.NewsletterMetadata
- async get_newsletter_info_with_invite(key)[source]¶
Retrieves the newsletter information with an invite using the provided key.
- Parameters:
key (str) – The key used to identify the newsletter.
- Returns:
The newsletter metadata.
- Return type:
NewsletterMetadata
- Raises:
GetNewsletterInfoWithInviteError – If there is an error retrieving the newsletter information.
- async get_newsletter_message_update(jid, count, since, after)[source]¶
Retrieves a list of newsletter messages that have been updated since a given timestamp.
- Parameters:
jid (JID) – The JID (Jabber ID) of the user.
count (int) – The maximum number of messages to retrieve.
since (int) – The timestamp (in milliseconds) to retrieve messages from.
after (int) – The timestamp (in milliseconds) to retrieve messages after.
- Returns:
A list of updated newsletter messages.
- Return type:
RepeatedCompositeFieldContainer[NewsletterMessage]
- Raises:
GetNewsletterMessageUpdateError – If there was an error retrieving the newsletter messages.
- async get_newsletter_messages(jid, count, before)[source]¶
Retrieves a list of newsletter messages for a given JID.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the user.
count (int) – The maximum number of messages to retrieve.
before (MessageServerID) – The ID of the message before which to retrieve messages.
- Returns:
A list of newsletter messages.
- Return type:
RepeatedCompositeFieldContaine[NewsletterMessage]
- async get_pn_from_lid(jid)[source]¶
Retrieves the matching jid from the supplied lid.
- Parameters:
jid (JID) – The JID (Jabber Identifier) (lid) of the target user.
- Raises:
GetJIDFromStoreError – Raised if there is an issue getting the jid from the given lid.
- Returns:
The jid (phone number) matching the supplied lid.
- Return type:
JID
- async get_privacy_settings()[source]¶
This function retrieves the my privacy settings.
- Returns:
privacy settings
- Return type:
PrivacySettings
- async get_profile_picture(jid, extra=)[source]¶
This function is used to get the profile picture of a user.
- Parameters:
jid (JID) – The unique identifier of the user whose profile picture we want to retrieve.
extra (neonize_proto.GetProfilePictureParams, optional) – Additional parameters, defaults to neonize_proto.GetProfilePictureParams()
- Raises:
GetProfilePictureError – If there is an error while trying to get the profile picture.
- Returns:
The information about the profile picture.
- Return type:
ProfilePictureInfo
- async get_status_privacy()[source]¶
Returns the status privacy settings of the user.
- Raises:
GetStatusPrivacyError – If there is an error in getting the status privacy.
- Returns:
The status privacy settings of the user.
- Return type:
RepeatedCompositeFieldContainer[StatusPrivacy]
- async get_sub_groups(community)[source]¶
Get the subgroups of a given community.
- Parameters:
community (JID) – The community for which to get the subgroups.
- Raises:
GetSubGroupsError – If there is an error while getting the subgroups.
- Returns:
The subgroups of the given community.
- Return type:
RepeatedCompositeFieldContainer[GroupLinkTarget]
- async get_subscribed_newletters()[source]¶
This function retrieves the newsletters the user has subscribed to.
- Raises:
GetSubscribedNewslettersError – If there is an error while fetching the subscribed newsletters
- Returns:
A container with the metadata of each subscribed newsletter
- Return type:
RepeatedCompositeFieldContainer[NewsletterMetadata]
- async get_user_devices(*jids)[source]¶
Retrieve devices associated with specified user JIDs.
- Parameters:
jids (JID) – Variable number of JIDs (Jabber Identifiers) of users.
- Raises:
GetUserDevicesError – If there is an error retrieving user devices.
- Returns:
Devices associated with the specified user JIDs.
- Return type:
RepeatedCompositeFieldContainer[JID]
- async get_user_info(*jid)[source]¶
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.
- Parameters:
jid (JID) – JID of the users to retrieve information from
- Raises:
GetUserInfoError – If there is an error in the model returned by the client
- Returns:
The user information for each JID
- Return type:
RepeatedCompositeFieldContainer[GetUserInfoSingleReturnFunction]
- property is_connected: bool¶
Check if the object is currently connected.
- Returns:
True if the object is connected, False otherwise.
- Return type:
bool
- property is_logged_in: bool¶
Check if the user is currently logged in.
- Returns:
True if the user is logged in, False otherwise.
- Return type:
bool
- async is_on_whatsapp(*numbers)[source]¶
This function checks if the provided phone numbers are registered with WhatsApp.
- Parameters:
numbers (str) – A series of phone numbers to be checked.
- Raises:
IsOnWhatsAppError – If an error occurs while verifying the phone numbers.
- Returns:
A list of responses, each indicating whether the corresponding number is registered with WhatsApp.
- Return type:
Sequence[IsOnWhatsAppResponse]
- async join_group_with_invite(jid, inviter, code, expiration)[source]¶
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.
- Parameters:
jid (JID) – The JID of the group to join.
inviter (JID) – The JID of the person who sent the invite.
code (str) – The invitation code.
expiration (int) – The expiration time of the invitation code in seconds.
- Raises:
JoinGroupWithInviteError – If there is an error in joining the group, such as an invalid code or expired invitation.
- async join_group_with_link(code)[source]¶
Join a group using an invite link.
- Parameters:
code (str) – The invite code or link for joining the group.
- Raises:
InviteLinkError – Raised if the group membership is pending approval or if the link is invalid.
- Returns:
The JID (Jabber Identifier) of the joined group.
- Return type:
JID
- async leave_group(jid)[source]¶
Leaves a group.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the target group.
- Returns:
A string indicating the result or an error status. Empty string if successful.
- Return type:
str
- async link_group(parent, child)[source]¶
Links a child group to a parent group.
- Parameters:
parent (JID) – The JID of the parent group
child (JID) – The JID of the child group
- Raises:
LinkGroupError – If there is an error while linking the groups
- async mark_read(*message_ids, chat, sender, receipt, timestamp=None)[source]¶
Marks the specified messages as read.
- Parameters:
message_ids (str) – Identifiers of the messages to mark as read.
chat (JID) – The JID of the chat.
sender (JID) – The JID of the sender.
receipt (ReceiptType) – The type of receipt indicating the message status.
timestamp (Optional[int], optional) – The timestamp of the read action, defaults to None.
- Raises:
MarkReadError – If there is an error marking messages as read.
- async newsletter_mark_viewed(jid, message_server_ids)[source]¶
Marks the specified newsletters as viewed by the user with the given JID.
- Parameters:
jid (JID) – The JID (Jabber ID) of the user who has viewed the newsletters.
message_server_ids (List[MessageServerID]) – List of server IDs of the newsletters that have been viewed.
- Raises:
NewsletterMarkViewedError – If an error occurs while marking the newsletters as viewed.
- async newsletter_send_reaction(jid, message_server_id, reaction, message_id)[source]¶
Sends a reaction to a newsletter.
- Parameters:
jid (JID) – The unique identifier for the recipient of the newsletter.
message_server_id (MessageServerID) – The unique identifier for the server where the message is stored.
reaction (str) – The reaction to be sent.
message_id (str) – The unique identifier for the message to which the reaction is being sent.
- Raises:
NewsletterSendReactionError – If an error occurs while sending the reaction.
- async newsletter_subscribe_live_updates(jid)[source]¶
Subscribes a user to live updates of a newsletter.
- Parameters:
jid (JID) – The unique identifier of the user subscribing to the newsletter.
- Raises:
NewsletterSubscribeLiveUpdatesError – If there is an error during the subscription process.
- Returns:
The duration for which the subscription is valid.
- Return type:
int
- async newsletter_toggle_mute(jid, mute)[source]¶
Toggle the mute status of a given JID.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the user.
mute (bool) – The desired mute status. If True, the user will be muted. If False, the user will be unmuted.
- Raises:
NewsletterToggleMuteError – If there is an error while toggling the mute status.
- async reply_message(message, quoted, to=None, link_preview=False, reply_privately=False, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Send a reply message to a specified JID.
- Parameters:
message (Union[str, MessageWithContextInfo]) – The message to be sent. Can be a string or a MessageWithContextInfo object.
quoted (neonize_proto.Message) – The message to be quoted in the message being sent.
to (Optional[JID], optional) – The recipient of the message. If not specified, the message is sent to the default recipient.
link_preview (bool, optional) – If set to True, enables link previews in the message being sent. Defaults to False.
reply_privately (bool, optional) – If set to True, the message is sent as a private reply. Defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
mentions_are_lids (bool, optional) – whether mentions contained in message or ghost_mentions are lids, defaults to False.
add_msg_secret (bool, optional) – If set to True generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
Response of the send operation.
- Return type:
SendResponse
- async resolve_business_message_link(code)[source]¶
Resolves the target of a business message link.
- Parameters:
code (str) – The code of the business message link to be resolved.
- Raises:
ResolveContactQRLinkError – If an error occurs while resolving the link.
- Returns:
The target of the business message link.
- Return type:
neonize_proto.BusinessMessageLinkTarget
- async resolve_contact_qr_link(code)[source]¶
Resolves a QR link for a specific contact.
- Parameters:
code (str) – The QR code to be resolved.
- Raises:
ResolveContactQRLinkError – If an error occurs while resolving the QR link.
- Returns:
The target contact of the QR link.
- Return type:
neonize_proto.ContactQRLinkTarget
- async revoke_message(chat, sender, message_id)[source]¶
Revoke a message.
- Parameters:
chat (JID) – Chat ID
sender (JID) – Sender ID
message_id (str) – Message ID
- Returns:
Response from server
- Return type:
SendResponse
- async send_album(to, files, caption=None, quoted=None, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Sends an album containing images, videos or both to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
files – A list containing either a file path (str), url (str) or binary data (bytes) representing the image/video.
caption (Optional[str], optional) – Optional. The caption of the first media in the album. Defaults to None.
quoted (Optional[Message], optional) – Optional. The message to which the album is a reply. Defaults to None.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
add_msg_secret (bool, optional) – Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A function for handling the result of the album sending process.
- Return type:
List[SendResponse, List[SendResponse]]
- async send_app_state(patch_info)[source]¶
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.
- Parameters:
patch_info (neonize_proto.PatchInfo) – Contains the information about the application state that needs to be patched.
- Raises:
SendAppStateError – If there’s an error while sending the application state, this exception is raised.
- async send_audio(to, file, ptt=False, quoted=None, add_msg_secret=False)[source]¶
Sends an audio to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
file (Union[str | bytes]) – Either a file path (str), url (str) or binary data (bytes) representing the audio.
ptt (bool, optional) – Optional. Whether the audio should be ptt. Defaults to False.
quoted (Optional[Message], optional) – Optional. The message to which the audio is a reply. Defaults to None.
add_msg_secret (bool, optional) – Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A function for handling the result of the audio sending process.
- Return type:
SendResponse
- async send_chat_presence(jid, state, media)[source]¶
Sends chat presence information.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the chat.
state (ChatPresence) – The chat presence state.
media (ChatPresenceMedia) – The chat presence media information.
- Returns:
A string indicating the result or status of the presence information sending.
- Return type:
str
- async send_contact(to, contact_name, contact_number, quoted=None)[source]¶
Sends a contact to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
contact_name (str) – The name of the contact.
contact_number (str) – The number of the contact.
quoted (Optional[Message], optional) – Optional. The message to which the contact is a reply. Defaults to None.
- Returns:
A function for handling the result of the contact sending process.
- Return type:
SendResponse
- async send_document(to, file, caption=None, title=None, filename=None, mimetype=None, quoted=None, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Sends a document to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
file (Union[str | bytes]) – Either a file path (str), url (str) or binary data (bytes) representing the document.
caption (Optional[str], optional) – Optional. The caption of the document. Defaults to None.
title (Optional[str], optional) – Optional. The title of the document. Defaults to None.
filename (Optional[str], optional) – Optional. The filename of the document. Defaults to None.
quoted (Optional[Message], optional) – Optional. The message to which the document is a reply. Defaults to None.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
add_msg_secret (bool, optional) – Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A function for handling the result of the document sending process.
- Return type:
SendResponse
- async send_image(to, file, caption=None, quoted=None, viewonce=False, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Sends an image to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
file (Union[str | bytes]) – Either a file path (str), url (str) or binary data (bytes) representing the image.
caption (Optional[str], optional) – Optional. The caption of the image. Defaults to None.
quoted (Optional[Message], optional) – Optional. The message to which the image is a reply. Defaults to None.
viewonce (bool, optional) – Optional. Whether the image should be viewonce. Defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
add_msg_secret (bool, optional) – Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A function for handling the result of the image sending process.
- Return type:
SendResponse
- async send_message(to, message, link_preview=False, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Send a message to the specified JID.
- Parameters:
to (JID) – The JID to send the message to.
message (Union[Message, str]) – The message to send.
link_preview (bool, optional) – Whether to send a link preview, defaults to False
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
mentions_are_lids (bool, optional) – whether mentions contained in message or ghost_mentions are lids, defaults to False.
add_msg_secret (bool, optional) – Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Raises:
SendMessageError – If there was an error sending the message.
- Returns:
The response from the server.
- Return type:
SendResponse
- async send_sticker(to, file, quoted=None, name='', packname='', crop=False, enforce_not_broken=False, animated_gif=False, passthrough=False, add_msg_secret=False)[source]¶
Send a sticker to a specific JID.
- Parameters:
to (JID) – The JID to send the sticker to.
file (Union[str, bytes]) – The file path of the sticker or the sticker data in bytes.
quoted (Optional[neonize_proto.Message], optional) – The quoted message, if any, defaults to None.
name (str, optional) – The name of the sticker, defaults to “”.
packname (str, optional) – The name of the sticker pack, defaults to “”.
crop (bool, optional) – Whether to crop-center the image, defaults to False
enforce_not_broken (bool, optional) – Whether to enforce non-broken stickers by constraining sticker size to WA limits, defaults to False
animated_gif (bool, optional) – Ensure transparent media are properly processed, defaults to False
passthrough (bool, optional) – Don’t process sticker, send as is, defaults to False.
add_msg_secret (bool, optional) – Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
The response from the send message function.
- Return type:
SendResponse
- async send_stickerpack(to, files, quoted=None, packname='Sticker pack', publisher='', crop=False, animated_gif=False, passthrough=False, add_msg_secret=False)[source]¶
Send a sticker pack to a specific JID.
- Parameters:
to (JID) – The JID to send the sticker to.
files (
list
) – A list of file paths of the stickers or a list of stickers data in bytes.quoted (Optional[neonize_proto.Message], optional) – The quoted message, if any, defaults to None.
packname (str, optional) – The name of the sticker pack, defaults to “Sticker pack”.
publisher (str, optional) – The name of the publisher, defaults to “”.
crop (bool, optional) – Whether to crop-center the image, defaults to False
add_msg_secret (bool, optional) – Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A list of response(s) from the send message function.
- Return type:
List[SendResponse]
- async send_video(to, file, caption=None, quoted=None, viewonce=False, gifplayback=False, is_gif=False, ghost_mentions=None, mentions_are_lids=False, add_msg_secret=False)[source]¶
Sends a video to the specified recipient.
- Parameters:
to (JID) – The JID (Jabber Identifier) of the recipient.
file (Union[str | bytes]) – Either a file path (str), url (str) or binary data (bytes) representing the video.
caption (Optional[str], optional) – Optional. The caption of the video. Defaults to None.
quoted (Optional[Message], optional) – Optional. The message to which the video is a reply. Defaults to None.
viewonce (bool, optional) – Optional. Whether the video should be viewonce. Defaults to False.
gifplayback (bool, optional) – Optional. Whether the video should be sent as gif. Defaults to False.
is_gif (bool, optional) – Optional. Whether the video to be sent is a gif. Defaults to False.
ghost_mentions (str, optional) – List of users to tag silently (Takes precedence over auto detected mentions)
add_msg_secret (bool, optional) – Optional. Whether to generate 32 random bytes for messageSecret inside MessageContextInfo before sending, defaults to False
- Returns:
A function for handling the result of the video sending process.
- Return type:
SendResponse
- async set_default_disappearing_timer(timer)[source]¶
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.
- Parameters:
timer (Union[timedelta, int]) – The duration for messages to exist before disappearing. Can be a timedelta or an integer.
- Raises:
SetDefaultDisappearingTimerError – If an error occurs while setting the disappearing timer.
- async set_disappearing_timer(jid, timer)[source]¶
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.
- Parameters:
jid (JID) – The JID for which the disappearing timer is to be set
timer (Union[timedelta, int]) – The duration for the disappearing timer. Can be a timedelta object or an integer representing nanoseconds.
- Raises:
SetDisappearingTimerError – If there is an error in setting the disappearing timer
- async set_force_activate_delivery_receipts(active)[source]¶
This method is used to forcibly activate or deactivate the delivery receipts for a client.
- Parameters:
active (bool) – 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.
- async set_group_announce(jid, announce)[source]¶
Sets the announcement status of a group.
- Parameters:
jid (JID) – The unique identifier of the group
announce (bool) – The announcement status to be set. If True, announcements are enabled. If False, they are disabled.
- Raises:
SetGroupAnnounceError – If there is an error while setting the announcement status
- async set_group_locked(jid, locked)[source]¶
Sets the locked status of a group identified by the given JID.
- Parameters:
jid (JID) – The JID (Jabber ID) of the group to be locked/unlocked.
locked (bool) – The new locked status of the group. True to lock the group, False to unlock.
- Raises:
SetGroupLockedError – If the operation fails, an error with the reason for the failure is raised.
- async set_group_name(jid, name)[source]¶
Sets the name of a group.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the group.
name (str) – The new name to be set for the group.
- Returns:
A string indicating the result or an error status. Empty string if successful.
- Return type:
str
- async set_group_photo(jid, file_or_bytes)[source]¶
Sets the photo of a group.
- Parameters:
jid (JID) – The JID (Jabber Identifier) of the group.
file_or_bytes (Union[str, bytes]) – Either a file path (str) or binary data (bytes) representing the group photo.
- Raises:
SetGroupPhotoError – Raised if there is an issue setting the group photo.
- Returns:
A string indicating the result or an error status.
- Return type:
str
- async set_group_topic(jid, previous_id, new_id, topic)[source]¶
Set the topic of a group in a chat application.
- Parameters:
jid (JID) – The unique identifier of the group
previous_id (str) – The previous identifier of the topic
new_id (str) – The new identifier for the topic
topic (str) – The new topic to be set
- Raises:
SetGroupTopicError – If there is an error setting the group topic
- async set_passive(passive)[source]¶
Sets the passive mode of the client.
- Parameters:
passive (bool) – If True, sets the client to passive mode. If False, sets the client to active mode.
- Raises:
SetPassiveError – If an error occurs while setting the client to passive mode.
- async set_privacy_setting(name, value)[source]¶
This method is used to set the privacy settings of a user.
- Parameters:
name (PrivacySettingType) – The name of the privacy setting to be changed.
value (PrivacySetting) – The new value for the privacy setting.
- Raises:
SetPrivacySettingError – If there is an error while setting the privacy setting.
- async set_profile_photo(file_or_bytes)[source]¶
Sets profile photo.
- Parameters:
file_or_bytes (Union[str, bytes]) – Either a file path (str) or binary data (bytes) representing the group photo.
- Raises:
SetGroupPhotoError – Raised if there is an issue setting the profile photo.
- Returns:
A string indicating the result or an error status.
- Return type:
str
- async set_status_message(msg)[source]¶
Sets a status message for a client using the client’s UUID.
- Parameters:
msg (str) – The status message to be set.
- Raises:
SetStatusMessageError – If there is an error while setting the status message.
- async subscribe_presence(jid)[source]¶
This method is used to subscribe to the presence of a certain JID (Jabber ID).
- Parameters:
jid (JID) – The Jabber ID (JID) that we want to subscribe to.
- Raises:
SubscribePresenceError – If there is an error while subscribing to the presence of the JID.
- async unfollow_newsletter(jid)[source]¶
Unfollows a newsletter by providing the JID (Jabber ID) of the newsletter.
- Parameters:
jid (JID) – The Jabber ID of the newsletter to unfollow.
- Raises:
UnfollowNewsletterError – If there is an error while attempting to unfollow the newsletter.
- async unlink_group(parent, child)[source]¶
This method is used to unlink a child group from a parent group.
- Parameters:
parent (JID) – The JID of the parent group from which the child group is to be unlinked.
child (JID) – The JID of the child group which is to be unlinked from the parent group.
- Raises:
UnlinkGroupError – If there is an error while unlinking the child group from the parent group.
- async update_blocklist(jid, action)[source]¶
Function to update the blocklist with a given action on a specific JID.
- Parameters:
jid (JID) – The Jabber ID (JID) of the user to be blocked or unblocked.
action (BlocklistAction) – The action to be performed (block or unblock) on the JID.
- Raises:
UpdateBlocklistError – If there is an error while updating the blocklist.
- Returns:
The updated blocklist.
- Return type:
Blocklist
- async update_group_participants(jid, participants_changes, action)[source]¶
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.
- Parameters:
jid (JID) – The JID (Jabber ID) of the group to update.
participants_changes (List[JID]) – A list of JIDs representing the participants to be added or removed.
action (ParticipantChange) – The action to perform (add, remove, promote or demote participants).
- Raises:
UpdateGroupParticipantsError – This error is raised if there is a problem updating the group participants.
- Returns:
A list of the updated group participants.
- Return type:
RepeatedCompositeFieldContainer[GroupParticipant]
- async upload(binary, media_type=None)[source]¶
Uploads media content.
- Parameters:
binary (bytes) – The binary data to be uploaded.
media_type (Optional[MediaType], optional) – Optional. The media type of the binary data, defaults to None.
- Raises:
UploadError – Raised if there is an issue with the upload.
- Returns:
An UploadResponse containing information about the upload.
- Return type:
UploadResponse
- async upload_newsletter(data, media_type)[source]¶
Uploads the newsletter to the server.
- Parameters:
data (bytes) – The newsletter content in bytes.
media_type (MediaType) – The type of media being uploaded.
- Raises:
UploadError – If there is an error during the upload process.
- Returns:
The response from the server after the upload.
- Return type:
UploadResponse
neonize.aioze.events module¶
- neonize.aioze.events.BlocklistChangeEv¶
alias of
BlocklistChange
- neonize.aioze.events.BlocklistEv¶
alias of
BlocklistEvent
- neonize.aioze.events.CallAcceptEv¶
alias of
CallAccept
- neonize.aioze.events.CallOfferEv¶
alias of
CallOffer
- neonize.aioze.events.CallOfferNoticeEv¶
alias of
CallOfferNotice
- neonize.aioze.events.CallPreAcceptEv¶
alias of
CallPreAccept
- neonize.aioze.events.CallRelayLatencyEv¶
alias of
CallRelayLatency
- neonize.aioze.events.CallTerminateEv¶
alias of
CallTerminate
- neonize.aioze.events.CallTransportEv¶
alias of
CallTransport
- neonize.aioze.events.ChatPresenceEv¶
alias of
ChatPresence
- neonize.aioze.events.ClientOutdatedEv¶
alias of
ClientOutdated
- neonize.aioze.events.ConnectFailureEv¶
alias of
ConnectFailure
- neonize.aioze.events.ConnectedEv¶
alias of
Connected
- neonize.aioze.events.DisconnectedEv¶
alias of
Disconnected
- neonize.aioze.events.GroupInfoEv¶
alias of
GroupInfoEvent
- neonize.aioze.events.HistorySyncEv¶
alias of
HistorySync
- neonize.aioze.events.IdentityChangeEv¶
alias of
IdentityChange
- neonize.aioze.events.JoinedGroupEv¶
alias of
JoinedGroup
- neonize.aioze.events.KeepAliveRestoredEv¶
alias of
KeepAliveRestored
- neonize.aioze.events.KeepAliveTimeoutEv¶
alias of
KeepAliveTimeout
- neonize.aioze.events.LoggedOutEv¶
alias of
LoggedOut
- neonize.aioze.events.MessageEv¶
alias of
Message
- neonize.aioze.events.NewsLetterMessageMetaEv¶
alias of
NewsLetterMessageMeta
- neonize.aioze.events.NewsletterJoinEv¶
alias of
NewsletterJoin
- neonize.aioze.events.NewsletterLeaveEv¶
alias of
NewsletterLeave
- neonize.aioze.events.NewsletterLiveUpdateEv¶
alias of
NewsletterLiveUpdate
- neonize.aioze.events.NewsletterMuteChangeEv¶
alias of
NewsletterMuteChange
- neonize.aioze.events.OfflineSyncCompletedEv¶
alias of
OfflineSyncCompleted
- neonize.aioze.events.OfflineSyncPreviewEv¶
alias of
OfflineSyncPreview
- neonize.aioze.events.PairStatusEv¶
alias of
PairStatus
- neonize.aioze.events.PictureEv¶
alias of
Picture
- neonize.aioze.events.PresenceEv¶
alias of
Presence
- neonize.aioze.events.PrivacySettingsEv¶
alias of
privacySettingsEvent
- neonize.aioze.events.QREv¶
alias of
QR
- neonize.aioze.events.ReceiptEv¶
alias of
Receipt
- neonize.aioze.events.StreamErrorEv¶
alias of
StreamError
- neonize.aioze.events.StreamReplacedEv¶
alias of
StreamReplaced
- neonize.aioze.events.TemporaryBanEv¶
alias of
TemporaryBan
- neonize.aioze.events.UnknownCallEventEv¶
alias of
UnknownCallEvent