Having fun with jabber bots
-
Upload
victor-hugo-germano -
Category
Technology
-
view
8.272 -
download
5
description
Transcript of Having fun with jabber bots
![Page 1: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/1.jpg)
Having Fun with Jabber Bots
Victor Hugo Germano
![Page 2: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/2.jpg)
Why Jabber Bots?What kinda a crazy am I?
![Page 3: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/3.jpg)
It’s Fun!
http
://w
ww
.flic
kr.c
om/p
hoto
s/sl
eepa
llday
/331
1794
264/
![Page 4: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/4.jpg)
http://www.flickr.com/photos/dancoulter/21042744/
Maybe a glimpse of the future?
![Page 5: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/5.jpg)
Dynamic webIs not enough!
![Page 6: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/6.jpg)
Tired of Ctrl+R and F5
http://www.flickr.com/photos/disaster_area/3454110496/
![Page 7: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/7.jpg)
We want websites like this!
![Page 8: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/8.jpg)
But during the game...
Real time streamming... for sure!
![Page 9: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/9.jpg)
FLASH
![Page 10: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/10.jpg)
Would FLASH be the answer?
![Page 11: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/11.jpg)
No!At least is what most companies are saying
![Page 12: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/12.jpg)
“Big” ProblemHow to create a chat room? Or a chess game?
![Page 13: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/13.jpg)
Latency MattersBecause
Specially when developing and application
![Page 14: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/14.jpg)
client
server
Traditional PollingOften Problematic
![Page 15: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/15.jpg)
?Any other options?
![Page 16: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/16.jpg)
![Page 17: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/17.jpg)
Extensive Messaging and Presence Protocol
Event-Driven
XML oriented
![Page 18: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/18.jpg)
Stanzas
<presence from="[email protected]/home"> <status>at #pyconIreland \o/</status></presence>
Presence
![Page 19: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/19.jpg)
Stanzas
Message<message to="[email protected]/work" from="[email protected]/home" type="chat" > <body>How u doing? ;) </body></message>
![Page 20: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/20.jpg)
Stanzas
IQ (Info Query)<iq type="get" id="an_id" from="[email protected]/casa" to="im.net"> <query xmlns="jabber:iq:roster"/></iq>
![Page 21: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/21.jpg)
client
server
Long Polling
![Page 22: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/22.jpg)
Jabber.org
![Page 23: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/23.jpg)
But XML sucks!xmppPy is your friend!
![Page 24: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/24.jpg)
xmppPyconn = xmpp.Client(‘gmail.com’)
conn.connect([server, port])
conn.auth(user, pwd)
conn.send(Message("[email protected]","hello!"))
conn.disconnect()
![Page 25: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/25.jpg)
First ExampleUsing GTalkBot
http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
![Page 26: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/26.jpg)
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()
![Page 27: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/27.jpg)
$> python mybot.py
![Page 28: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/28.jpg)
How about a real bot?Enough with the hello_world
![Page 29: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/29.jpg)
DemoAdd a contact on your GTalk account
![Page 30: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/30.jpg)
Having fun!Show me the code!
![Page 31: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/31.jpg)
How can you use it?
http://www.flickr.com/photos/flysi/183272970/
![Page 32: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/32.jpg)
Real Time Web?Powered by XMPP
![Page 33: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/33.jpg)
BOSHBidirectional-streams Over Synchronous HTTP
![Page 34: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/34.jpg)
Strophe.jsWhen XMPP hits the web
http://code.stanziq.com/strophe/
![Page 35: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/35.jpg)
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” }
);
![Page 36: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/36.jpg)
Who uses XMPP on the web?
![Page 37: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/37.jpg)
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
![Page 38: Having fun with jabber bots](https://reader034.fdocuments.net/reader034/viewer/2022042714/54b48ade4a7959bb688b4633/html5/thumbnails/38.jpg)
Thank you!
twitter.com/victorhggoogle.com/profiles/victorhg
Use it! Share it!Remix it!