Python interface to Tox distributed communications
Project description
dendrotox is a Python module designed to enable Python code to interact with the Tox distributed communications network, including for the purposes of scripts communicating with people or other scripts. It uses TokTok Toxcore and ratox for interfacing with the Tox network and megaparsex for parsing.
In particular, dendrotox interacts with the filesystem provided by the FIFO Tox client ratox. dendrotox also provides functionality to send and receive messages, to parse input, to send files, to request confirmations, to provide information such as IP address and weather information, and to run arbitrary commands, including functionality to launch reverse-SSH connections and to restart a script.
setup
sudo apt-get install\
autoconf \
autotools-dev \
automake \
build-essential \
checkinstall \
check \
cmake \
git \
libtool \
libsodium-dev \
yasm
cd ~
mkdir Tox
cd Tox
Install the Sodium crypto library.
git clone https://github.com/jedisct1/libsodium.git
cd libsodium
git checkout tags/1.0.3
./autogen.sh
./configure
make check
sudo checkinstall --install --pkgname libsodium --pkgversion 1.0.0 --nodoc
sudo ldconfig
cd ..
Install the libvpx codec.
git clone https://chromium.googlesource.com/webm/libvpx
cd libvpx
git checkout tags/v1.4.0
./configure --enable-shared --disable-static
make -j$(nproc)
sudo make install
cd ..
Install TokTok ToxCore.
git clone https://github.com/TokTok/c-toxcore.git
cd c-toxcore
autoreconf --install --force
mkdir _build
cd _build
../configure
make -j$(nproc)
sudo make install
sudo ldconfig
cd ../..
Install ratox.
#git clone git://git.2f30.org/ratox.git
git clone https://github.com/kytvi2p/ratox.git
cd ratox
make -j$(nproc)
sudo make install
Install dendrotox.
sudo pip install dentrodox
When ratox is launched for the first time, it creates a file .ratox.tox at the working directory to store Tox profile details. While running, the file id contains the Tox ID.
examples
dendrotox is imported and launched in the following way:
import dendrotox
dendrotox.start_messaging()
print("Tox ID: " + dendrotox.self_ID())
A message can be sent to a contact in the following way, where a contact is specified using a string containing their Tox ID:
dendrotox.send_message(
contact = Tox_ID,
text = "oohai"
)
A message can be sent to multiple contacts in the following way, where contacts are specified as a list of strings containing contacts’ Tox IDs.
dendrotox.send_message(
contacts = [Tox_ID_1, Tox_ID_2],
text = "sup"
)
A list of unseen messages received recently can be accessed in the following ways:
messages = dendrotox.received_messages()
print(messages[0].sender())
message = dendrotox.last_received_message()
print(message.__repr__())
See example bot code for more advanced usage, including message parsing, confirmations and running commands.
dendrotox_alert.py
The script dendrotox_alert.py is a command line script that can be used to send a message to contacts. It attempts to connect with any specified contacts before attempting to send a message to them. If no contacts are specified, it attempts to send a message to all known contacts.
dendrotox_alert.py --text="alert"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.