SlideShare a Scribd company logo
1 of 18
a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot +  Echo  &  HTTP-like JSON API  Bots +  djabotd  – Django daemon command
track l r .com Marek Kuziel < [email_address] > #my #experience #in #hashtags #... #opensource #php #python #java #javascript  #html  #xhtml #docbook #xslt #css #linux #nginx #postgresql #mysql #memcache  #apache  #subversion #mercurial #phing #pear #deployment #scaling #automation  #tomcat  #javaws  #arduino #8051 #Z80 #assembly #GWT #drupal #django #wsgi  #jabber  #xmpp  #thegimp #openid #oauth #ecommerce #zencart #titanium #mobile #tracklr #tracklr2mindmap #djauthy #djabot Djabot – Python Jabber Bot
Jabber/XMPP track l r .com Djabot – Python Jabber Bot Good security – TLS support Decentralized – You can run your own Jabber/XMPP server Open – Standards, community, code
What Is a Jabber Bot? track l r .com Djabot – Python Jabber Bot An unmanned Jabber/XMPP client Runs as a program on a computer (ie. as a Linux daemon) Processes incoming messages from other clients
Introducing Djabot track l r .com Djabot – Python Jabber Bot Python Jabber client – TLS support, extensible (bots, auth) Example bots:  echo ,  HTTP-like JSON API djabotd  – Django command that implements Djabot and  allows you to run bots for your Django based app  as a daemon
Djabot – More Information track l r .com Djabot – Python Jabber Bot Requires: PyXMPP, M2Crypto, libxml2-python, dnspython Allows you to provide your own auth callback function to  protect your bots Allows you to write as many bots as you like and  configure your instance to use them
Djabot – Example Code track l r .com Djabot – Python Jabber Bot #/usr/bin/env python from pyxmpp.all import JID from djabot.djabot import Client if __name__ == '__main__: def auth_check(requestSenderJID): return True  # reply to any sender / do not check sender's JID at all BOTS = ['djabot.bots.echo'] c=Client(JID('USERNAME'), 'PASSWORD', 'tls_noverify', BOTS, auth_check) c.connect() c.loop(1)
Djabot – Example Echo Bot Code track l r .com Djabot – Python Jabber Bot from djabot.bots.base import Djabot as Base class Djabot(Base): NAME = 'djabot-echo-bot' def command_echo(self, inputs): return inputs['body'] def status(self, inputs): return 'echoed back: echo %s' % inputs['body']
Djabot commands –  inputs track l r .com Djabot – Python Jabber Bot djabot processes received Jabber msg & passes the following dictionary as  inputs  parameter to any  command that you define: inputs = { 'subject': subject,  # subject of received msg 'body': body,  # body of received msg  'body_json': None, #  JSON object ( if possible to load body as JSON) 'jid': sender,  # JID of sender }
Jabber/XMPP HTTP-like JSON API track l r .com Djabot – Python Jabber Bot What? request/response JSON API over Jabber/XMPP that mimics HTTP (status code; PUT|POST|GET|DELETE verbs) Why? I prefer “chatting” with my app instead of RESTful  HTTP based approach Seriously. Why? Faster & easier implementation of APIs
Core properties of the API protocol track l r .com Djabot – Python Jabber Bot HTTP  status   code  and  message  property in response  transaction  property to uniquely identify sent/received messages api  property for version namespace of given  action property in request
“ GTalk – djabot” example chat about  GET track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;GET&quot;, &quot;api&quot;: &quot;1.0&quot;,  &quot;data&quot;: {&quot;id&quot;: &quot;123&quot;}, &quot;object&quot;: &quot;OBJECT&quot;,  &quot;transaction&quot;: &quot;1234567890&quot;} djabot:   {'message': u'GET OBJECT ID 123 OK', 'code': '200', 'data': '{&quot;id&quot;: &quot;123&quot;, &quot;example_data&quot;: &quot;EXAMPLE&quot;}',  'transaction': u'1234567890'}
“ GTalk – djabot” example chat about  PUT track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;PUT&quot;, &quot;api&quot;: &quot;1.0&quot;,  &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot:   {'message': u'PUT OBJECT ID 123 OK', 'code': '200', 'transaction':  u'1234567890'}
“ GTalk – djabot” example chat about  POST track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;POST&quot;, &quot;api&quot;: &quot;1.0&quot;,  &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot:   {'message': u'POST OBJECT ID 123 OK', 'code': '200', 'transaction':  u'1234567890'}
“ GTalk – djabot” example chat about  DELETE track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;DELETE&quot;, &quot;api&quot;: &quot;1.0&quot;,  &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot:   {'message': u'DELETE OBJECT ID 123 OK', 'code': '200', 'transaction':  u'1234567890'}
Demo HTTP-like JSON API Bot track l r .com Djabot – Python Jabber Bot [email_address] Try it :-)
Djabot – Source Code track l r .com Djabot – Python Jabber Bot Released 2010/07/17 under BSD License http://bitbucket.org/vshivak/djabot/ Feedback or contributions: Marek Kuziel < [email_address] >
Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at  http://tracklr.com/tm/presentations/tracklr-djabot.pdf

