Skip to main content

slack-machine-plugins

Utility plugins for Slack-Machine, the sexy, simple, yet powerful and extendable Slack bot.

pip install slack-machine-plugins

commander

Commander provides two classes Command and CommandArgument for a declarative way to define chat commands and their arguments for input validation and error feedback for the user. Features include:

  • Type and length validation for chat command arguments.
  • Strict choices.
  • Custom validation and error messages.
  • Usage and error texts for user feedback.

Example Usage

Taken from test case, realistic example.

# command definition
####################
from machine_plugins.commander import Command, CommandArgument

scale_cmd = Command(
    name='scale',
    description='Scale a deployment.',
    arguments=[
        CommandArgument(
            name='namespace',
            target_type=str,
            choices=['default', 'dev'],
            description='Namespace of the deployment.',
        ),
        CommandArgument(
            name='deployment',
            validation=(lambda d: d.startswith('deployment-prefix-'),),
            description='Name of the deployment.',
        ),
        CommandArgument(
            name='replicas',
            target_type=int,
            validation=(lambda r: 2 <= int(r) <= 10, 'You can not scale under 2 or above 10 replicas.'),
        ),
    ],
)

# command usage in slack-machine
################################
from machine.plugins.base import MachineBasePlugin
from machine.plugins.decorators import respond_to


class DeploymentPlugin(MachineBasePlugin):

    @respond_to(regex=r'^scale ?(?P<args>.*)$')
    def scale(self, msg, args):
        errs = scale_cmd.errors(args)
        if errs:
            resp = '\n'.join(errs)
            msg.say(f'```{resp}```')
            return
        # input validation complete, do your thing e.g `scale(*args.split())`

Metadata

Release files for slack-machine-plugins 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slack-machine-plugins 0.1.1
File Size Uploaded Provenance
slack-machine-plugins-0.1.1.tar.gz 6.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for slack-machine-plugins 0.1.1
File Interpreter ABI Platform
slack_machine_plugins-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 14.0 kB

Release files / slack-machine-plugins-0.1.1.tar.gz

Download URL slack-machine-plugins-0.1.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
832dd3a714415fee6de09f82ae174bf10858af7592c336c27ac0946bf8ebdf1d
BLAKE2b-256 checksum
How to use checksums
d88a7f40c09e26d5153dbed06a61ef63c33bcbeace68c5f87256ec6336ee6eea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.6

Release files / slack_machine_plugins-0.1.1-py2.py3-none-any.whl

Download URL slack_machine_plugins-0.1.1-py2.py3-none-any.whl
Size 7.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
923b1d00d983d743d8fccae11522acc422588e23e9cb2ab684420f398aa3deca
BLAKE2b-256 checksum
How to use checksums
369f737042ed5e732498cb574012b2d1be489092ad0cd3e7dcae91cb07ab7d5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.6

Security for slack-machine-plugins 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page