TOXYGEN
 All Classes Functions
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
toxygen.tox.Tox Class Reference

Public Member Functions

def __init__
 
def __del__
 
def get_savedata_size
 
def get_savedata
 
def bootstrap
 
def add_tcp_relay
 
def self_get_connection_status
 
def callback_self_connection_status
 
def iteration_interval
 
def iterate
 
def self_get_address
 
def self_set_nospam
 
def self_get_nospam
 
def self_get_public_key
 
def self_get_secret_key
 
def self_set_name
 
def self_get_name_size
 
def self_get_name
 
def self_set_status_message
 
def self_get_status_message_size
 
def self_get_status_message
 
def self_set_status
 
def self_get_status
 
def friend_add
 
def friend_add_norequest
 
def friend_delete
 
def friend_by_public_key
 
def friend_exists
 
def self_get_friend_list_size
 
def self_get_friend_list
 
def friend_get_public_key
 
def friend_get_last_online
 
def friend_get_name_size
 
def friend_get_name
 
def callback_friend_name
 
def friend_get_status_message_size
 
def friend_get_status_message
 
def callback_friend_status_message
 
def friend_get_status
 
def callback_friend_status
 
def friend_get_connection_status
 
def callback_friend_connection_status
 
def friend_get_typing
 
def callback_friend_typing
 
def self_set_typing
 
def friend_send_message
 
def callback_friend_read_receipt
 
def callback_friend_request
 
def callback_friend_message
 
def file_control
 
def callback_file_recv_control
 
def file_seek
 
def file_get_file_id
 
def file_send
 
def file_send_chunk
 
def callback_file_chunk_request
 
def callback_file_recv
 
def callback_file_recv_chunk
 
def friend_send_lossy_packet
 
def friend_send_lossless_packet
 
def callback_friend_lossy_packet
 
def callback_friend_lossless_packet
 
def self_get_dht_id
 
def self_get_udp_port
 
def self_get_tcp_port
 

Static Public Member Functions

def options_default
 
def options_new
 
def options_free
 
def hash
 

Public Attributes

 self_connection_status_cb
 
 friend_name_cb
 
 friend_status_message_cb
 
 friend_status_cb
 
 friend_connection_status_cb
 
 friend_request_cb
 
 friend_read_receipt_cb
 
 friend_typing_cb
 
 friend_message_cb
 
 file_recv_control_cb
 
 file_chunk_request_cb
 
 file_recv_cb
 
 file_recv_chunk_cb
 
 friend_lossy_packet_cb
 
 friend_lossless_packet_cb
 
 AV
 

Static Public Attributes

tuple libtoxcore = LibToxCore()
 

Constructor & Destructor Documentation

def toxygen.tox.Tox.__init__ (   self,
  tox_options = None,
  tox_pointer = None 
)
Creates and initialises a new Tox instance with the options passed.

This function will bring the instance into a valid state. Running the event loop with a new instance will
operate correctly.

:param tox_options: An options object. If this parameter is None, the default options are used.
:param tox_pointer: Tox instance pointer. If this parameter is not None, tox_options will be ignored.

Member Function Documentation

def toxygen.tox.Tox.add_tcp_relay (   self,
  address,
  port,
  public_key 
)
Adds additional host:port pair as TCP relay.

This function can be used to initiate TCP connections to different ports on the same bootstrap node, or to add
 TCP relays without using them as bootstrap nodes.

:param address: The hostname or IP address (IPv4 or IPv6) of the TCP relay.
:param port: The port on the host on which the TCP relay is listening.
:param public_key: The long term public key of the TCP relay (TOX_PUBLIC_KEY_SIZE bytes).
:return: True on success.
def toxygen.tox.Tox.bootstrap (   self,
  address,
  port,
  public_key 
)
Sends a "get nodes" request to the given bootstrap node with IP, port, and public key to setup connections.

This function will attempt to connect to the node using UDP. You must use this function even if
Tox_Options.udp_enabled was set to false.

:param address: The hostname or IP address (IPv4 or IPv6) of the node.
:param port: The port on the host on which the bootstrap Tox instance is listening.
:param public_key: The long term public key of the bootstrap node (TOX_PUBLIC_KEY_SIZE bytes).
:return: True on success.
def toxygen.tox.Tox.callback_file_chunk_request (   self,
  callback,
  user_data 
)
Set the callback for the `file_chunk_request` event. Pass None to unset.

