Skip to main content

A Python Slack Bot with hot patch!

Project description

# slactorbot

A slack bot that uses lightweights actors and dynamic module imports for plugins

Start the bot. Add, remove or edit plugins and magic happens.

# Why?

All of the Python slack bots I tried were annoying.

  • Every plugin got sent every message and then filtered by regex. I just wanted slack commands to run the correct plugin.

  • Working on plugins locally and then constantly restarting the bot to test them became tedious

  • The basic list of commands shown by help shouldn’t require manually updating any files

  • Exceptions in plugins would crash everything. Why not let it live and crash the plugin.

# Usage

Copy the config.yaml.example to config.yaml and update the settings. Do a pip install -r requirements.txt.

Then ./run_bot.py

The bot responds to:

bot_name plugin name commands

For instance if I have my bot_name configured as dlbot and I’ve got a plugin called example.py I’d type:

dlbot example text

Into the slack channel configured in the config. This would run whatever logic is in the example.py plugin within the elif for the command text.

# Plugins

Create or modify any file with a .py extension in the slactorbot/plugins directory. slactorbot will reload them without needing to restart.

The plugins are little actors that get dynamically imported. They each need a class called Main and a receiveMessage function.

They receive a message which is a list of words typed after the bot_name and the plugin name in the slack room.

If in doubt have a look at the example.py plugin.

# Todo

  • More slack options

  • Handle restarting crashes in actors

  • Make it a pip package

  • Needs tests

Project details


Download files

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

Source Distribution

slactorbot-0.0.1.tar.gz (4.9 kB view hashes)

Uploaded Source

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