Skip to main content

IRC bot - full featured, yet extensible and customizable

Project description

pmxbot is an IRC bot written in python. Originally built for internal use, it’s been sanitized and set free upon the world. You can find out more details on the website, http://bitbucket.org/yougov/pmxbot, and especially the wiki https://bitbucket.org/yougov/pmxbot/wiki/Home

Commands

pmxbot listens to commands prefixed by a ‘!’ If it’s a command, it knows it will reply, take an action, etc. It can search the web, store quotes you, track karma, make decisions, and do just about anything else you could want. It stores logs and quotes and karma in either a sqlite or MongoDB database, and there’s a web interface for reviewing the logs and karma.

Contains

pmxbot will respond to things you say if it detects words and phrases it’s been told to recognize. For example, mention sql on rails.

Requirements

pmxbot requires Python 2.6 or 2.7. It also requires a few python packages as defined in setup.py.

If using the MongoDB backend, it requires pymongo (otherwise, sqlite will be used).

Testing

pmxbot includes a test suite that does some functional tests with an included TCL IRC daemon, and some basic unit tests as well. Just run them from the pmxbot root directory using “py.test” (requires pytest) and it should do it all for you.

You’ll need TCL for the functional tests not to be skipped.

Configuration

Configuration is based on very easy YAML files. Check out config.yaml in the source tree for an example.

Usage

Once you’ve setup a config file, you just need to call pmxbot config.yaml and it will join and connect. We recommend running pmxbot under daemontools, upstart, supervisord, or your favorite supervisor to make it automatically restart if it crashes (or terminates due to a planned restart).

Custom Features

Setuptools Entry Points Plugin

pmxbot provides an extension mechanism for adding commands, and uses this mechanism even for its own built-in commands.

To create a setuptools (or distribute or compatible packaging tool) entry point plugin, package your modules using the setuptools tradition and install it alongside pmxbot. Your package should define an entry point in the group pmxbot_handlers by including something similar to the following in the package’s setup.py:

entry_points = {
    'pmxbot_handlers': [
        'plugin name = mylib.mymodule',
    ],
},

During startup (and after loading the traditional script-based plugins), pmxbot will load mylib.mymodule. plugin name can be anything, but should be a name suitable to identify the plugin (and it will be displayed during pmxbot startup).

If your plugin requires any initialization, specify an initialization function (or class method) in the entry point. For example:

'plugin name = mylib.mymodule:initialize_func'

On startup, pmxbot will call initialize_func with no parameters.

Within the script you’ll want to import the decorates you need to use with: from pmxbot.core import command, contains, execdelay, execat. You’ll then decorate each function with the appropriate line so pmxbot registers it.

A command (!g) gets the @command decorator:

@command("tinytear", aliases=('tt', 'tear', 'cry'), doc="I cry a tiny tear for you.")
def tinytear(client, event, channel, nick, rest):
      if rest:
              return "/me sheds a single tear for %s" % rest
      else:
              return "/me sits and cries as a single tear slowly trickles down its cheek"

A response (when someone says something) uses the @contains decorator:

@contains("sqlonrails")
def yay_sor(client, event, channel, nick, rest):
      karmaChange(botbase.logger.db, 'sql on rails', 1)
      return "Only 76,417 lines..."

For an example of how to implement a setuptools-based plugin, see one of the many examples in the pmxbot project itself or one of the popular third-party projects:

- `wolframalpha <http://bitbucket.org/yougov/pmxbot-wolframalpha>`_.
- `jaraco.translate <http://bitbucket.org/jaraco/jaraco.translate>`_.
- `excuses <http://bitbucket.org/yougov/excuses>`_.

Web Interface

pmxbot includes a web server for allowing users to view the logs, read the help, and check karma. You specify the host, port, base path, logo, title, etc with the same YAML config file. Just run like pmxbotweb config.yaml and it will start up. Like pmxbot, use of a supervisor is recommended to restart the process following termination.

Project details


Release history Release notifications

History Node

1122.3

History Node

1122.2

History Node

1122.1

History Node

1122.0

History Node

1121.1

History Node

1121.0

History Node

1120.0

History Node

1119.0.3

History Node

1119.0.2

History Node

1119.0.1

History Node

1119.0

History Node

1118.3.2

History Node

1118.3.1

History Node

1118.3.0

History Node

1118.2.1

History Node

1118.2.0

History Node

1118.1.0

History Node

1118.0.4

History Node

1118.0.3

History Node

1118.0.2

History Node

1118.0.1

History Node

1118.0

History Node

1117.4.3

History Node

1117.4.2

History Node

1117.4.1

History Node

1117.4

History Node

1117.3.9

History Node

1117.3.8

History Node

1117.3.7

History Node

1117.3.6

History Node

1117.3.5

History Node

1117.3.4

History Node

1117.3.2

History Node

1117.3.1

History Node

1117.3

History Node

1117.2.4

History Node

1117.2.3

History Node

1117.2.2

History Node

1117.2.1

History Node

1117.2

History Node

1117.0.2

History Node

1117.0.1

History Node

1117.0

History Node

1116.0