This event is triggered when Core is ready to send more file data.

:param callback: Python function.
If the length parameter is 0, the file transfer is finished, and the client's resources associated with the file
number should be released. After a call with zero length, the file number can be reused for future file
transfers.

If the requested position is not equal to the client's idea of the current file or stream position, it will need
to seek. In case of read-once streams, the client should keep the last read chunk so that a seek back can be
supported. A seek-back only ever needs to read from the last requested chunk. This happens when a chunk was
requested, but the send failed. A seek-back request can occur an arbitrary number of times for any given chunk.

In response to receiving this callback, the client should call the function `tox_file_send_chunk` with the
requested chunk. If the number of bytes sent through that function is zero, the file transfer is assumed
complete. A client must send the full length of data requested with this callback.

Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the receiving friend for this file.
The file transfer identifier (c_uint32) returned by tox_file_send.
The file or stream position (c_uint64) from which to continue reading.
The number of bytes (c_size_t) requested for the current chunk.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_file_recv (   self,
  callback,
  user_data 
)
Set the callback for the `file_recv` event. Pass None to unset.

This event is triggered when a file transfer request is received.

:param callback: Python function.
The client should acquire resources to be associated with the file transfer. Incoming file transfers start in
the PAUSED state. After this callback returns, a transfer can be rejected by sending a TOX_FILE_CONTROL_CANCEL
control command before any other control commands. It can be accepted by sending TOX_FILE_CONTROL_RESUME.

Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who is sending the file transfer request.
The friend-specific file number (c_uint32) the data received is associated with.
The meaning of the file (c_uint32) to be sent.
Size in bytes (c_uint64) of the file the client wants to send, UINT64_MAX if unknown or streaming.
Name of the file (c_char_p). Does not need to be the actual name. This name will be sent along with the file
send request.
Size in bytes (c_size_t) of the filename.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_file_recv_chunk (   self,
  callback,
  user_data 
)
Set the callback for the `file_recv_chunk` event. Pass NULL to unset.

This event is first triggered when a file transfer request is received, and subsequently when a chunk of file
data for an accepted request was received.

:param callback: Python function.
When length is 0, the transfer is finished and the client should release the resources it acquired for the
transfer. After a call with length = 0, the file number can be reused for new file transfers.

If position is equal to file_size (received in the file_receive callback) when the transfer finishes, the file
was received completely. Otherwise, if file_size was UINT64_MAX, streaming ended successfully when length is 0.

Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who is sending the file.
The friend-specific file number (c_uint32) the data received is associated with.
The file position (c_uint64) of the first byte in data.
A byte array (c_char_p) containing the received chunk.
The length (c_size_t) of the received chunk.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_file_recv_control (   self,
  callback,
  user_data 
)
Set the callback for the `file_recv_control` event. Pass NULL to unset.

This event is triggered when a file control command is received from a friend.

:param callback: Python function.
When receiving TOX_FILE_CONTROL_CANCEL, the client should release the resources associated with the file number
and consider the transfer failed.

Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who is sending the file.
The friend-specific file number (c_uint32) the data received is associated with.
The file control (TOX_FILE_CONTROL) command received.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_connection_status (   self,
  callback,
  user_data 
)
Set the callback for the `friend_connection_status` event. Pass NULL to unset.

This event is triggered when a friend goes offline after having been online, or when a friend goes online.

This callback is not called when adding friends. It is assumed that when adding friends, their connection status
is initially offline.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend whose connection status changed,
The result of calling tox_friend_get_connection_status (TOX_CONNECTION) on the passed friend_number,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_lossless_packet (   self,
  callback,
  user_data 
)
Set the callback for the `friend_lossless_packet` event. Pass NULL to unset.

:param callback: Python function.
Should take pointer (c_void_p) to Tox object,
friend_number (c_uint32) - The friend number of the friend who sent a lossless packet,
A byte array (c_uint8 array) containing the received packet data,
length (c_size_t) - The length of the packet data byte array,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_lossy_packet (   self,
  callback,
  user_data 
)
Set the callback for the `friend_lossy_packet` event. Pass NULL to unset.

:param callback: Python function.
Should take pointer (c_void_p) to Tox object,
friend_number (c_uint32) - The friend number of the friend who sent a lossy packet,
A byte array (c_uint8 array) containing the received packet data,
length (c_size_t) - The length of the packet data byte array,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_message (   self,
  callback,
  user_data 
)
Set the callback for the `friend_message` event. Pass None to unset.

