## Installation
### Using pip
pip install ttapi
### Via source
Obtain the source by downloading from the web or cloning with git. In the
directory containing setup.py run:
python setup.py install
## Examples
### Chat bot
This bot respond to anybody who write "/hello" on the chat.
```py
from ttapi import Bot
bot = Bot(AUTH, USERID, ROOMID)
def speak(data):
name = data['name']
text = data['text']
if text == '/hello':
bot.speak('Hey! How are you %s ?' % name)
bot.on('speak', speak)
bot.start()
```
### Simple
```py
from ttapi import Bot
bot = Bot(AUTH, USERID, ROOMID)
# Define callbacks
def roomChanged(data): print 'The bot has changed room.', data
def speak(data): print 'Someone has spoken.', data
def updateVotes(data): print 'Someone has voted.', data
def registered(data): print 'Someone registered.', data
# Bind listeners
bot.on('roomChanged', roomChanged)
bot.on('speak', speak )
bot.on('update_votes', updateVotes)
bot.on('registered', registered )
# Start the bot
bot.start()
```
### Using pip
pip install ttapi
### Via source
Obtain the source by downloading from the web or cloning with git. In the
directory containing setup.py run:
python setup.py install
## Examples
### Chat bot
This bot respond to anybody who write "/hello" on the chat.
```py
from ttapi import Bot
bot = Bot(AUTH, USERID, ROOMID)
def speak(data):
name = data['name']
text = data['text']
if text == '/hello':
bot.speak('Hey! How are you %s ?' % name)
bot.on('speak', speak)
bot.start()
```
### Simple
```py
from ttapi import Bot
bot = Bot(AUTH, USERID, ROOMID)
# Define callbacks
def roomChanged(data): print 'The bot has changed room.', data
def speak(data): print 'Someone has spoken.', data
def updateVotes(data): print 'Someone has voted.', data
def registered(data): print 'Someone registered.', data
# Bind listeners
bot.on('roomChanged', roomChanged)
bot.on('speak', speak )
bot.on('update_votes', updateVotes)
bot.on('registered', registered )
# Start the bot
bot.start()
```
Release files for ttapi 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ttapi-1.1.0.tar.gz | 7.4 kB | Details |
Release files / ttapi-1.1.0.tar.gz
| Download URL | ttapi-1.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
518b9825bfe6c3f19593a89ae6d48bc09846e392cd6f771cf565ade077f6af35
|
|
BLAKE2b-256 checksum How to use checksums |
794a4c40cfeb8349a0c933b1b7ef1e260e5bfaca226092947f7c989e31177d5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |