neonize package¶
Subpackages¶
- neonize.proto package
- neonize.utils package
- Submodules
- neonize.utils.calc module
- neonize.utils.enum module
BlocklistAction
ChatPresence
ChatPresenceMedia
ClientName
ClientType
ClientType.UNKNOWN
ClientType.CHROME
ClientType.EDGE
ClientType.FIREFOX
ClientType.IE
ClientType.OPERA
ClientType.SAFARI
ClientType.ELECTRON
ClientType.UWP
ClientType.OTHER
ClientType.CHROME
ClientType.EDGE
ClientType.ELECTRON
ClientType.FIREFOX
ClientType.IE
ClientType.OPERA
ClientType.OTHER
ClientType.SAFARI
ClientType.UNKNOWN
ClientType.UWP
ClientType.name
LogLevel
MediaType
MediaTypeToMMS
ParticipantChange
ParticipantRequestChange
Presence
PrivacySetting
PrivacySetting.UNDEFINED
PrivacySetting.ALL
PrivacySetting.CONTACTS
PrivacySetting.CONTACTS_BLACKLIST
PrivacySetting.MATCH_LAST_SEEN
PrivacySetting.KNOWN
PrivacySetting.NONE
PrivacySetting.ALL
PrivacySetting.CONTACTS
PrivacySetting.CONTACTS_BLACKLIST
PrivacySetting.KNOWN
PrivacySetting.MATCH_LAST_SEEN
PrivacySetting.NONE
PrivacySetting.UNDEFINED
PrivacySettingType
PrivacySettingType.GROUP_ADD
PrivacySettingType.LAST_SEEN
PrivacySettingType.STATUS
PrivacySettingType.PROFILE
PrivacySettingType.READ_RECEIPTS
PrivacySettingType.ONLINE
PrivacySettingType.CALL_ADD
PrivacySettingType.CALL_ADD
PrivacySettingType.GROUP_ADD
PrivacySettingType.LAST_SEEN
PrivacySettingType.ONLINE
PrivacySettingType.PROFILE
PrivacySettingType.READ_RECEIPTS
PrivacySettingType.STATUS
ReceiptType
ReceiptType.DELIVERED
ReceiptType.SENDER
ReceiptType.RETRY
ReceiptType.READ
ReceiptType.READ_SELF
ReceiptType.PLAYED
ReceiptType.PLAYED_SELF
ReceiptType.SERVER_ERROR
ReceiptType.INACTIVE
ReceiptType.PEER_MSG
ReceiptType.HISTORY_SYNC
ReceiptType.DELIVERED
ReceiptType.HISTORY_SYNC
ReceiptType.INACTIVE
ReceiptType.PEER_MSG
ReceiptType.PLAYED
ReceiptType.PLAYED_SELF
ReceiptType.READ
ReceiptType.READ_SELF
ReceiptType.RETRY
ReceiptType.SENDER
ReceiptType.SERVER_ERROR
- neonize.utils.ffmpeg module
AFFmpeg
FFProbeInfo
FFmpeg
Format
Format.filename
Format.nb_streams
Format.nb_programs
Format.format_name
Format.format_long_name
Format.start_time
Format.duration
Format.size
Format.probe_score
Format.tags
Format.duration
Format.filename
Format.format_long_name
Format.format_name
Format.nb_programs
Format.nb_streams
Format.probe_score
Format.size
Format.start_time
Format.tags
ImageFormat
Stream
Stream.index
Stream.codec_type
Stream.avg_frame_rate
Stream.codec_tag_string
Stream.start_pts
Stream.tags
Stream.extradata_size
Stream.start_time
Stream.disposition
Stream.codec_tag
Stream.time_base
Stream.codec_long_name
Stream.codec_name
Stream.r_frame_rate
Stream.closed_captions
Stream.color_range
Stream.display_aspect_ratio
Stream.color_transfer
Stream.is_avc
Stream.color_primaries
Stream.film_grain
Stream.color_space
Stream.refs
Stream.level
Stream.nal_length_size
Stream.chroma_location
Stream.has_b_frames
Stream.pix_fmt
Stream.sample_aspect_ratio
Stream.bits_per_raw_sample
Stream.profile
Stream.field_order
Stream.width
Stream.height
Stream.coded_width
Stream.coded_height
Stream.bits_per_sample
Stream.sample_fmt
Stream.channel_layout
Stream.initial_padding
Stream.channels
Stream.sample_rate
Stream.avg_frame_rate
Stream.bits_per_raw_sample
Stream.bits_per_sample
Stream.channel_layout
Stream.channels
Stream.chroma_location
Stream.closed_captions
Stream.codec_long_name
Stream.codec_name
Stream.codec_tag
Stream.codec_tag_string
Stream.codec_type
Stream.coded_height
Stream.coded_width
Stream.color_primaries
Stream.color_range
Stream.color_space
Stream.color_transfer
Stream.display_aspect_ratio
Stream.disposition
Stream.extradata_size
Stream.field_order
Stream.film_grain
Stream.has_b_frames
Stream.height
Stream.index
Stream.initial_padding
Stream.is_avc
Stream.level
Stream.nal_length_size
Stream.pix_fmt
Stream.profile
Stream.r_frame_rate
Stream.refs
Stream.sample_aspect_ratio
Stream.sample_fmt
Stream.sample_rate
Stream.start_pts
Stream.start_time
Stream.tags
Stream.time_base
Stream.width
- neonize.utils.iofile module
- neonize.utils.jid module
- neonize.utils.log module
- neonize.utils.message module
- neonize.utils.platform module
- neonize.utils.thumbnail module
- Module contents
AspectRatioMethod()
BlocklistAction
ChatPresence
ChatPresenceMedia
ClientName
ClientType
ClientType.UNKNOWN
ClientType.CHROME
ClientType.EDGE
ClientType.FIREFOX
ClientType.IE
ClientType.OPERA
ClientType.SAFARI
ClientType.ELECTRON
ClientType.UWP
ClientType.OTHER
ClientType.CHROME
ClientType.EDGE
ClientType.ELECTRON
ClientType.FIREFOX
ClientType.IE
ClientType.OPERA
ClientType.OTHER
ClientType.SAFARI
ClientType.UNKNOWN
ClientType.UWP
ClientType.name
FFmpeg
JIDToNonAD()
Jid2String()
MediaType
MediaTypeToMMS
ParticipantChange
ParticipantRequestChange
PrivacySetting
PrivacySetting.UNDEFINED
PrivacySetting.ALL
PrivacySetting.CONTACTS
PrivacySetting.CONTACTS_BLACKLIST
PrivacySetting.MATCH_LAST_SEEN
PrivacySetting.KNOWN
PrivacySetting.NONE
PrivacySetting.ALL
PrivacySetting.CONTACTS
PrivacySetting.CONTACTS_BLACKLIST
PrivacySetting.KNOWN
PrivacySetting.MATCH_LAST_SEEN
PrivacySetting.NONE
PrivacySetting.UNDEFINED
PrivacySettingType
PrivacySettingType.GROUP_ADD
PrivacySettingType.LAST_SEEN
PrivacySettingType.STATUS
PrivacySettingType.PROFILE
PrivacySettingType.READ_RECEIPTS
PrivacySettingType.ONLINE
PrivacySettingType.CALL_ADD
PrivacySettingType.CALL_ADD
PrivacySettingType.GROUP_ADD
PrivacySettingType.LAST_SEEN
PrivacySettingType.ONLINE
PrivacySettingType.PROFILE
PrivacySettingType.READ_RECEIPTS
PrivacySettingType.STATUS
ReceiptType
ReceiptType.DELIVERED
ReceiptType.SENDER
ReceiptType.RETRY
ReceiptType.READ
ReceiptType.READ_SELF
ReceiptType.PLAYED
ReceiptType.PLAYED_SELF
ReceiptType.SERVER_ERROR
ReceiptType.INACTIVE
ReceiptType.PEER_MSG
ReceiptType.HISTORY_SYNC
ReceiptType.DELIVERED
ReceiptType.HISTORY_SYNC
ReceiptType.INACTIVE
ReceiptType.PEER_MSG
ReceiptType.PLAYED
ReceiptType.PLAYED_SELF
ReceiptType.READ
ReceiptType.READ_SELF
ReceiptType.RETRY
ReceiptType.SENDER
ReceiptType.SERVER_ERROR
add_exif()
build_jid()
extract_text()
gen_vcard()
get_bytes_from_name_or_url()
get_message_type()
save_file_to_temp_directory()
validate_link()
Submodules¶
neonize.builder module¶
- neonize.builder.build_edit(chat, message_id, new_message)[source]¶
This function builds an edited message in the WhatsApp protocol format.
- Parameters:
chat (neonize.JID) – The JID (Jabber ID) of the chat where the message will be sent.
message_id (str) – The unique identifier of the message to be edited.
new_message (waProto.Message) – The new message content that will replace the old message.
- Returns:
The constructed message in the WhatsApp protocol format.
- Return type:
waProto.Message
- neonize.builder.build_history_sync_request(message_info, count)[source]¶
Builds a history sync request message.
- Parameters:
message_info (neonize.MessageInfo) – Information about the message to sync from.
count (int) – Number of messages to sync.
- Returns:
A constructed Message object for history sync.
- Return type:
Message
- neonize.builder.build_revoke(chat, sender, id, myJID)[source]¶
This function builds and returns a protocol message of type ‘REVOKE’ with given parameters.
- Parameters:
chat (neonize.JID) – The chat ID where the message is to be revoked
sender (neonize.JID) – The sender’s ID who is revoking the message
id (str) – The ID of the message to be revoked
myJID (neonize.JID) – The ID of the user using the application
- Returns:
A protocol message of type ‘REVOKE’
- Return type:
waProto.Message
neonize.client module¶
- class neonize.client.ChatSettingsStore(uuid)[source]¶
Bases:
object
- 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
- 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.
- 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.
- 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.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:
str
:param uuid: The unique identifier of the client. :type uuid: str :type jid: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.client.ContactStore(uuid)[source]¶
Bases:
object
- 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]
- 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
- 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
- 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
- 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.client.NewClient(name, jid=None, props=None, uuid=None)[source]¶
Bases:
object
- 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.
- 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
- build_document_message(file, caption=None, title=None, filename=None, mimetype=None, quoted=None)[source]¶
- build_image_message(file, caption=None, quoted=None, viewonce=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.
- Returns:
The constructed image message.
- Return type:
Message
- 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.
- build_poll_vote_creation(name, options, selectable_count)[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.
- Returns:
The poll vote creation message.
- Return type:
Message
- 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
- build_reply_message(message, quoted, link_preview=False, reply_privately=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.
mentioned_jid (List[str], optional) – List of JIDs to be mentioned in the message. Defaults to an empty list.
- Returns:
Response of the send operation.
- Return type:
SendResponse
- build_revoke(chat, sender, message_id, with_go=False)[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
- build_sticker_message(file, quoted=None, name='', packname='')[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 “”
- Returns:
The constructed sticker message
- Return type:
Message
- build_video_message(file, caption=None, quoted=None, viewonce=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
- Returns:
A video message with the given parameters.
- Return type:
Message
- 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
- 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.
- 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]
- 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
- 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
- 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.
- generate_message_id()[source]¶
Generates a unique identifier for a message.
- Returns:
A string representing the unique identifier for the message.
- Return type:
str
- 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.
- 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
- 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
- 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.
- 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.
- 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
- 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]
- 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.
- 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]
- 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
- 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]
- 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
- 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.
- 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.
- 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]
- get_privacy_settings()[source]¶
This function retrieves the my privacy settings.
- Returns:
privacy settings
- Return type:
PrivacySettings
- 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
- 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]
- 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]
- 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]
- 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]
- 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
- 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]
- 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.
- 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
- 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
- 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
- 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.
- 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.
- 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.
- 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
- 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.
- reply_message(message, quoted, to=None, link_preview=False, reply_privately=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.
mentioned_jid (List[str], optional) – List of JIDs to be mentioned in the message. Defaults to an empty list.
- Returns:
Response of the send operation.
- Return type:
SendResponse
- 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
- 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
- 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
- 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.
- send_audio(to, file, ptt=False, quoted=None)[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.
- Returns:
A function for handling the result of the audio sending process.
- Return type:
SendResponse
- 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
- 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
- send_document(to, file, caption=None, title=None, filename=None, mimetype=None, quoted=None)[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.
- Returns:
A function for handling the result of the document sending process.
- Return type:
SendResponse
- send_image(to, file, caption=None, quoted=None, viewonce=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.
- Returns:
A function for handling the result of the image sending process.
- Return type:
SendResponse
- send_message(to, message, link_preview=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
- Raises:
SendMessageError – If there was an error sending the message.
- Returns:
The response from the server.
- Return type:
SendResponse
- send_sticker(to, file, quoted=None, name='', packname='')[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 “”.
- Returns:
The response from the send message function.
- Return type:
SendResponse
- send_video(to, file, caption=None, quoted=None, viewonce=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.
- Returns:
A function for handling the result of the video sending process.
- Return type:
SendResponse
- 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.
- 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
- 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.
- 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
- 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.
- 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
- 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
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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]
- 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
- 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.const module¶
neonize.download module¶
neonize.events module¶
- class neonize.events.Event(client)[source]¶
Bases:
object
- property blocking¶
- execute(binary, size, code)[source]¶
Executes a function from the list of functions based on the given code.
- Parameters:
binary (int) – The binary data to be processed by the function.
size (int) – The size of the binary data.
code (int) – The index of the function to be executed from the list of functions.
neonize.exc module¶
neonize.neonize-linux-amd64 module¶
neonize.types module¶
Module contents¶
- class neonize.Event(client)[source]¶
Bases:
object
- property blocking¶
- execute(binary, size, code)[source]¶
Executes a function from the list of functions based on the given code.
- Parameters:
binary (int) – The binary data to be processed by the function.
size (int) – The size of the binary data.
code (int) – The index of the function to be executed from the list of functions.
- class neonize.FFmpeg(data, prefix=None)[source]¶
Bases:
object
- cv_to_webp(animated=True)[source]¶
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.
- Parameters:
animated (bool, optional) – If True, only the first 6 seconds of the file will be converted, defaults to True
- Returns:
The converted file in bytes
- Return type:
bytes
- extract_info()[source]¶
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:
An FFProbeInfo object containing the format and streams of the media file.
- Return type:
- extract_thumbnail(format=ImageFormat.JPG, size=200)[source]¶
Extracts a thumbnail from a video file.
- Parameters:
format (ImageFormat, optional) – The format of the output thumbnail, defaults to ImageFormat.JPG
size (Optional[Tuple[int, int] | int], optional) – 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
- Returns:
The bytes representing the thumbnail image.
- Return type:
bytes
- property filepath¶
- class neonize.NewClient(name, jid=None, props=None, uuid=None)[source]¶
Bases:
object
- 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.
- 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
- build_document_message(file, caption=None, title=None, filename=None, mimetype=None, quoted=None)[source]¶
- build_image_message(file, caption=None, quoted=None, viewonce=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.
- Returns:
The constructed image message.
- Return type:
Message
- 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.
- build_poll_vote_creation(name, options, selectable_count)[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.
- Returns:
The poll vote creation message.
- Return type:
Message
- 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
- build_reply_message(message, quoted, link_preview=False, reply_privately=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.
mentioned_jid (List[str], optional) – List of JIDs to be mentioned in the message. Defaults to an empty list.
- Returns:
Response of the send operation.
- Return type:
SendResponse
- build_revoke(chat, sender, message_id, with_go=False)[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
- build_sticker_message(file, quoted=None, name='', packname='')[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 “”
- Returns:
The constructed sticker message
- Return type:
Message
- build_video_message(file, caption=None, quoted=None, viewonce=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
- Returns:
A video message with the given parameters.
- Return type:
Message
- 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
- 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.
- 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]
- 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
- 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
- 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.
- generate_message_id()[source]¶
Generates a unique identifier for a message.
- Returns:
A string representing the unique identifier for the message.
- Return type:
str
- 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.
- 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
- 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
- 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.
- 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.
- 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
- 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]
- 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.
- 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]
- 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
- 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]
- 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
- 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.
- 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.
- 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]
- get_privacy_settings()[source]¶
This function retrieves the my privacy settings.
- Returns:
privacy settings
- Return type:
PrivacySettings
- 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
- 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]
- 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]
- 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]
- 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]
- 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
- 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]
- 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.
- 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
- 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
- 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
- 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.
- 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.
- 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.
- 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
- 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.
- reply_message(message, quoted, to=None, link_preview=False, reply_privately=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.
mentioned_jid (List[str], optional) – List of JIDs to be mentioned in the message. Defaults to an empty list.
- Returns:
Response of the send operation.
- Return type:
SendResponse
- 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
- 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
- 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
- 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.
- send_audio(to, file, ptt=False, quoted=None)[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.
- Returns:
A function for handling the result of the audio sending process.
- Return type:
SendResponse
- 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
- 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
- send_document(to, file, caption=None, title=None, filename=None, mimetype=None, quoted=None)[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.
- Returns:
A function for handling the result of the document sending process.
- Return type:
SendResponse
- send_image(to, file, caption=None, quoted=None, viewonce=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.
- Returns:
A function for handling the result of the image sending process.
- Return type:
SendResponse
- send_message(to, message, link_preview=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
- Raises:
SendMessageError – If there was an error sending the message.
- Returns:
The response from the server.
- Return type:
SendResponse
- send_sticker(to, file, quoted=None, name='', packname='')[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 “”.
- Returns:
The response from the send message function.
- Return type:
SendResponse
- send_video(to, file, caption=None, quoted=None, viewonce=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.
- Returns:
A function for handling the result of the video sending process.
- Return type:
SendResponse
- 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.
- 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
- 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.
- 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
- 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.
- 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
- 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
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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]
- 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
- 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