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, quote you, track karma, make decisions, and do just about anything else you could want. It stores logs and quotes and karma in 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 basic nose 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 with “nosetests” (requires nose) or “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

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:initialize_func',
    ],
},

During startup (and after loading the traditional script-based plugins), pmxbot will load mylib.mymodule and call initialize_func from that module (with no parameters). plugin_name can be anything, but should be a name suitable to identify the plugin. It is not necessary that initialize_func do anything at all, but it must be present, and will be called during startup.

Within the script you’ll want to import the decorates you need to use with: from pmxbot.botbase 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 the wolframalpha plugin.

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 | RSS feed

Download files

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

Source Distribution

pmxbot-1100.8.5.zip (214.0 kB view details)

Uploaded Source

File details

Details for the file pmxbot-1100.8.5.zip.

File metadata

  • Download URL: pmxbot-1100.8.5.zip
  • Upload date:
  • Size: 214.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pmxbot-1100.8.5.zip
Algorithm Hash digest
SHA256 cb0749e5c321e15d2e842f180780b00aebc135e19d9aa674d81ea765e1678a56
MD5 055b3e9a701a88f5c29306b7a9b4c09d
BLAKE2b-256 192a1c3c3dfb9c5f5662fd40ba889535732b4b23a4a5561f68465b91e6c97e5a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page