示例#1
0
 def __init__(self, app: App):  # type: ignore
     self.app = app
     self.logger = get_bolt_app_logger(app.name, SlackRequestHandler)
     self.app.listener_runner.lazy_listener_runner = LambdaLazyListenerRunner(
         self.logger)
     if self.app.oauth_flow is not None:
         self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = "?"
    def __init__(self, *, app_name: str, func: Callable[..., Awaitable[Any]]):
        self.app_name = app_name
        if inspect.iscoroutinefunction(func):
            self.func = func
        else:
            raise ValueError("Async middleware function must be an async function")

        self.arg_names = inspect.getfullargspec(func).args
        self.logger = get_bolt_app_logger(self.app_name, self.func)
示例#3
0
    def __init__(self, app: App, chalice: Chalice):  # type: ignore
        self.app = app
        self.chalice = chalice
        self.logger = get_bolt_app_logger(app.name, ChaliceSlackRequestHandler)

        lambda_client = None
        if getenv("AWS_CHALICE_CLI_MODE") == "true":
            lambda_client = LocalLambdaClient(self.chalice, Config())

        self.app.listener_runner.lazy_listener_runner = ChaliceLazyListenerRunner(
            logger=self.logger, lambda_client=lambda_client)

        if self.app.oauth_flow is not None:
            self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = "?"
示例#4
0
 def __init__(
     self,
     *,
     app_name: str,
     func: Callable[..., Awaitable[BoltResponse]],
     matchers: List[AsyncListenerMatcher],
     middleware: List[AsyncMiddleware],
     auto_acknowledgement: bool = False,
 ):
     self.app_name = app_name
     self.func = func
     self.matchers = matchers
     self.middleware = middleware
     self.auto_acknowledgement = auto_acknowledgement
     self.arg_names = inspect.getfullargspec(func).args
     self.logger = get_bolt_app_logger(app_name, self.func)
示例#5
0
 def _init_context(self, req: BoltRequest):
     req.context["logger"] = get_bolt_app_logger(self.name)
     req.context["token"] = self._token
     if self._token is not None:
         # This WebClient instance can be safely singleton
         req.context["client"] = self._client
     else:
         # Set a new dedicated instance for this request
         client_per_request: WebClient = WebClient(
             token=None,  # the token will be set later
             base_url=self._client.base_url,
             timeout=self._client.timeout,
             ssl=self._client.ssl,
             proxy=self._client.proxy,
             headers=self._client.headers,
         )
         req.context["client"] = client_per_request
示例#6
0
 def __init__(
     self,
     *,
     app_name: str,
     ack_function: Callable[..., Awaitable[Optional[BoltResponse]]],
     lazy_functions: Sequence[Callable[..., Awaitable[None]]],
     matchers: Sequence[AsyncListenerMatcher],
     middleware: Sequence[AsyncMiddleware],
     auto_acknowledgement: bool = False,
 ):
     self.app_name = app_name
     self.ack_function = ack_function
     self.lazy_functions = lazy_functions
     self.matchers = matchers
     self.middleware = middleware
     self.auto_acknowledgement = auto_acknowledgement
     self.arg_names = inspect.getfullargspec(ack_function).args
     self.logger = get_bolt_app_logger(app_name, self.ack_function)
示例#7
0
 def _init_context(self, req: AsyncBoltRequest):
     req.context["logger"] = get_bolt_app_logger(self.name)
     req.context["token"] = self._token
     if self._token is not None:
         # This AsyncWebClient instance can be safely singleton
         req.context["client"] = self._async_client
     else:
         # Set a new dedicated instance for this request
         client_per_request: AsyncWebClient = AsyncWebClient(
             token=None,  # the token will be set later
             base_url=self._async_client.base_url,
             timeout=self._async_client.timeout,
             ssl=self._async_client.ssl,
             proxy=self._async_client.proxy,
             session=self._async_client.session,
             trust_env_in_session=self._async_client.trust_env_in_session,
             headers=self._async_client.headers,
             team_id=req.context.team_id,
         )
         req.context["client"] = client_per_request
示例#8
0
    def __init__(self,
                 app: App,
                 chalice: Chalice,
                 lambda_client: Optional[BaseClient] = None):  # type: ignore
        self.app = app
        self.chalice = chalice
        self.logger = get_bolt_app_logger(app.name, ChaliceSlackRequestHandler)

        if getenv("AWS_CHALICE_CLI_MODE") == "true" and lambda_client is None:
            try:
                from slack_bolt.adapter.aws_lambda.local_lambda_client import (
                    LocalLambdaClient, )

                lambda_client = LocalLambdaClient(self.chalice, None)
            except ImportError:
                logging.info("Failed to load LocalLambdaClient for CLI mode.")
                pass

        self.app.listener_runner.lazy_listener_runner = ChaliceLazyListenerRunner(
            logger=self.logger, lambda_client=lambda_client)

        if self.app.oauth_flow is not None:
            self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = "?"
示例#9
0
 def __init__(self, *, app_name: str, func: Callable):
     self.app_name = app_name
     self.func = func
     self.arg_names = inspect.getfullargspec(func).args
     self.logger = get_bolt_app_logger(self.app_name, self.func)
示例#10
0
 def __init__(self, app: App, chalice: Chalice):  # type: ignore
     self.app = app
     self.chalice = chalice
     self.logger = get_bolt_app_logger(app.name, ChaliceSlackRequestHandler)
示例#11
0
 def _init_context(self, req: AsyncBoltRequest):
     req.context["logger"] = get_bolt_app_logger(self.name)
     req.context["token"] = self._token
     req.context["client"] = self._async_client
示例#12
0
 def __init__(self, app: App):  # type: ignore
     self.app = app
     self.logger = get_bolt_app_logger(app.name, SlackRequestHandler)