History Node

1115.5

History Node

1115.4.1

History Node

1115.4

History Node

1115.3.2

History Node

1115.3.1

History Node

1115.3

History Node

1115.2.1

History Node

1115.2

History Node

1115.1

History Node

1115.0

History Node

1114.0

History Node

1113.6

History Node

1113.5

History Node

1113.4

History Node

1113.3

History Node

1113.2

History Node

1113.1

History Node

1113.0

History Node

1112.2.2

History Node

1112.2.1

History Node

1112.2

History Node

1112.1

History Node

1112.0

History Node

1111.1

History Node

1111.0.2

History Node

1111.0.1

History Node

1111.0

History Node

1110.7.1

History Node

1110.7

History Node

1110.6

History Node

1110.5

History Node

1110.4.1

History Node

1110.4

History Node

1110.3.1

History Node

1110.3

History Node

1110.2

History Node

1110.1.1

History Node

1110.1

History Node

1110.0

History Node

1109.3

History Node

1109.2

History Node

1109.0

History Node

1108.4.1

History Node

1108.4

History Node

1108.3.1

History Node

1108.3

History Node

1108.2

History Node

1108.1

History Node

1108.0

History Node

1107.4

History Node

1107.2

History Node

1107.1

History Node

1107.0

History Node

1106.4.1

History Node

1106.4

History Node

1106.3

History Node

1106.2

History Node

1106.1.4

History Node

1106.1.3

History Node

1106.1.2

History Node

1106.1.1

History Node

1106.1

History Node

1106.0

History Node

1105.7

History Node

1105.6

History Node

1105.5

History Node

1105.4.2

History Node

1105.4.1

History Node

1105.4

History Node

1105.3.1

History Node

1105.3

History Node

1105.2.2

History Node

1105.2.1

History Node

1105.1.1

History Node

1105.0.1

History Node

1105.0

History Node

1104.4.3

History Node

1104.4.2

History Node

1104.4.1

History Node

1104.4

History Node

1104.3.1

History Node

1104.3

History Node

1104.2

History Node

1104.1

History Node

1104.0

History Node

1103.7.1dev

History Node

1103.7

History Node

1103.6.5

History Node

1103.6.4

History Node

1103.6.3

History Node

1103.6.2

History Node

1103.6.1

History Node

1103.6

History Node

1103.5.1

History Node

1103.4.5

History Node

1103.4.4

History Node

1103.4.3

History Node

1103.4.2

History Node

1103.4.1

History Node

1103.4

History Node

1103.3.2

History Node

1103.3.1

History Node

1103.3

History Node

1103.2

This version
History Node

1103.1.10

History Node

1103.1.9

History Node

1103.1.8

History Node

1103.1.7

History Node

1103.1.6

History Node

1103.1.5

History Node

1103.1.4

History Node

1103.1.3

History Node

1103.1.2

History Node

1103.1.1

History Node

1103.1

History Node

1103.0.4

History Node

1103.0.3

History Node

1103.0.2

History Node

1103.0

History Node

1102.0

History Node

1101.9.2

History Node

1101.9.1

History Node

1101.8.2

History Node

1101.8.1

History Node

1101.8

History Node

1101.7.4

History Node

1101.7.3

History Node

1101.7.1

History Node

1101.7

History Node

1101.6

History Node

1101.6b1

History Node

1101.5

History Node

1101.4

History Node

1101.3

History Node

1101.3b1

History Node

1101.2

History Node

1101.1.4

History Node

1101.1.2

History Node

1101.1.1

History Node

1101.1

History Node

1101.0.1

History Node

1101.0

History Node

1100.8.5

History Node

1100.8.1

History Node

1100.6

History Node

1100.5.8

History Node

1100.5.7

History Node

1100.5.6

History Node

1100.5.5

History Node

1100.5.4

History Node

1100.5.3

History Node

1100.5.2

History Node

1100.5.1

History Node

1100.5

History Node

1100.3

History Node

1100.2

History Node

1100.1.1dev

History Node

1100.1

History Node

1100.0

History Node

1100b7

History Node

1100b4

History Node

1100b3

History Node

1100b2

History Node

1100b1

History Node

1005

History Node

1005b2

History Node

1005b1

History Node

1004.4

History Node

1004.3

History Node

1004.2

History Node

1004

History Node

1004-beta16

History Node

1004-beta15

History Node

1004-beta14

History Node

1004-beta13

History Node

1004-beta12

History Node

1004-beta11

History Node

1004-beta10

History Node

1004-beta8

History Node

1004-beta7

History Node

1004-beta6

History Node

1004-beta5

History Node

1004-beta4

History Node

1004-beta3

History Node

1004-beta2

History Node

1004-beta1

History Node

1003-beta5

History Node

1003-beta4

History Node

1003-beta3

History Node

1003-beta2

History Node

1003-beta1

History Node

1002

History Node

1002-beta3

History Node

1002-beta2

History Node

1002-beta

History Node

1001

History Node

1000

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pmxbot-1103.1.10.zip (225.8 kB) Copy SHA256 hash SHA256 Source None Sep 5, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page