def command(cls, name=None):
        """
        A decorator to convert a function to a command.

        A command's docstring must be a docopt usage string.
        See docopt.org for what it supports.

        Commands receive three arguments:

          * opts: a dictionary output by docopt
          * bot: the Bot instance handling the command (eg for storing state between commands)
          * event: the Slack event that triggered the command (eg for finding the message's sender)

        Additional options may be passed in as keyword arguments:

          * name: the string used to execute the command (no spaces allowed)

        They must return one of three things:

          * a string of response text. It will be sent via the RTM api to the channel where
            the bot received the message. Slack will format it as per https://api.slack.com/docs/message-formatting.
          * None, to send no response.
          * a dictionary of kwargs representing a message to send via https://api.slack.com/methods/chat.postMessage.
            Use this to send more complex messages, such as those with custom link text or DMs.
            For example, to respond with a DM containing custom link text, return
            `{'text': '<http://example.com|my text>', 'channel': event['user'], 'username': bot.name}`.
            Note that this api has higher latency than the RTM api; use it only when necessary.
        """
        # adapted from https://github.com/docopt/docopt/blob/master/examples/interactive_example.py

        def decorator(func):

            @functools.wraps(func)
            def _cmd_wrapper(rest, *args, **kwargs):
                try:
                    usage = _cmd_wrapper.__doc__.partition('\n')[0]
                    opts = docopt(usage, rest)
                except (SystemExit, DocoptExit) as e:
                    # opts did not match
                    return str(e)

                return func(opts, *args, **kwargs)

            cls.commands[name or func.__name__] = _cmd_wrapper

            return _cmd_wrapper
        return decorator
A decorator to convert a function to a command.

        A command's docstring must be a docopt usage string.
        See docopt.org for what it supports.

        Commands receive three arguments:

          * opts: a dictionary output by docopt
          * bot: the Bot instance handling the command (eg for storing state between commands)
          * event: the Slack event that triggered the command (eg for finding the message's sender)

        Additional options may be passed in as keyword arguments:

          * name: the string used to execute the command (no spaces allowed)

        They must return one of three things:

          * a string of response text. It will be sent via the RTM api to the channel where
            the bot received the message. Slack will format it as per https://api.slack.com/docs/message-formatting.
          * None, to send no response.
          * a dictionary of kwargs representing a message to send via https://api.slack.com/methods/chat.postMessage.
            Use this to send more complex messages, such as those with custom link text or DMs.
            For example, to respond with a DM containing custom link text, return
            `{'text': '<http://example.com|my text>', 'channel': event['user'], 'username': bot.name}`.
            Note that this api has higher latency than the RTM api; use it only when necessary.