More Related Content

What's hot

Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Steven Francia
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...Guillaume Laforge
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Steven Francia
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost MaintainabilityMosky Liu
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page CreationWildan Maulana
 
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)James Titcumb
 
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)James Titcumb
 
Elegant concurrency
Elegant concurrencyElegant concurrency
Elegant concurrencyMosky Liu
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachablePamela Fox
 
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019Viktor Todorov
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Servicesmattjive
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for DummiesElizabeth Smith
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
JavaScript, Beyond the Curly Braces
JavaScript, Beyond the Curly BracesJavaScript, Beyond the Curly Braces
JavaScript, Beyond the Curly BracesChicago ALT.NET
 

What's hot (20)

Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
 
Boost Maintainability
Boost MaintainabilityBoost Maintainability
Boost Maintainability
 
Learn php with PSK
Learn php with PSKLearn php with PSK
Learn php with PSK
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
 
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
 
Elegant concurrency
Elegant concurrencyElegant concurrency
Elegant concurrency
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php performance
Php performancePhp performance
Php performance
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More Approachable
 
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 
Php Extensions for Dummies
Php Extensions for DummiesPhp Extensions for Dummies
Php Extensions for Dummies
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
Php string function
Php string function Php string function
Php string function
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
JavaScript, Beyond the Curly Braces
JavaScript, Beyond the Curly BracesJavaScript, Beyond the Curly Braces
JavaScript, Beyond the Curly Braces
 

Similar to Djabot – Python Jabber Bot

Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebIlya Grigorik
 
Ruby as a glue language
Ruby as a glue languageRuby as a glue language
Ruby as a glue languagequakewang
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
 
Enterprise AIR Development for JavaScript Developers
Enterprise AIR Development for JavaScript DevelopersEnterprise AIR Development for JavaScript Developers
Enterprise AIR Development for JavaScript DevelopersAndreCharland
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceSaumil Shah
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009marpierc
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedPyCon Italia
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbitedskam
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 
Atlrug intermodal - sep 2011
Atlrug   intermodal - sep 2011Atlrug   intermodal - sep 2011
Atlrug intermodal - sep 2011hosheng
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIsPamela Fox
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsMarian Marinov
 

Similar to Djabot – Python Jabber Bot (20)

Real-time Ruby for the Real-time Web
Real-time Ruby for the Real-time WebReal-time Ruby for the Real-time Web
Real-time Ruby for the Real-time Web
 
Ruby as a glue language
Ruby as a glue languageRuby as a glue language
Ruby as a glue language
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Enterprise AIR Development for JavaScript Developers
Enterprise AIR Development for JavaScript DevelopersEnterprise AIR Development for JavaScript Developers
Enterprise AIR Development for JavaScript Developers
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surface
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
 
PSGI/Plack OSDC.TW
PSGI/Plack OSDC.TWPSGI/Plack OSDC.TW
PSGI/Plack OSDC.TW
 
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
Fantom and Tales
Fantom and TalesFantom and Tales
Fantom and Tales
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Atlrug intermodal - sep 2011
Atlrug   intermodal - sep 2011Atlrug   intermodal - sep 2011
Atlrug intermodal - sep 2011
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIs
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your plugins
 

Recently uploaded

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

