+ All Categories
Transcript
Page 1: Having fun with jabber bots

Having Fun with Jabber Bots

Victor Hugo Germano

Page 2: Having fun with jabber bots

Why Jabber Bots?What kinda a crazy am I?

Page 3: Having fun with jabber bots

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

http://www.flickr.com/photos/dancoulter/21042744/

Maybe a glimpse of the future?

Page 5: Having fun with jabber bots

Dynamic webIs not enough!

Page 6: Having fun with jabber bots

Tired of Ctrl+R and F5

http://www.flickr.com/photos/disaster_area/3454110496/

Page 7: Having fun with jabber bots

We want websites like this!

Page 8: Having fun with jabber bots

But during the game...

Real time streamming... for sure!

Page 9: Having fun with jabber bots

FLASH

Page 10: Having fun with jabber bots

Would FLASH be the answer?

Page 11: Having fun with jabber bots

No!At least is what most companies are saying

Page 12: Having fun with jabber bots

“Big” ProblemHow to create a chat room? Or a chess game?

Page 13: Having fun with jabber bots

Latency MattersBecause

Specially when developing and application

Page 14: Having fun with jabber bots

client

server

Traditional PollingOften Problematic

Page 15: Having fun with jabber bots

?Any other options?

Page 16: Having fun with jabber bots
Page 17: Having fun with jabber bots

Extensive Messaging and Presence Protocol

Event-Driven

XML oriented

Page 18: Having fun with jabber bots

Stanzas

<presence from="[email protected]/home">  <status>at #pyconIreland \o/</status></presence>

Presence

Page 19: Having fun with jabber bots

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

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

client

server

Long Polling

Page 22: Having fun with jabber bots

Jabber.org

Page 23: Having fun with jabber bots

But XML sucks!xmppPy is your friend!

Page 24: Having fun with jabber bots

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

First ExampleUsing GTalkBot

http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py

Page 26: Having fun with jabber bots

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

$> python mybot.py

Page 28: Having fun with jabber bots

How about a real bot?Enough with the hello_world

Page 29: Having fun with jabber bots

DemoAdd a contact on your GTalk account

[email protected]

Page 30: Having fun with jabber bots

Having fun!Show me the code!

Page 31: Having fun with jabber bots

How can you use it?

http://www.flickr.com/photos/flysi/183272970/

Page 32: Having fun with jabber bots

Real Time Web?Powered by XMPP

Page 33: Having fun with jabber bots

BOSHBidirectional-streams Over Synchronous HTTP

Page 34: Having fun with jabber bots

Strophe.jsWhen XMPP hits the web

http://code.stanziq.com/strophe/

Page 35: Having fun with jabber bots

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

Who uses XMPP on the web?

Page 37: Having fun with jabber bots

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

Thank you!

twitter.com/victorhggoogle.com/profiles/victorhg

Use it! Share it!Remix it!


Top Related