SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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 a 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 a 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
 

Último

KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 

Último (20)

KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 

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