Home Jabberbot – For creating Jabber/XMPP bots and services in Python

Jabberbot – For creating Jabber/XMPP bots and services in Python

 

jabberbot-screenshot-meego-meegoexperts
Ever thought of being brave and programming your own Jabberbot ? Me neither, but read on and possibly we can all get inspired:

Programming your own Jabber bot can be fun and helpful. This is 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.
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)

Dependencies

Documentation

Debian Package

Thanks to Carl Chenet, python-jabberbot is now available as a Debian package for easy installation on Debian and derived systems:

Download

Development repository (Git)

You can get the latest and greatest code via Git:
git clone git://repo.or.cz/jabberbot.git

Usage

  1. Import the class: from jabberbot import JabberBot, botcmd
  2. Subclass the JabberBot class
  3. 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 None if the command gives no reply)
  4. Create an instance of your bot, supplying username and password
  5. Call the serve_forever() method of your instance
  6. You can call the send() method on your bot to send messages to specific users

Example code

from jabberbot import JabberBot, botcmd
import datetime
class SystemInfoJabberBot(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 '%snn%s' % ( version, loadavg, )
    @botcmd
    def time( self, mess, args):
        """Displays current server time"""
        return str(datetime.datetime.now())
    @botcmd
    def rot13( self, mess, args):
        """Returns passed arguments rot13'ed"""
        return args.encode('rot13')
    @botcmd
    def whoami(self, mess, args):
        """Tells you your username"""
        return mess.getFrom().getStripped()
username = '[email protected]'
password = 'my-password'
bot = SystemInfoJabberBot(username,password)
bot.serve_forever()

For ChangeLog, Further information, Links and Examples please go to the original site here

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Get the biggest tech headlines of the day delivered to your inbox

    By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

    Tech News

    Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

    In-Depth Tech Stories

    Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

    Expert Reviews

    Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.