jabberbot: A simple framework for creating Jabber/XMPP bots and services in Python
Programming your own Jabber bot can be fun and helpful. This
python-jabberbot, a Jabber bot framework for Python
that enables you to easily write simple Jabber bots. You can use your
Jabber bots to provide information about your running systems, to make
your website interact with your visitors or notify you about updates or
changes you monitor with your Python scripts.
[...] now I have the
'bot bug' and I want to write bots for all kinds of things, since it's
so easy to do. Thanks again!
This Jabber bot is partly inspired by the xmpppy example
bot.py, but designed to be re-usable and to make it easy to write
small Jabber bots that do one thing and do it well.
License: GNU General Public License, Version 3 or later (GPLv3)
We now have a mailing list for discussing the development of the JabberBot module:
Thanks to Carl Chenet, python-jabberbot is now available as a Debian package for easy installation on Debian and derived systems:
- python-jabberbot in Debian
- Current version: jabberbot-0.16.tar.gz (Released: 2015-06-12)
Development repository (Git)
You can get the latest and greatest code via Git:
git clone git://git.code.sf.net/p/pythonjabberbot/code
- 2007-07-28: Initial release
- 2007-09-17: Merged patch from John Martinez
- 2007-10-19: Merged patch from Dan Sanders
- 2008-07-12: Add setup.py, prepare for CheeseShop, tarball
- 2008-11-26: Add TwitterBot example
- 2009-01-25: Fix dependency checking
- 2009-11-01: JabberBot 0.7 released with patches from Pat Notz
- 2009-11-06: JabberBot 0.8 released (fixed code examples on website +
examples/in the source)
- 2009-12-23: JabberBot 0.9 released (better help display; adding missing COPYING file)
- 2010-07-30: JabberBot 0.10 released (XMMP TUNE support, XHTML support, command name overriding, suppressed default response and custom MUC usernames)
- 2011-01-22: JabberBot 0.11 released (various bugfixes, XMPP MUC base class and examples)
- 2011-02-10: JabberBot 0.12 released (support for private subscription domains; contributed by David O'Rourke)
- 2011-04-04: JabberBot 0.13 released (support "own" messages; contributed by Rene Mayrhofer)
- 2011-07-31: JabberBot 0.14 released (various bugfixes and minor feature enhancements)
- 2012-03-08: JabberBot 0.15 released (command prefixes, custom handlers, pep8, experimental threading support)
- 2015-06-12: JabberBot 0.16 released (XEP-0045 support, support for servers without SRV record, sendInitPresence fixes)
- Import the class:
from jabberbot import JabberBot, botcmd
- Subclass the
- Add methods and decorate them with "@botcmd". The signature
of the methods should look like this:
def somecommand(self, mess, args)- the methods should return the message sent back to the user as string (or
Noneif the command gives no reply)
- Create an instance of your bot, supplying username and password
- Call the
serve_forever()method of your instance
- You can call the
send()method on your bot to send messages to specific users
from jabberbot import JabberBot, botcmd
def serverinfo( self, mess, args):
"""Displays information about the server"""
version = open('/proc/version').read().strip()
loadavg = open('/proc/loadavg').read().strip()
return '%s\n\n%s' % ( version, loadavg, )
def time( self, mess, args):
"""Displays current server time"""
def rot13( self, mess, args):
"""Returns passed arguments rot13'ed"""
def whoami(self, mess, args):
"""Tells you your username"""
username = 'email@example.com'
password = 'my-password'
bot = SystemInfoJabberBot(username,password)
Starting with version 0.7, more examples can be found in the
examples/ subdirectory of the source distribution.
Projects using python-jabberbot
- Hubert Chathi's System status bot
- John Sullivan's SnakeBot
- Jay Parlar's Prowl (iPhone) Jabberbots
- Vicent Tamarit's TVBot (using natural language processing)
- Gareth Rushgrove's LastBot (Personal LastFM search bot)
- René Mayrhofer's dvcs-autosync (an open source replacement for Dropbox)
- Guillaume Binet's err (A plugin-based XMPP chatbot designed to be easily deployable, extensible and maintainable)