pytox.Tox Class

PyTox wraps libtoxcore API with the object pytox.Tox, all the tox API methods are in this class.

class pytox.Tox

ToxCore object

add_tcp_relay(address, port, public_key)
bootstrap(address, port, public_key)

Resolves address into an IP address. If successful, sends a ‘get nodes’request to the given node with ip, port.

conference_delete(conference_number)

Delete a conference from the chats array.

conference_get_chatlist()

Return a list of valid conference numbers.

conference_get_chatlist_size()

Return the number of conferences in the current Tox instance.

conference_get_title(conference_number)

Returns the title for a conference.

conference_get_type(conference_number)

Return the type of conference, could be the following value:

type

description

Tox.CONFERENCE_TYPE_TEXT

text chat

Tox.CONFERENCE_TYPE_AV

video chat

conference_invite(friend_number, conference_number)

Invite friend_number to conference_number.

conference_join(friend_number, cookie)

Join a conference (you need to have been invited first.). Returns the conference number of success.

conference_new()

Creates a new conference and puts it in the chats array.

conference_peer_count(conference_number)

Return the number of peers in the conference.

conference_peer_get_name(conference_number, peer_number)

Get the conference peer’s name.

conference_peer_number_is_ours(conference_number, peer_number)

Check if the current peer number corresponds to ours.

conference_send_message(conference_number, type, message)

Send a conference message.

conference_set_title(conference_number, title)

Sets the title for a conference.

file_control(friend_number, file_number, control)

Send a file send request. Returns file number to be sent.

file_get_file_id(friend_number, file_number)

Send a file send request. Returns file id’s hex string

file_seek(friend_number, file_number, position)

Send a file send request. Returns file number to be sent.

file_send(friend_number, kind, file_size, file_id, filename)

Send a file send request. Returns file number to be sent.

file_send_chunk(friend_number, file_number, position, data)

Send a file send request. Returns file number to be sent.

friend_add(address, message)

Add a friend.

friend_add_norequest(address)

Add a friend without sending request.

friend_by_public_key(friend_id)

Return the friend id associated to that client id.

friend_delete(friend_number)

Remove a friend.

friend_exists(friend_number)

Checks if there exists a friend with given friendnumber.

friend_get_connection_status(friend_number)

Return True if friend is connected(Online) else False.

friend_get_last_online(friend_number)

returns datetime.datetime object representing the last time friend_number was seen online, or None if never seen.

friend_get_name(friend_number)

Get nickname of friend_number.

friend_get_name_size(friend_number)

Get nickname length of friend_number.

friend_get_public_key(friend_number)

Return the public key associated to that friend number.

friend_get_status(friend_number)

Get friend status.

See also

set_user_status()

friend_get_status_message(friend_number)

Get status message of a friend.

friend_get_status_message_size(friend_number)

Return the length of friend_number’s status message.

friend_get_typing(friend_number)

Return True is user is typing.

friend_send_message(friend_number, type, message)

Send a text chat message to an online friend.

get_savedata()

Return messenger blob in str.

get_savedata_size()

return size of messenger data (for saving).

iterate()

The main loop that needs to be run at least 20 times per second.

iteration_interval()

returns time (in ms) before the next tox_iterate() needs to be run on success.

kill()

Run this before closing shop.

on_conference_invite(friend_number, type, cookie)

Callback for receiving conference invitations, default implementation does nothing.

on_conference_message(conference_number, peer_number, message)

Callback for receiving conference messages, default implementation does nothing.

on_conference_peer_list_changed(conference_number)

Callback for joins/parts/name changes, default implementation does nothing.

on_conference_peer_name(conference_number, peer_number, peer_name)

Callback for receiving conference peer name changes, default implementation does nothing.

on_file_chunk_request(friend_number, file_number, position, length)

Callback for more file chunk, default implementation does nothing.

on_file_recv(friend_number, file_number, kind, file_size, filename)

Callback for receiving file transfer, default implementation does nothing.

on_file_recv_chunk(friend_number, file_number, position, data)

Callback for receiving file chunk, default implementation does nothing.

on_file_recv_control(friend_number, file_number, control)

Callback for receiving file control, default implementation does nothing.

on_friend_connection_status(friend_number, status)

Callback for receiving read receipt, default implementation does nothing.

status is a boolean value which indicates the status of the friend indicated by friend_number. True means online and False means offline after previously online.

on_friend_message(friend_number, type, message)

Callback for receiving friend messages, default implementation does nothing.

on_friend_name(friend_number, new_name)

Callback for receiving friend name changes, default implementation does nothing.

on_friend_read_receipt(friend_number, receipt)

Callback for receiving read receipt, default implementation does nothing.

on_friend_request(address, message)

Callback for receiving friend requests, default implementation does nothing.

on_friend_status(friend_number, kind)

Callback for receiving friend status changes, default implementation does nothing.

on_friend_status_message(friend_number, new_status)

Callback for receiving friend status message changes, default implementation does nothing.

on_friend_typing(friend_number, is_typing)

Callback for receiving friend status changes, default implementation does nothing.

on_log(level, file, line, func, message)

Callback for internal log messages, default implementation does nothing.

on_self_connection_status(friend_number, status)

Callback for receiving read receipt, default implementation does nothing.

self_get_address()

Return address to give to others.

self_get_connection_status()

Return False if we are not connected to the DHT.

self_get_friend_list()

Get a list of valid friend numbers.

self_get_friend_list_size()

Return the number of friends.

self_get_keys()

Get the public and secret key from the Tox object. Return a tuple (public_key, secret_key)

self_get_name()

Get our self nickname.

self_get_name_size()

Get our self nickname string length

self_get_nospam()

get nospam part from ID

self_get_status()

Get user status of youself.

See also

set_user_status()

self_get_status_message()

Get status message of yourself.

self_get_status_message_size()

Get status message string length of yourself.

self_set_name(name)

Set our self nickname.

self_set_nospam(nospam)

set nospam part of ID. nospam should be of type uint32

self_set_status(status)

Set our user status, status can have following values:

kind

description

Tox.USERSTATUS_NONE

the user is online

Tox.USERSTATUS_AWAY

the user is away

Tox.USERSTATUS_BUSY

the user is busy

Tox.USERSTATUS_INVALID

invalid status

self_set_status_message(message)

Set our self status message.

self_set_typing(friend_number, is_typing)

Set user typing status.