Module slack_bolt.listener.listener_start_handler

Classes

class CustomListenerStartHandler (logger: logging.Logger, func: Callable[..., None])
Expand source code
class CustomListenerStartHandler(ListenerStartHandler):
    def __init__(self, logger: Logger, func: Callable[..., None]):
        self.func = func
        self.logger = logger
        self.arg_names = get_arg_names_of_callable(func)

    def handle(
        self,
        request: BoltRequest,
        response: Optional[BoltResponse],
    ):
        kwargs: Dict[str, Any] = build_required_kwargs(
            required_arg_names=self.arg_names,
            logger=self.logger,
            request=request,
            response=response,
            next_keys_required=False,
        )
        self.func(**kwargs)

Ancestors

Inherited members

class DefaultListenerStartHandler (logger: logging.Logger)
Expand source code
class DefaultListenerStartHandler(ListenerStartHandler):
    def __init__(self, logger: Logger):
        self.logger = logger

    def handle(
        self,
        request: BoltRequest,
        response: Optional[BoltResponse],
    ):
        pass

Ancestors

Inherited members

class ListenerStartHandler
Expand source code
class ListenerStartHandler(metaclass=ABCMeta):
    @abstractmethod
    def handle(
        self,
        request: BoltRequest,
        response: Optional[BoltResponse],
    ) -> None:
        """Do something extra before the listener execution.

        This handler is useful if a developer needs to maintain/clean up
        thread-local resources such as Django ORM database connections
        before a listener execution starts.

        Args:
            request: The request.
            response: The response.
        """
        raise NotImplementedError()

Subclasses

Methods

def handle(self, request: BoltRequest, response: Optional[BoltResponse]) ‑> None

Do something extra before the listener execution.

This handler is useful if a developer needs to maintain/clean up thread-local resources such as Django ORM database connections before a listener execution starts.

Args

request
The request.
response
The response.