Skip to content

oxij/PyTox-ng

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTox-ng

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.

Documentation

API reference can be read here.

Examples


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).

Getting started

Run pip install ..

Or, better, get Nix, git clone Nixpkgs, add it to NIX_PATH, and then run nix-build ./default.nix.

TODO

  • Complete the API bindings (use tools/apicomplete.py to check).
  • Add unittests for ToxAV.

Contributing

  1. Fork it
  2. Create your own feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Packages

No packages published

Languages

  • C 76.7%
  • Python 22.4%
  • Nix 0.9%