forked from slackapi/bolt-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinternals.py
More file actions
32 lines (27 loc) · 888 Bytes
/
internals.py
File metadata and controls
32 lines (27 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import inspect
from functools import wraps
from logging import Logger
from typing import Callable
from slack_bolt.kwargs_injection import build_required_kwargs
from slack_bolt.request import BoltRequest
def build_runnable_function(
func: Callable[..., None],
logger: Logger,
request: BoltRequest,
) -> Callable[[], None]:
arg_names = inspect.getfullargspec(func).args
@wraps(func)
def request_wired_func_wrapper() -> None:
try:
func(
**build_required_kwargs(
logger=logger,
required_arg_names=arg_names,
request=request,
response=None,
this_func=func,
)
)
except Exception as e:
logger.error(f"Failed to run an internal function ({e})")
return request_wired_func_wrapper