This event is triggered when a message from a friend is received.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who sent the message,
Message type (TOX_MESSAGE_TYPE),
The message data (c_char_p) they sent,
The size (c_size_t) of the message byte array.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_name (   self,
  callback,
  user_data 
)
Set the callback for the `friend_name` event. Pass None to unset.

This event is triggered when a friend changes their name.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend whose name changed,
A byte array (c_char_p) containing the same data as tox_friend_get_name would write to its `name` parameter,
A value (c_size_t) equal to the return value of tox_friend_get_name_size,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_read_receipt (   self,
  callback,
  user_data 
)
Set the callback for the `friend_read_receipt` event. Pass None to unset.

This event is triggered when the friend receives the message sent with tox_friend_send_message with the
corresponding message ID.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who received the message,
The message ID (c_uint32) as returned from tox_friend_send_message corresponding to the message sent,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_request (   self,
  callback,
  user_data 
)
Set the callback for the `friend_request` event. Pass None to unset.

This event is triggered when a friend request is received.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The Public Key (c_uint8 array) of the user who sent the friend request,
The message (c_char_p) they sent along with the request,
The size (c_size_t) of the message byte array,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_status (   self,
  callback,
  user_data 
)
Set the callback for the `friend_status` event. Pass None to unset.

This event is triggered when a friend changes their user status.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend whose user status changed,
The new user status (TOX_USER_STATUS),
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_status_message (   self,
  callback,
  user_data 
)
Set the callback for the `friend_status_message` event. Pass NULL to unset.

This event is triggered when a friend changes their status message.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend whose status message changed,
A byte array (c_char_p) containing the same data as tox_friend_get_status_message would write to its
`status_message` parameter,
A value (c_size_t) equal to the return value of tox_friend_get_status_message_size,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_friend_typing (   self,
  callback,
  user_data 
)
Set the callback for the `friend_typing` event. Pass NULL to unset.

This event is triggered when a friend starts or stops typing.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
The friend number (c_uint32) of the friend who started or stopped typing,
The result of calling tox_friend_get_typing (c_bool) on the passed friend_number,
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.callback_self_connection_status (   self,
  callback,
  user_data 
)
Set the callback for the `self_connection_status` event. Pass None to unset.

This event is triggered whenever there is a change in the DHT connection state. When disconnected, a client may
choose to call tox_bootstrap again, to reconnect to the DHT. Note that this state may frequently change for
short amounts of time. Clients should therefore not immediately bootstrap on receiving a disconnect.

:param callback: Python function. Should take pointer (c_void_p) to Tox object,
TOX_CONNECTION (c_int),
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.tox.Tox.file_control (   self,
  friend_number,
  file_number,
  control 
)
Sends a file control command to a friend for a given file transfer.

:param friend_number: The friend number of the friend the file is being transferred to or received from.
:param file_number: The friend-specific identifier for the file transfer.
:param control: The control (TOX_FILE_CONTROL) command to send.
:return: True on success.
def toxygen.tox.Tox.file_get_file_id (   self,
  friend_number,
  file_number,
  file_id = None 
)
Copy the file id associated to the file transfer to a byte array.

:param friend_number: The friend number of the friend the file is being transferred to or received from.
:param file_number: The friend-specific identifier for the file transfer.
:param file_id: A pointer (c_char_p) to memory region of at least TOX_FILE_ID_LENGTH bytes. If this parameter is
None, this function has no effect.
:return: file id.
def toxygen.tox.Tox.file_seek (   self,
  friend_number,
  file_number,
  position 
)
Sends a file seek control command to a friend for a given file transfer.

This function can only be called to resume a file transfer right before TOX_FILE_CONTROL_RESUME is sent.

:param friend_number: The friend number of the friend the file is being received from.
:param file_number: The friend-specific identifier for the file transfer.
:param position: The position that the file should be seeked to.
:return: True on success.
def toxygen.tox.Tox.file_send (   self,
  friend_number,
  kind,
  file_size,
  file_id,
  filename 
)
Send a file transmission request.

Maximum filename length is TOX_MAX_FILENAME_LENGTH bytes. The filename should generally just be a file name, not
a path with directory names.

If a non-UINT64_MAX file size is provided, it can be used by both sides to determine the sending progress. File
size can be set to UINT64_MAX for streaming data of unknown size.

