Skip to content


Subversion checkout URL

You can clone with
Download ZIP bot written in Python with a simple plugin API
Branch: master

Merge branch 'zentavr-master', closes #19

latest commit 85f90d2c0e
@1stvamp authored



HippyBot is a chatroom bot written in Python. It is technically just a Jabber/XMPP bot, but it has customised features for connecting to and working on Hipchat.

HippyBot includes a simple plugin API for adding commands.


There a few ways you can install Hippybot:

Download and install with

python install

Install from PyPi:

pip install hippybot
# or using setuptools
easy_install hippybot


There is an example configuration file distributed with HippyBot called hippybot.conf.example, copy this and edit it. You will need to add an account to your Hipchat group for the bot to connect as. While logged in as the account go to the XMPP settings page to get the details you'll need to edit the config file.


Run HippyBot from a terminal like so:

hippybot -c path/to/your/config/file.conf

To run as a background daemon use -d or -daemon:

hippybot -c path/to/your/config/file.conf -d

Optionally you can provide a path to a PID file to use with -p or --pid. Note: at present you will have to provide your own control script, e.g. for use with init.d or upstart.

You should see the bot join any channels listed in the config file. You can then target the bot with commands using the at-sign notation, e.g.:

@botname rot13 hello world

If you have the rot13 example plugin set to load (via the plugins section of the config file) then the bot will reply to you using at-sign notation with a ROT13'd (each character offset by 13) version of the text "hello world".

The bot has 2 inbuilt commands:

  • load_plugins: this will reload any updated plugins (note it will also reset the internal state of any loaded plugins, e.g. the counter in the mexican wave plugin). Note it does not reload the bot's configuration file and so will not load new plugins.
  • reload: this will reload the bot itself, reloading the configuration file, reconnecting to HipChat and reloading any plugins, in the process. Note: it does not end the main process, you would have to do that yourself from the terminal (for example if HippyBot were updated).


There are 3 plugins currently distributed with HippyBot:

  • rot13: this is mostly included as an example, it ROT13s, any text spoken directly to the bot, back at the speaker.

  • mexican_wave: this is a fun plugin that completes a mexican wave if 2 people in a row say \o/ in a channel, e.g.:

    John Smith: \o/
    Joe Bloggs: \o/
    Hippy Bot:  \o/
  • udefine: look up a term on Urban Dictionary, the first 3 definitions will be posted back to the channel. Warning: many terms are NSFW.

To instruct the bot to load a plugin include the plugin's module path in the load field of the plugins section of the config file, e.g. to load the mexican_wave plugin which is located in the file in hippybot/plugins/, you would write it as:

load = hippybot.plugins.mexican_wave

To load a plugin named my_custom_plugin that you have installed into your python path under myhippybotplugins in a filename (or module) named you would append (on a new line, notice the indentation):

load = hippybot.plugins.mexican_wave

To search for plugins in paths outside of hippybot, you can use the load_path option:


load_path = /absolute/path/plugins

Plugin API

HippyBot includes a very simple plugin API. To add commands to HippyBot you just need an importable Python package (e.g. a directory in the PYTHON_PATH that includes a file named, and place your plugin in it's own Python file (the ROT13 plugin lives in

You then can include a function that matches the same name as the file and is the same command you want to register, and use either the botcmd or directcmd decorators:

from hippybot.decorators import directcmd

def hello_world(bot, mess, args):
    return u'Hello world!'

This registers the command hello world as a direct command, that means the text "Hello world!" will be directly spoken back to the user using at-sign notation. The botcmd decorator on the other hand will respond in the channel without targetting the original speaker. By default these function based plugins only support direct commands (spoken to the bot using at-sign notation), however you can create more complex plugins with greater control using class based plugins.

To create class based plugins create the Python module as normal, with any descriptive name you want, and include a class named Plugin in the module, for example the hello world plugin can be written like:

from hippybot.decorators import botcmd, directcmd

class Plugin(object):
    global_commands = ['hello_world']
    command_aliases = {'hi!': 'hello'}

    def hello_world(self, mess, args):
        return u'Hello world!'

    def hello(self, mess, args):
        return u'Well hello there..'

This uses 2 special properties:

  • global_commands: a list of command method names that can be triggered without targetting the bot using at-sign notation (just say the command in the channel without mentioning the bot).
  • command_aliases: dict of command aliases and the methods they map to, this is a way of triggering a command from a string that can't be used as a Python method name (e.g. using special symbols such as the "o/" trigger used in the mexican wave plugin).
  • all_msg_handlers: a list of handler method names that will be passed all incoming XMPP message objects regardless of type as. This can be used for low-level hanbdling of Jabber messages without using the higher level message handling of jabberbot or hippybot.

HipChat API

HippyBot includes a very simple object orientated wrapper for the HipChat API. To make use of the API you need to create an API key and enter that into the config file under the section hipchat, as an option called api_auth_token, e.g.:

api_auth_token = xxxxxxxxxxxxxxxxxxxxxxxx

If you are using self-hosted Hipchat service, set up something like this:

api_server =
api_auth_token = xxxxxxxxxxxxxxxxxxxxxxxx

Then you can access the wrapper via the api attribute on the bot instance, e.g. from within a command method on a plugin class:

from hippybot.decorators import botcmd

class Plugin(object):
    global_commands = ['hello']

    def hello(self, mess, args):
        channel = unicode(mess.getFrom()).split('/')[0]
        # Say hello world as a room notification
        # Params to the API wrapper are sent as dicts{
            'room_id': channel,
            'message': 'Hello world!'
Something went wrong with that request. Please try again.