PyTox-ng is a set of object-oriented Python bindings for c-toxcore of Tox.chat instant messaging system.
Unlike aitjcize/PyTox (of which this project is a fork), this project is maintained.
Unlike the official Python bindings this project is not auto-generated by Cython and thus has a nicer API.
API reference can be read here.
class ToxOptions():
def __init__(self):
self.ipv6_enabled = True
self.udp_enabled = True
self.proxy_type = 0 # 1=http, 2=socks
self.proxy_host = ''
self.proxy_port = 0
self.start_port = 0
self.end_port = 0
self.tcp_port = 0
self.savedata_type = 0 # 1=toxsave, 2=secretkey
self.savedata_data = b''
self.savedata_length = 0}
class EchoBot(Tox):
def __init__(self, opts):
super(EchoBot, self).__init__(opts)
def loop(self):
while True:
self.iterate()
time.sleep(0.03)
def on_friend_request(self, pk, message):
print 'Friend request from %s: %s' % (pk, message)
self.friend_add_norequest(pk)
print 'Accepted.'
def on_friend_message(self, fid, message):
name = self.self_get_name(fid)
print '%s: %s' % (name, message)
print 'EchoBot: %s' % message
self.friend_send_message(fid, Tox.MESSAGE_TYPE_NORMAL, message)
- echo.py: A better version of the above echo bot that waits for a friend request, accepts it, and then start echoing back anything that you send (including chat messages, files, audio, and video frames).
Run pip install .
.
Or, better, get Nix, git clone
Nixpkgs, add it to NIX_PATH
, and then run
nix-build ./default.nix
.
- Complete the API bindings (use tools/apicomplete.py to check).
- Add unittests for ToxAV.
- Fork it
- Create your own feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request