File transmission occurs in chunks, which are requested through the `file_chunk_request` event.

When a friend goes offline, all file transfers associated with the friend are purged from core.

If the file contents change during a transfer, the behaviour is unspecified in general. What will actually
happen depends on the mode in which the file was modified and how the client determines the file size.

- If the file size was increased
    - and sending mode was streaming (file_size = UINT64_MAX), the behaviour will be as expected.
    - and sending mode was file (file_size != UINT64_MAX), the file_chunk_request callback will receive length =
    0 when Core thinks the file transfer has finished. If the client remembers the file size as it was when
    sending the request, it will terminate the transfer normally. If the client re-reads the size, it will think
    the friend cancelled the transfer.
- If the file size was decreased
    - and sending mode was streaming, the behaviour is as expected.
    - and sending mode was file, the callback will return 0 at the new (earlier) end-of-file, signalling to the
    friend that the transfer was cancelled.
- If the file contents were modified
    - at a position before the current read, the two files (local and remote) will differ after the transfer
    terminates.
    - at a position after the current read, the file transfer will succeed as expected.
    - In either case, both sides will regard the transfer as complete and successful.

:param friend_number: The friend number of the friend the file send request should be sent to.
:param kind: The meaning of the file to be sent.
:param file_size: Size in bytes of the file the client wants to send, UINT64_MAX if unknown or streaming.
:param file_id: A file identifier of length TOX_FILE_ID_LENGTH that can be used to uniquely identify file
transfers across core restarts. If NULL, a random one will be generated by core. It can then be obtained by
using tox_file_get_file_id().
:param filename: Name of the file. Does not need to be the actual name. This name will be sent along with the
file send request.
:return: A file number used as an identifier in subsequent callbacks. This number is per friend. File numbers
are reused after a transfer terminates. On failure, this function returns UINT32_MAX. Any pattern in file
numbers should not be relied on.
def toxygen.tox.Tox.file_send_chunk (   self,
  friend_number,
  file_number,
  position,
  data 
)
Send a chunk of file data to a friend.

This function is called in response to the `file_chunk_request` callback. The length parameter should be equal
to the one received though the callback. If it is zero, the transfer is assumed complete. For files with known
size, Core will know that the transfer is complete after the last byte has been received, so it is not necessary
(though not harmful) to send a zero-length chunk to terminate. For streams, core will know that the transfer is
finished if a chunk with length less than the length requested in the callback is sent.

:param friend_number: The friend number of the receiving friend for this file.
:param file_number: The file transfer identifier returned by tox_file_send.
:param position: The file or stream position from which to continue reading.
:param data: Chunk of file data
:return: true on success.
def toxygen.tox.Tox.friend_add (   self,
  address,
  message 
)
Add a friend to the friend list and send a friend request.

A friend request message must be at least 1 byte long and at most TOX_MAX_FRIEND_REQUEST_LENGTH.

Friend numbers are unique identifiers used in all functions that operate on friends. Once added, a friend number
is stable for the lifetime of the Tox object. After saving the state and reloading it, the friend numbers may
not be the same as before. Deleting a friend creates a gap in the friend number set, which is filled by the next
adding of a friend. Any pattern in friend numbers should not be relied on.

If more than INT32_MAX friends are added, this function causes undefined behaviour.

:param address: The address of the friend (returned by tox_self_get_address of the friend you wish to add) it
must be TOX_ADDRESS_SIZE bytes.
:param message: The message that will be sent along with the friend request.
:return: the friend number on success, UINT32_MAX on failure.
def toxygen.tox.Tox.friend_add_norequest (   self,
  public_key 
)
Add a friend without sending a friend request.

This function is used to add a friend in response to a friend request. If the client receives a friend request,
it can be reasonably sure that the other client added this client as a friend, eliminating the need for a friend
request.

This function is also useful in a situation where both instances are controlled by the same entity, so that this
entity can perform the mutual friend adding. In this case, there is no need for a friend request, either.

:param public_key: A byte array of length TOX_PUBLIC_KEY_SIZE containing the Public Key (not the Address) of the
friend to add.
:return: the friend number on success, UINT32_MAX on failure.
def toxygen.tox.Tox.friend_by_public_key (   self,
  public_key 
)
Return the friend number associated with that Public Key.

