having fun with jabber bots
DESCRIPTION
Victor's presentation about xmpp and Jabber bots at Pycon Ireland 2010 Imagine the possibility of creating a real time channel, capable of notifying and interact, using a simple instant messaging application. Integrating such tool on your application could bring real value to you and customers. The main focus of this presentation is to show an easy way to create and use computer bots through the Python language, suggesting useful applications, and bring together some advanced considerations about security and natural language processing. Learn how to create a bot using jabberBot (5 minute tutorial): basics testing live example How to make it useful? Real time notification system Integration with Yahoo, Exchange APIs System administration Getting serious Alternative libraries Language ProcessingTRANSCRIPT
Having Fun with Jabber Bots
Victor Hugo Germano
Why Jabber Bots?What kinda a crazy am I?
It’s Fun!
http
://w
ww
.flic
kr.c
om/p
hoto
s/sl
eepa
llday
/331
1794
264/
http://www.flickr.com/photos/dancoulter/21042744/
Maybe a glimpse of the future?
Dynamic webIs not enough!
Tired of Ctrl+R and F5
http://www.flickr.com/photos/disaster_area/3454110496/
We want websites like this!
But during the game...
Real time streamming... for sure!
FLASH
Would FLASH be the answer?
No!At least is what most companies are saying
“Big” ProblemHow to create a chat room? Or a chess game?
Latency MattersBecause
Specially when developing and application
client
server
Traditional PollingOften Problematic
?Any other options?
Extensive Messaging and Presence Protocol
Event-Driven
XML oriented
Stanzas
<presence from="[email protected]/home"> <status>at #pyconIreland \o/</status></presence>
Presence
Stanzas
Message<message to="[email protected]/work" from="[email protected]/home" type="chat" > <body>How u doing? ;) </body></message>
Stanzas
IQ (Info Query)<iq type="get" id="an_id" from="[email protected]/casa" to="im.net"> <query xmlns="jabber:iq:roster"/></iq>
client
server
Long Polling
Jabber.org
But XML sucks!xmppPy is your friend!
xmppPyconn = xmpp.Client(‘gmail.com’)
conn.connect([server, port])
conn.auth(user, pwd)
conn.send(Message("[email protected]","hello!"))
conn.disconnect()
First ExampleUsing GTalkBot
http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
mybot.py
http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
from gtalkbot import GTalkBot, botcommand
class MyBot(GTalkBot): def __init__(self): super(MyBot,self).__init__('USER_ID','PWD')
@botcommand def hello(self, mess, args): return “Hello World!”
MyBot().run_client()
$> python mybot.py
How about a real bot?Enough with the hello_world
DemoAdd a contact on your GTalk account
Having fun!Show me the code!
How can you use it?
http://www.flickr.com/photos/flysi/183272970/
Real Time Web?Powered by XMPP
BOSHBidirectional-streams Over Synchronous HTTP
Strophe.jsWhen XMPP hits the web
http://code.stanziq.com/strophe/
Strophe.js// Connecting
var conn = new Strophe.Connection(URL)
conn.connect( jid, password, callback );
// Creating stanzas
var stanza = new Strophe.Builder(
“message”,
{ “to”: “[email protected]”, type:”chat” }
);
Who uses XMPP on the web?
References
http://xmpppy.sourceforge.net/
http://xmpp.org/
http://thpinfo.com/2007/python-jabberbot/
http://xmpppy-guide.berlios.de/
http://code.stanziq.com/strophe/
Real Time Web with XMPP @ InfoQ
Thank you!
twitter.com/victorhggoogle.com/profiles/victorhg
Use it! Share it!Remix it!