Python binding for Project Tox.
PyTox provides a Pythonic binding, i.e Object-oriented instead of C style, raise exception instead of returning error code. A simple example is as follows:
class EchoBot(Tox):
def loop(self):
while True:
self.do()
time.sleep(0.03)
def on_friend_request(self, pk, message):
print 'Friend request from %s: %s' % (pk, message)
self.add_friend_norequest(pk)
print 'Accepted.'
def on_friend_message(self, friendId, message):
name = self.getname(friendId)
print '%s: %s' % (name, message)
print 'EchoBot: %s' % message
self.send_message(friendId, message)
As you can see callbacks are mapped into class method instead of using it the the c ways. For more details please refer to examples/echo.py.
- echo.py: A working echo bot that wait for friend requests, and than start echoing anything that friend send.
Full API documentation can be read here.
- Fork it
- Create your 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 new Pull Request