:param public_key: A byte array containing the Public Key.
:return: friend number
def toxygen.tox.Tox.friend_delete (   self,
  friend_number 
)
Remove a friend from the friend list.

This does not notify the friend of their deletion. After calling this function, this client will appear offline
to the friend and no communication can occur between the two.

:param friend_number: Friend number for the friend to be deleted.
:return: True on success.
def toxygen.tox.Tox.friend_exists (   self,
  friend_number 
)
Checks if a friend with the given friend number exists and returns true if it does.
def toxygen.tox.Tox.friend_get_connection_status (   self,
  friend_number 
)
Check whether a friend is currently connected to this client.

The result of this function is equal to the last value received by the `friend_connection_status` callback.

:param friend_number: The friend number for which to query the connection status.
:return: the friend's connection status (TOX_CONNECTION) as it was received through the
`friend_connection_status` event.
def toxygen.tox.Tox.friend_get_last_online (   self,
  friend_number 
)
Return a unix-time timestamp of the last time the friend associated with a given friend number was seen online.
This function will return UINT64_MAX on error.

:param friend_number: The friend number you want to query.
:return: unix-time timestamp
def toxygen.tox.Tox.friend_get_name (   self,
  friend_number,
  name = None 
)
Write the name of the friend designated by the given friend number to a byte array.

Call tox_friend_get_name_size to determine the allocation size for the `name` parameter.

The data written to `name` is equal to the data received by the last `friend_name` callback.

:param friend_number: number of friend
:param name: pointer (c_char_p) to a valid memory region large enough to store the friend's name.
:return: name of the friend
def toxygen.tox.Tox.friend_get_name_size (   self,
  friend_number 
)
Return the length of the friend's name. If the friend number is invalid, the return value is unspecified.

The return value is equal to the `length` argument received by the last `friend_name` callback.
def toxygen.tox.Tox.friend_get_public_key (   self,
  friend_number,
  public_key = None 
)
Copies the Public Key associated with a given friend number to a byte array.

:param friend_number: The friend number you want the Public Key of.
:param public_key: pointer (c_char_p) to a memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If this
parameter is None, this function allocates memory for Tox Public Key.
:return: Tox Public Key
def toxygen.tox.Tox.friend_get_status (   self,
  friend_number 
)
Return the friend's user status (away/busy/...). If the friend number is invalid, the return value is
unspecified.

The status returned is equal to the last status received through the `friend_status` callback.

:return: TOX_USER_STATUS
def toxygen.tox.Tox.friend_get_status_message (   self,
  friend_number,
  status_message = None 
)
Write the status message of the friend designated by the given friend number to a byte array.

Call tox_friend_get_status_message_size to determine the allocation size for the `status_name` parameter.

The data written to `status_message` is equal to the data received by the last `friend_status_message` callback.

:param friend_number:
:param status_message: pointer (c_char_p) to a valid memory region large enough to store the friend's status
message.
:return: status message of the friend
def toxygen.tox.Tox.friend_get_status_message_size (   self,
  friend_number 
)
Return the length of the friend's status message. If the friend number is invalid, the return value is SIZE_MAX.

:return: length of the friend's status message
def toxygen.tox.Tox.friend_get_typing (   self,
  friend_number 
)
Check whether a friend is currently typing a message.

:param friend_number: The friend number for which to query the typing status.
:return: true if the friend is typing.
def toxygen.tox.Tox.friend_send_lossless_packet (   self,
  friend_number,
  data 
)
Send a custom lossless packet to a friend.
The first byte of data must be in the range 160-191. Maximum length of a
custom packet is TOX_MAX_CUSTOM_PACKET_SIZE.

Lossless packet behaviour is comparable to TCP (reliability, arrive in order)
but with packets instead of a stream.

:param friend_number: The friend number of the friend this lossless packet
:param data: python string containing the packet data
:return: True on success.
def toxygen.tox.Tox.friend_send_lossy_packet (   self,
  friend_number,
  data 
)
Send a custom lossy packet to a friend.
The first byte of data must be in the range 200-254. Maximum length of a
custom packet is TOX_MAX_CUSTOM_PACKET_SIZE.

Lossy packets behave like UDP packets, meaning they might never reach the
other side or might arrive more than once (if someone is messing with the
connection) or might arrive in the wrong order.

Unless latency is an issue, it is recommended that you use lossless custom packets instead.

