Skip to content

Commit 647701e

Browse files
committed
version 1.14.0
1 parent 0a2cee6 commit 647701e

File tree

49 files changed

+19294
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+19294
-127
lines changed

docs/api-docs/slack_bolt/adapter/aiohttp/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ <h1 class="title">Module <code>slack_bolt.adapter.aiohttp</code></h1>
6666
secure=True,
6767
httponly=True,
6868
)
69-
return resp</code></pre>
69+
return resp
70+
71+
72+
__all__ = [
73+
&#34;to_bolt_request&#34;,
74+
&#34;to_aiohttp_response&#34;,
75+
]</code></pre>
7076
</details>
7177
</section>
7278
<section>

docs/api-docs/slack_bolt/adapter/aws_lambda/index.html

Lines changed: 170 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ <h1 class="title">Module <code>slack_bolt.adapter.aws_lambda</code></h1>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from .handler import SlackRequestHandler # noqa: F401</code></pre>
29+
<pre><code class="python">from .handler import SlackRequestHandler
30+
31+
__all__ = [
32+
&#34;SlackRequestHandler&#34;,
33+
]</code></pre>
3034
</details>
3135
</section>
3236
<section>
@@ -67,6 +71,160 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
6771
<section>
6872
</section>
6973
<section>
74+
<h2 class="section-title" id="header-classes">Classes</h2>
75+
<dl>
76+
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler"><code class="flex name class">
77+
<span>class <span class="ident">SlackRequestHandler</span></span>
78+
<span>(</span><span>app: <a title="slack_bolt.app.app.App" href="../../app/app.html#slack_bolt.app.app.App">App</a>)</span>
79+
</code></dt>
80+
<dd>
81+
<div class="desc"></div>
82+
<details class="source">
83+
<summary>
84+
<span>Expand source code</span>
85+
</summary>
86+
<pre><code class="python">class SlackRequestHandler:
87+
def __init__(self, app: App): # type: ignore
88+
self.app = app
89+
self.logger = get_bolt_app_logger(app.name, SlackRequestHandler, app.logger)
90+
self.app.listener_runner.lazy_listener_runner = LambdaLazyListenerRunner(
91+
self.logger
92+
)
93+
if self.app.oauth_flow is not None:
94+
self.app.oauth_flow.settings.redirect_uri_page_renderer.install_path = &#34;?&#34;
95+
96+
@classmethod
97+
def clear_all_log_handlers(cls):
98+
# https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda
99+
root = logging.getLogger()
100+
if root.handlers:
101+
for handler in root.handlers:
102+
root.removeHandler(handler)
103+
104+
def handle(self, event, context):
105+
self.logger.debug(f&#34;Incoming event: {event}, context: {context}&#34;)
106+
107+
method = event.get(&#34;requestContext&#34;, {}).get(&#34;http&#34;, {}).get(&#34;method&#34;)
108+
if method is None:
109+
method = event.get(&#34;requestContext&#34;, {}).get(&#34;httpMethod&#34;)
110+
111+
if method is None:
112+
return not_found()
113+
if method == &#34;GET&#34;:
114+
if self.app.oauth_flow is not None:
115+
oauth_flow: OAuthFlow = self.app.oauth_flow
116+
bolt_req: BoltRequest = to_bolt_request(event)
117+
query = bolt_req.query
118+
is_callback = query is not None and (
119+
(
120+
_first_value(query, &#34;code&#34;) is not None
121+
and _first_value(query, &#34;state&#34;) is not None
122+
)
123+
or _first_value(query, &#34;error&#34;) is not None
124+
)
125+
if is_callback:
126+
bolt_resp = oauth_flow.handle_callback(bolt_req)
127+
return to_aws_response(bolt_resp)
128+
else:
129+
bolt_resp = oauth_flow.handle_installation(bolt_req)
130+
return to_aws_response(bolt_resp)
131+
elif method == &#34;POST&#34;:
132+
bolt_req = to_bolt_request(event)
133+
# https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
134+
aws_lambda_function_name = context.function_name
135+
bolt_req.context[&#34;aws_lambda_function_name&#34;] = aws_lambda_function_name
136+
bolt_req.context[&#34;lambda_request&#34;] = event
137+
bolt_resp = self.app.dispatch(bolt_req)
138+
aws_response = to_aws_response(bolt_resp)
139+
return aws_response
140+
elif method == &#34;NONE&#34;:
141+
bolt_req = to_bolt_request(event)
142+
bolt_resp = self.app.dispatch(bolt_req)
143+
aws_response = to_aws_response(bolt_resp)
144+
return aws_response
145+
146+
return not_found()</code></pre>
147+
</details>
148+
<h3>Static methods</h3>
149+
<dl>
150+
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers"><code class="name flex">
151+
<span>def <span class="ident">clear_all_log_handlers</span></span>(<span>)</span>
152+
</code></dt>
153+
<dd>
154+
<div class="desc"></div>
155+
<details class="source">
156+
<summary>
157+
<span>Expand source code</span>
158+
</summary>
159+
<pre><code class="python">@classmethod
160+
def clear_all_log_handlers(cls):
161+
# https://stackoverflow.com/questions/37703609/using-python-logging-with-aws-lambda
162+
root = logging.getLogger()
163+
if root.handlers:
164+
for handler in root.handlers:
165+
root.removeHandler(handler)</code></pre>
166+
</details>
167+
</dd>
168+
</dl>
169+
<h3>Methods</h3>
170+
<dl>
171+
<dt id="slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle"><code class="name flex">
172+
<span>def <span class="ident">handle</span></span>(<span>self, event, context)</span>
173+
</code></dt>
174+
<dd>
175+
<div class="desc"></div>
176+
<details class="source">
177+
<summary>
178+
<span>Expand source code</span>
179+
</summary>
180+
<pre><code class="python">def handle(self, event, context):
181+
self.logger.debug(f&#34;Incoming event: {event}, context: {context}&#34;)
182+
183+
method = event.get(&#34;requestContext&#34;, {}).get(&#34;http&#34;, {}).get(&#34;method&#34;)
184+
if method is None:
185+
method = event.get(&#34;requestContext&#34;, {}).get(&#34;httpMethod&#34;)
186+
187+
if method is None:
188+
return not_found()
189+
if method == &#34;GET&#34;:
190+
if self.app.oauth_flow is not None:
191+
oauth_flow: OAuthFlow = self.app.oauth_flow
192+
bolt_req: BoltRequest = to_bolt_request(event)
193+
query = bolt_req.query
194+
is_callback = query is not None and (
195+
(
196+
_first_value(query, &#34;code&#34;) is not None
197+
and _first_value(query, &#34;state&#34;) is not None
198+
)
199+
or _first_value(query, &#34;error&#34;) is not None
200+
)
201+
if is_callback:
202+
bolt_resp = oauth_flow.handle_callback(bolt_req)
203+
return to_aws_response(bolt_resp)
204+
else:
205+
bolt_resp = oauth_flow.handle_installation(bolt_req)
206+
return to_aws_response(bolt_resp)
207+
elif method == &#34;POST&#34;:
208+
bolt_req = to_bolt_request(event)
209+
# https://docs.aws.amazon.com/lambda/latest/dg/python-context.html
210+
aws_lambda_function_name = context.function_name
211+
bolt_req.context[&#34;aws_lambda_function_name&#34;] = aws_lambda_function_name
212+
bolt_req.context[&#34;lambda_request&#34;] = event
213+
bolt_resp = self.app.dispatch(bolt_req)
214+
aws_response = to_aws_response(bolt_resp)
215+
return aws_response
216+
elif method == &#34;NONE&#34;:
217+
bolt_req = to_bolt_request(event)
218+
bolt_resp = self.app.dispatch(bolt_req)
219+
aws_response = to_aws_response(bolt_resp)
220+
return aws_response
221+
222+
return not_found()</code></pre>
223+
</details>
224+
</dd>
225+
</dl>
226+
</dd>
227+
</dl>
70228
</section>
71229
</article>
72230
<nav id="sidebar">
@@ -91,6 +249,17 @@ <h1>Index</h1>
91249
<li><code><a title="slack_bolt.adapter.aws_lambda.local_lambda_client" href="local_lambda_client.html">slack_bolt.adapter.aws_lambda.local_lambda_client</a></code></li>
92250
</ul>
93251
</li>
252+
<li><h3><a href="#header-classes">Classes</a></h3>
253+
<ul>
254+
<li>
255+
<h4><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler">SlackRequestHandler</a></code></h4>
256+
<ul class="">
257+
<li><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler.clear_all_log_handlers">clear_all_log_handlers</a></code></li>
258+
<li><code><a title="slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle" href="#slack_bolt.adapter.aws_lambda.SlackRequestHandler.handle">handle</a></code></li>
259+
</ul>
260+
</li>
261+
</ul>
262+
</li>
94263
</ul>
95264
</nav>
96265
</main>

docs/api-docs/slack_bolt/adapter/bottle/index.html

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ <h1 class="title">Module <code>slack_bolt.adapter.bottle</code></h1>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from .handler import SlackRequestHandler # noqa: F401</code></pre>
29+
<pre><code class="python">from .handler import SlackRequestHandler
30+
31+
__all__ = [
32+
&#34;SlackRequestHandler&#34;,
33+
]</code></pre>
3034
</details>
3135
</section>
3236
<section>
@@ -43,6 +47,77 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
4347
<section>
4448
</section>
4549
<section>
50+
<h2 class="section-title" id="header-classes">Classes</h2>
51+
<dl>
52+
<dt id="slack_bolt.adapter.bottle.SlackRequestHandler"><code class="flex name class">
53+
<span>class <span class="ident">SlackRequestHandler</span></span>
54+
<span>(</span><span>app: <a title="slack_bolt.app.app.App" href="../../app/app.html#slack_bolt.app.app.App">App</a>)</span>
55+
</code></dt>
56+
<dd>
57+
<div class="desc"></div>
58+
<details class="source">
59+
<summary>
60+
<span>Expand source code</span>
61+
</summary>
62+
<pre><code class="python">class SlackRequestHandler:
63+
def __init__(self, app: App): # type: ignore
64+
self.app = app
65+
66+
def handle(self, req: Request, resp: Response) -&gt; str:
67+
if req.method == &#34;GET&#34;:
68+
if self.app.oauth_flow is not None:
69+
oauth_flow: OAuthFlow = self.app.oauth_flow
70+
if req.path == oauth_flow.install_path:
71+
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
72+
set_response(bolt_resp, resp)
73+
return bolt_resp.body or &#34;&#34;
74+
elif req.path == oauth_flow.redirect_uri_path:
75+
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
76+
set_response(bolt_resp, resp)
77+
return bolt_resp.body or &#34;&#34;
78+
elif req.method == &#34;POST&#34;:
79+
bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
80+
set_response(bolt_resp, resp)
81+
return bolt_resp.body or &#34;&#34;
82+
83+
resp.status = 404
84+
return &#34;Not Found&#34;</code></pre>
85+
</details>
86+
<h3>Methods</h3>
87+
<dl>
88+
<dt id="slack_bolt.adapter.bottle.SlackRequestHandler.handle"><code class="name flex">
89+
<span>def <span class="ident">handle</span></span>(<span>self, req: bottle.BaseRequest, resp: bottle.BaseResponse) ‑> str</span>
90+
</code></dt>
91+
<dd>
92+
<div class="desc"></div>
93+
<details class="source">
94+
<summary>
95+
<span>Expand source code</span>
96+
</summary>
97+
<pre><code class="python">def handle(self, req: Request, resp: Response) -&gt; str:
98+
if req.method == &#34;GET&#34;:
99+
if self.app.oauth_flow is not None:
100+
oauth_flow: OAuthFlow = self.app.oauth_flow
101+
if req.path == oauth_flow.install_path:
102+
bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
103+
set_response(bolt_resp, resp)
104+
return bolt_resp.body or &#34;&#34;
105+
elif req.path == oauth_flow.redirect_uri_path:
106+
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
107+
set_response(bolt_resp, resp)
108+
return bolt_resp.body or &#34;&#34;
109+
elif req.method == &#34;POST&#34;:
110+
bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
111+
set_response(bolt_resp, resp)
112+
return bolt_resp.body or &#34;&#34;
113+
114+
resp.status = 404
115+
return &#34;Not Found&#34;</code></pre>
116+
</details>
117+
</dd>
118+
</dl>
119+
</dd>
120+
</dl>
46121
</section>
47122
</article>
48123
<nav id="sidebar">
@@ -61,6 +136,16 @@ <h1>Index</h1>
61136
<li><code><a title="slack_bolt.adapter.bottle.handler" href="handler.html">slack_bolt.adapter.bottle.handler</a></code></li>
62137
</ul>
63138
</li>
139+
<li><h3><a href="#header-classes">Classes</a></h3>
140+
<ul>
141+
<li>
142+
<h4><code><a title="slack_bolt.adapter.bottle.SlackRequestHandler" href="#slack_bolt.adapter.bottle.SlackRequestHandler">SlackRequestHandler</a></code></h4>
143+
<ul class="">
144+
<li><code><a title="slack_bolt.adapter.bottle.SlackRequestHandler.handle" href="#slack_bolt.adapter.bottle.SlackRequestHandler.handle">handle</a></code></li>
145+
</ul>
146+
</li>
147+
</ul>
148+
</li>
64149
</ul>
65150
</nav>
66151
</main>

0 commit comments

Comments
 (0)