Djabot – Python Jabber Bot

  • 1. a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot + Echo & HTTP-like JSON API Bots + djabotd – Django daemon command
  • 2. track l r .com Marek Kuziel < [email_address] > #my #experience #in #hashtags #... #opensource #php #python #java #javascript #html #xhtml #docbook #xslt #css #linux #nginx #postgresql #mysql #memcache #apache #subversion #mercurial #phing #pear #deployment #scaling #automation #tomcat #javaws #arduino #8051 #Z80 #assembly #GWT #drupal #django #wsgi #jabber #xmpp #thegimp #openid #oauth #ecommerce #zencart #titanium #mobile #tracklr #tracklr2mindmap #djauthy #djabot Djabot – Python Jabber Bot
  • 3. Jabber/XMPP track l r .com Djabot – Python Jabber Bot Good security – TLS support Decentralized – You can run your own Jabber/XMPP server Open – Standards, community, code
  • 4. What Is a Jabber Bot? track l r .com Djabot – Python Jabber Bot An unmanned Jabber/XMPP client Runs as a program on a computer (ie. as a Linux daemon) Processes incoming messages from other clients
  • 5. Introducing Djabot track l r .com Djabot – Python Jabber Bot Python Jabber client – TLS support, extensible (bots, auth) Example bots: echo , HTTP-like JSON API djabotd – Django command that implements Djabot and allows you to run bots for your Django based app as a daemon
  • 6. Djabot – More Information track l r .com Djabot – Python Jabber Bot Requires: PyXMPP, M2Crypto, libxml2-python, dnspython Allows you to provide your own auth callback function to protect your bots Allows you to write as many bots as you like and configure your instance to use them
  • 7. Djabot – Example Code track l r .com Djabot – Python Jabber Bot #/usr/bin/env python from pyxmpp.all import JID from djabot.djabot import Client if __name__ == '__main__: def auth_check(requestSenderJID): return True # reply to any sender / do not check sender's JID at all BOTS = ['djabot.bots.echo'] c=Client(JID('USERNAME'), 'PASSWORD', 'tls_noverify', BOTS, auth_check) c.connect() c.loop(1)
  • 8. Djabot – Example Echo Bot Code track l r .com Djabot – Python Jabber Bot from djabot.bots.base import Djabot as Base class Djabot(Base): NAME = 'djabot-echo-bot' def command_echo(self, inputs): return inputs['body'] def status(self, inputs): return 'echoed back: echo %s' % inputs['body']
  • 9. Djabot commands – inputs track l r .com Djabot – Python Jabber Bot djabot processes received Jabber msg & passes the following dictionary as inputs parameter to any command that you define: inputs = { 'subject': subject, # subject of received msg 'body': body, # body of received msg 'body_json': None, # JSON object ( if possible to load body as JSON) 'jid': sender, # JID of sender }
  • 10. Jabber/XMPP HTTP-like JSON API track l r .com Djabot – Python Jabber Bot What? request/response JSON API over Jabber/XMPP that mimics HTTP (status code; PUT|POST|GET|DELETE verbs) Why? I prefer “chatting” with my app instead of RESTful HTTP based approach Seriously. Why? Faster & easier implementation of APIs
  • 11. Core properties of the API protocol track l r .com Djabot – Python Jabber Bot HTTP status code and message property in response transaction property to uniquely identify sent/received messages api property for version namespace of given action property in request
  • 12. “ GTalk – djabot” example chat about GET track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;GET&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: &quot;123&quot;}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'GET OBJECT ID 123 OK', 'code': '200', 'data': '{&quot;id&quot;: &quot;123&quot;, &quot;example_data&quot;: &quot;EXAMPLE&quot;}', 'transaction': u'1234567890'}
  • 13. “ GTalk – djabot” example chat about PUT track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;PUT&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'PUT OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  • 14. “ GTalk – djabot” example chat about POST track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;POST&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'POST OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  • 15. “ GTalk – djabot” example chat about DELETE track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;DELETE&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'DELETE OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  • 16. Demo HTTP-like JSON API Bot track l r .com Djabot – Python Jabber Bot [email_address] Try it :-)
  • 17. Djabot – Source Code track l r .com Djabot – Python Jabber Bot Released 2010/07/17 under BSD License http://bitbucket.org/vshivak/djabot/ Feedback or contributions: Marek Kuziel < [email_address] >
  • 18. Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at http://tracklr.com/tm/presentations/tracklr-djabot.pdf