:param friend_number: The friend number of the friend this lossy packet
:param data: python string containing the packet data
:return: True on success.
def toxygen.tox.Tox.friend_send_message (   self,
  friend_number,
  message_type,
  message 
)
Send a text chat message to an online friend.

This function creates a chat message packet and pushes it into the send queue.

The message length may not exceed TOX_MAX_MESSAGE_LENGTH. Larger messages must be split by the client and sent
as separate messages. Other clients can then reassemble the fragments. Messages may not be empty.

The return value of this function is the message ID. If a read receipt is received, the triggered
`friend_read_receipt` event will be passed this message ID.

Message IDs are unique per friend. The first message ID is 0. Message IDs are incremented by 1 each time a
message is sent. If UINT32_MAX messages were sent, the next message ID is 0.

:param friend_number: The friend number of the friend to send the message to.
:param message_type: Message type (TOX_MESSAGE_TYPE).
:param message: A non-None message text.
:return: message ID
def toxygen.tox.Tox.get_savedata (   self,
  savedata = None 
)
Store all information associated with the tox instance to a byte array.

:param savedata: pointer (c_char_p) to a memory region large enough to store the tox instance data.
Call tox_get_savedata_size to find the number of bytes required. If this parameter is None, this function
allocates memory for the tox instance data.
:return: pointer (c_char_p) to a memory region with the tox instance data
def toxygen.tox.Tox.get_savedata_size (   self)
Calculates the number of bytes required to store the tox instance with tox_get_savedata.
This function cannot fail. The result is always greater than 0.

:return: number of bytes
def toxygen.tox.Tox.hash (   data,
  hash = None 
)
static
Generates a cryptographic hash of the given data.

This function may be used by clients for any purpose, but is provided primarily for validating cached avatars.
This use is highly recommended to avoid unnecessary avatar updates.

If hash is NULL or data is NULL while length is not 0 the function returns false, otherwise it returns true.

This function is a wrapper to internal message-digest functions.

:param hash: A valid memory location the hash data. It must be at least TOX_HASH_LENGTH bytes in size.
:param data: Data to be hashed or NULL.
:return: true if hash was not NULL.
def toxygen.tox.Tox.iterate (   self)
The main loop that needs to be run in intervals of tox_iteration_interval() milliseconds.
def toxygen.tox.Tox.iteration_interval (   self)
Return the time in milliseconds before tox_iterate() should be called again for optimal performance.
:return: time in milliseconds
def toxygen.tox.Tox.options_default (   tox_options)
static
Initialises a Tox_Options object with the default options.

The result of this function is independent of the original options. All values will be overwritten, no values
will be read (so it is permissible to pass an uninitialised object).

If options is NULL, this function has no effect.

:param tox_options: A pointer to options object to be filled with default options.
def toxygen.tox.Tox.options_free (   tox_options)
static
Releases all resources associated with an options objects.

Passing a pointer that was not returned by tox_options_new results in undefined behaviour.

:param tox_options: A pointer to new ToxOptions object
def toxygen.tox.Tox.options_new ( )
static
Allocates a new Tox_Options object and initialises it with the default options. This function can be used to
preserve long term ABI compatibility by giving the responsibility of allocation and deallocation to the Tox
library.

Objects returned from this function must be freed using the tox_options_free function.

:return: A pointer to new ToxOptions object with default options or raise MemoryError.
def toxygen.tox.Tox.self_get_address (   self,
  address = None 
)
Writes the Tox friend address of the client to a byte array. The address is not in human-readable format. If a
client wants to display the address, formatting is required.

:param address: pointer (c_char_p) to a memory region of at least TOX_ADDRESS_SIZE bytes. If this parameter is
None, this function allocates memory for address.
:return: Tox friend address
def toxygen.tox.Tox.self_get_connection_status (   self)
Return whether we are connected to the DHT. The return value is equal to the last value received through the
`self_connection_status` callback.

:return: TOX_CONNECTION
def toxygen.tox.Tox.self_get_dht_id (   self,
  dht_id = None 
)
Writes the temporary DHT public key of this instance to a byte array.

This can be used in combination with an externally accessible IP address and the bound port (from
tox_self_get_udp_port) to run a temporary bootstrap node.

Be aware that every time a new instance is created, the DHT public key changes, meaning this cannot be used to
run a permanent bootstrap node.

