def handle(self, type: str, *, kwargs: dict = None) -> Callable:
        """
        Register an event handler with the :obj:`Layabout` instance.

        Args:
            type: The name of a Slack RTM API event to be handled. As a
                special case, although it is not a proper RTM event, ``*`` may
                be provided to handle all events. For more information about
                available events see the
                `Slack RTM API <https://api.slack.com/rtm>`_.
            kwargs: Optional arbitrary keyword arguments passed to the event
                handler when the event is triggered.

        Returns:
            A decorator that validates and registers a Layabout event handler.

        Raises:
            TypeError: If the decorated :obj:`Callable`'s signature does not
                accept at least 2 parameters.
        """
        def decorator(fn: Callable) -> Callable:
            # Validate that the wrapped callable is a suitable event handler.
            sig = signature(fn)
            num_params = len(sig.parameters)
            if num_params < 2:
                raise TypeError(_format_parameter_error_message(
                    fn.__name__, sig, num_params))

            # Register a tuple of the callable and its kwargs, if any.
            self._handlers[type].append((fn, kwargs or {}))
            return fn

        return decorator
def handle ( self , type : str , * , kwargs : dict = None ) -> Callable : def decorator ( fn : Callable ) -> Callable : sig = signature ( fn ) num_params = len ( sig . parameters ) if num_params < 2 : raise TypeError ( _format_parameter_error_message ( fn . __name__ , sig , num_params ) ) self . _handlers [ type ] . append ( ( fn , kwargs or { } ) ) return fn return decorator
Register an event handler with the :obj:`Layabout` instance.

        Args:
            type: The name of a Slack RTM API event to be handled. As a
                special case, although it is not a proper RTM event, ``*`` may
                be provided to handle all events. For more information about
                available events see the
                `Slack RTM API <https://api.slack.com/rtm>`_.
            kwargs: Optional arbitrary keyword arguments passed to the event
                handler when the event is triggered.

        Returns:
            A decorator that validates and registers a Layabout event handler.

        Raises:
            TypeError: If the decorated :obj:`Callable`'s signature does not
                accept at least 2 parameters.