:param dht_id: pointer (c_char_p) to a memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If this parameter is
None, this function allocates memory for dht_id.
:return: dht_id
def toxygen.tox.Tox.self_get_friend_list (   self,
  friend_list = None 
)
Copy a list of valid friend numbers into an array.

Call tox_self_get_friend_list_size to determine the number of elements to allocate.

:param friend_list: pointer (c_char_p) to a memory region with enough space to hold the friend list. If this
parameter is None, this function allocates memory for the friend list.
:return: friend list
def toxygen.tox.Tox.self_get_friend_list_size (   self)
Return the number of friends on the friend list.

This function can be used to determine how much memory to allocate for tox_self_get_friend_list.

:return: number of friends
def toxygen.tox.Tox.self_get_name (   self,
  name = None 
)
Write the nickname set by tox_self_set_name to a byte array.

If no nickname was set before calling this function, the name is empty, and this function has no effect.

Call tox_self_get_name_size to find out how much memory to allocate for the result.

:param name: pointer (c_char_p) to a memory region location large enough to hold the nickname. If this parameter
is NULL, the function allocates memory for the nickname.
:return: nickname
def toxygen.tox.Tox.self_get_name_size (   self)
Return the length of the current nickname as passed to tox_self_set_name.

If no nickname was set before calling this function, the name is empty, and this function returns 0.

:return: length of the current nickname
def toxygen.tox.Tox.self_get_nospam (   self)
Get the 4-byte nospam part of the address.

:return: nospam part of the address
def toxygen.tox.Tox.self_get_public_key (   self,
  public_key = None 
)
Copy the Tox Public Key (long term) from the Tox object.

:param public_key: A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If this parameter is NULL, this
function allocates memory for Tox Public Key.
:return: Tox Public Key
def toxygen.tox.Tox.self_get_secret_key (   self,
  secret_key = None 
)
Copy the Tox Secret Key from the Tox object.

:param secret_key: pointer (c_char_p) to a memory region of at least TOX_SECRET_KEY_SIZE bytes. If this
parameter is NULL, this function allocates memory for Tox Secret Key.
:return: Tox Secret Key
def toxygen.tox.Tox.self_get_status (   self)
Returns the client's user status.

:return: client's user status
def toxygen.tox.Tox.self_get_status_message (   self,
  status_message = None 
)
Write the status message set by tox_self_set_status_message to a byte array.

If no status message was set before calling this function, the status is empty, and this function has no effect.

Call tox_self_get_status_message_size to find out how much memory to allocate for the result.

:param status_message: pointer (c_char_p) to a valid memory location large enough to hold the status message.
If this parameter is None, the function allocates memory for the status message.
:return: status message
def toxygen.tox.Tox.self_get_status_message_size (   self)
Return the length of the current status message as passed to tox_self_set_status_message.

If no status message was set before calling this function, the status is empty, and this function returns 0.

:return: length of the current status message
def toxygen.tox.Tox.self_get_tcp_port (   self)
Return the TCP port this Tox instance is bound to. This is only relevant if the instance is acting as a TCP
relay.
def toxygen.tox.Tox.self_get_udp_port (   self)
Return the UDP port this Tox instance is bound to.
def toxygen.tox.Tox.self_set_name (   self,
  name 
)
Set the nickname for the Tox client.

Nickname length cannot exceed TOX_MAX_NAME_LENGTH. If length is 0, the name parameter is ignored
(it can be None), and the nickname is set back to empty.
:param name: New nickname.
:return: True on success.
def toxygen.tox.Tox.self_set_nospam (   self,
  nospam 
)
Set the 4-byte nospam part of the address.

:param nospam: Any 32 bit unsigned integer.
def toxygen.tox.Tox.self_set_status (   self,
  status 
)
Set the client's user status.

:param status: One of the user statuses listed in the enumeration TOX_USER_STATUS.
def toxygen.tox.Tox.self_set_status_message (   self,
  status_message 
)
Set the client's status message.

Status message length cannot exceed TOX_MAX_STATUS_MESSAGE_LENGTH. If length is 0, the status parameter is
ignored, and the user status is set back to empty.

:param status_message: new status message
:return: True on success.
def toxygen.tox.Tox.self_set_typing (   self,
  friend_number,
  typing 
)
Set the client's typing status for a friend.

The client is responsible for turning it on or off.

:param friend_number: The friend to which the client is typing a message.
:param typing: The typing status. True means the client is typing.
:return: True on success.

The documentation for this class was generated from the following file: