Skip to content

Commit ef883ad

Browse files
committed
version 3.26.1
1 parent d82de19 commit ef883ad

File tree

19 files changed

+281
-279
lines changed

19 files changed

+281
-279
lines changed

docs/api-docs/slack_sdk/index.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,12 +3095,18 @@ <h2 id="note">Note</h2>
30953095
*,
30963096
channel: str,
30973097
users: Union[str, Sequence[str]],
3098+
force: Optional[bool] = None,
30983099
**kwargs,
30993100
) -&gt; SlackResponse:
31003101
&#34;&#34;&#34;Invites users to a channel.
31013102
https://api.slack.com/methods/conversations.invite
31023103
&#34;&#34;&#34;
3103-
kwargs.update({&#34;channel&#34;: channel})
3104+
kwargs.update(
3105+
{
3106+
&#34;channel&#34;: channel,
3107+
&#34;force&#34;: force,
3108+
}
3109+
)
31043110
if isinstance(users, (list, Tuple)):
31053111
kwargs.update({&#34;users&#34;: &#34;,&#34;.join(users)})
31063112
else:
@@ -9760,7 +9766,7 @@ <h3>Methods</h3>
97609766
</details>
97619767
</dd>
97629768
<dt id="slack_sdk.WebClient.conversations_invite"><code class="name flex">
9763-
<span>def <span class="ident">conversations_invite</span></span>(<span>self, *, channel: str, users: Union[str, Sequence[str]], **kwargs) ‑> <a title="slack_sdk.web.slack_response.SlackResponse" href="web/slack_response.html#slack_sdk.web.slack_response.SlackResponse">SlackResponse</a></span>
9769+
<span>def <span class="ident">conversations_invite</span></span>(<span>self, *, channel: str, users: Union[str, Sequence[str]], force: Optional[bool] = None, **kwargs) ‑> <a title="slack_sdk.web.slack_response.SlackResponse" href="web/slack_response.html#slack_sdk.web.slack_response.SlackResponse">SlackResponse</a></span>
97649770
</code></dt>
97659771
<dd>
97669772
<div class="desc"><p>Invites users to a channel.
@@ -9774,12 +9780,18 @@ <h3>Methods</h3>
97749780
*,
97759781
channel: str,
97769782
users: Union[str, Sequence[str]],
9783+
force: Optional[bool] = None,
97779784
**kwargs,
97789785
) -&gt; SlackResponse:
97799786
&#34;&#34;&#34;Invites users to a channel.
97809787
https://api.slack.com/methods/conversations.invite
97819788
&#34;&#34;&#34;
9782-
kwargs.update({&#34;channel&#34;: channel})
9789+
kwargs.update(
9790+
{
9791+
&#34;channel&#34;: channel,
9792+
&#34;force&#34;: force,
9793+
}
9794+
)
97839795
if isinstance(users, (list, Tuple)):
97849796
kwargs.update({&#34;users&#34;: &#34;,&#34;.join(users)})
97859797
else:

docs/api-docs/slack_sdk/oauth/installation_store/amazon_s3/index.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.amazon_s3</cod
133133
self.logger.debug(f&#34;S3 put_object response: {response}&#34;)
134134

135135
def save_bot(self, bot: Bot):
136+
if bot.bot_token is None:
137+
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
138+
return
139+
136140
none = &#34;none&#34;
137141
e_id = bot.enterprise_id or none
138142
t_id = bot.team_id or none
@@ -243,10 +247,13 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.amazon_s3</cod
243247
data = json.loads(body)
244248
installation = Installation(**data)
245249

246-
if installation is not None and user_id is not None:
250+
has_user_installation = user_id is not None and installation is not None
251+
no_bot_token_installation = installation is not None and installation.bot_token is None
252+
should_find_bot_installation = has_user_installation or no_bot_token_installation
253+
if should_find_bot_installation:
247254
# Retrieve the latest bot token, just in case
248255
# See also: https://github.com/slackapi/bolt-python/issues/664
249-
latest_bot_installation = self.find_installation(
256+
latest_bot_installation = self.find_bot(
250257
enterprise_id=enterprise_id,
251258
team_id=team_id,
252259
is_enterprise_install=is_enterprise_install,
@@ -500,6 +507,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
500507
self.logger.debug(f&#34;S3 put_object response: {response}&#34;)
501508

502509
def save_bot(self, bot: Bot):
510+
if bot.bot_token is None:
511+
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
512+
return
513+
503514
none = &#34;none&#34;
504515
e_id = bot.enterprise_id or none
505516
t_id = bot.team_id or none
@@ -610,10 +621,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
610621
data = json.loads(body)
611622
installation = Installation(**data)
612623

613-
if installation is not None and user_id is not None:
624+
has_user_installation = user_id is not None and installation is not None
625+
no_bot_token_installation = installation is not None and installation.bot_token is None
626+
should_find_bot_installation = has_user_installation or no_bot_token_installation
627+
if should_find_bot_installation:
614628
# Retrieve the latest bot token, just in case
615629
# See also: https://github.com/slackapi/bolt-python/issues/664
616-
latest_bot_installation = self.find_installation(
630+
latest_bot_installation = self.find_bot(
617631
enterprise_id=enterprise_id,
618632
team_id=team_id,
619633
is_enterprise_install=is_enterprise_install,

docs/api-docs/slack_sdk/oauth/installation_store/file/index.html

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.file</code></h
105105
f.write(entity)
106106

107107
def save_bot(self, bot: Bot):
108+
if bot.bot_token is None:
109+
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
110+
return
111+
108112
none = &#34;none&#34;
109113
e_id = bot.enterprise_id or none
110114
t_id = bot.team_id or none
@@ -197,10 +201,13 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.file</code></h
197201
data = json.loads(f.read())
198202
installation = Installation(**data)
199203

200-
if installation is not None and user_id is not None:
204+
has_user_installation = user_id is not None and installation is not None
205+
no_bot_token_installation = installation is not None and installation.bot_token is None
206+
should_find_bot_installation = has_user_installation or no_bot_token_installation
207+
if should_find_bot_installation:
201208
# Retrieve the latest bot token, just in case
202209
# See also: https://github.com/slackapi/bolt-python/issues/664
203-
latest_bot_installation = self.find_installation(
210+
latest_bot_installation = self.find_bot(
204211
enterprise_id=enterprise_id,
205212
team_id=team_id,
206213
is_enterprise_install=is_enterprise_install,
@@ -284,7 +291,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
284291
<dl>
285292
<dt id="slack_sdk.oauth.installation_store.file.FileInstallationStore"><code class="flex name class">
286293
<span>class <span class="ident">FileInstallationStore</span></span>
287-
<span>(</span><span>*, base_dir: str = '/Users/seratch/.bolt-app-installation', historical_data_enabled: bool = True, client_id: Optional[str] = None, logger: logging.Logger = &lt;Logger slack_sdk.oauth.installation_store.file (WARNING)&gt;)</span>
294+
<span>(</span><span>*, base_dir: str = '/Users/kazuhiro.sera/.bolt-app-installation', historical_data_enabled: bool = True, client_id: Optional[str] = None, logger: logging.Logger = &lt;Logger slack_sdk.oauth.installation_store.file (WARNING)&gt;)</span>
288295
</code></dt>
289296
<dd>
290297
<div class="desc"><p>The installation store interface.</p>
@@ -373,6 +380,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
373380
f.write(entity)
374381

375382
def save_bot(self, bot: Bot):
383+
if bot.bot_token is None:
384+
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
385+
return
386+
376387
none = &#34;none&#34;
377388
e_id = bot.enterprise_id or none
378389
t_id = bot.team_id or none
@@ -465,10 +476,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
465476
data = json.loads(f.read())
466477
installation = Installation(**data)
467478

468-
if installation is not None and user_id is not None:
479+
has_user_installation = user_id is not None and installation is not None
480+
no_bot_token_installation = installation is not None and installation.bot_token is None
481+
should_find_bot_installation = has_user_installation or no_bot_token_installation
482+
if should_find_bot_installation:
469483
# Retrieve the latest bot token, just in case
470484
# See also: https://github.com/slackapi/bolt-python/issues/664
471-
latest_bot_installation = self.find_installation(
485+
latest_bot_installation = self.find_bot(
472486
enterprise_id=enterprise_id,
473487
team_id=team_id,
474488
is_enterprise_install=is_enterprise_install,

docs/api-docs/slack_sdk/oauth/installation_store/index.html

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,17 @@ <h2 class="section-title" id="header-classes">Classes</h2>
162162
else:
163163
self.bot_scopes = bot_scopes
164164
self.bot_refresh_token = bot_refresh_token
165+
165166
if bot_token_expires_at is not None:
166-
if type(bot_token_expires_at) == datetime:
167-
self.bot_token_expires_at = int(bot_token_expires_at.timestamp()) # type: ignore
168-
elif type(bot_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, bot_token_expires_at):
169-
self.bot_token_expires_at = int(_from_iso_format_to_unix_timestamp(bot_token_expires_at))
170-
else:
171-
self.bot_token_expires_at = int(bot_token_expires_at)
167+
self.bot_token_expires_at = _timestamp_to_type(bot_token_expires_at, int)
172168
elif bot_token_expires_in is not None:
173169
self.bot_token_expires_at = int(time()) + bot_token_expires_in
174170
else:
175171
self.bot_token_expires_at = None
172+
176173
self.is_enterprise_install = is_enterprise_install or False
177174

178-
if type(installed_at) == float:
179-
self.installed_at = installed_at # type: ignore
180-
elif type(installed_at) == datetime:
181-
self.installed_at = installed_at.timestamp() # type: ignore
182-
elif type(installed_at) == str:
183-
if re.match(&#34;^\\d+.\\d+$&#34;, installed_at):
184-
self.installed_at = float(installed_at)
185-
else:
186-
self.installed_at = _from_iso_format_to_unix_timestamp(installed_at)
187-
else:
188-
raise ValueError(f&#34;Unsupported data format for installed_at {installed_at}&#34;)
175+
self.installed_at = _timestamp_to_type(installed_at, float)
189176

190177
self.custom_values = custom_values if custom_values is not None else {}
191178

@@ -340,7 +327,7 @@ <h3>Methods</h3>
340327
</dd>
341328
<dt id="slack_sdk.oauth.installation_store.FileInstallationStore"><code class="flex name class">
342329
<span>class <span class="ident">FileInstallationStore</span></span>
343-
<span>(</span><span>*, base_dir: str = '/Users/seratch/.bolt-app-installation', historical_data_enabled: bool = True, client_id: Optional[str] = None, logger: logging.Logger = &lt;Logger slack_sdk.oauth.installation_store.file (WARNING)&gt;)</span>
330+
<span>(</span><span>*, base_dir: str = '/Users/kazuhiro.sera/.bolt-app-installation', historical_data_enabled: bool = True, client_id: Optional[str] = None, logger: logging.Logger = &lt;Logger slack_sdk.oauth.installation_store.file (WARNING)&gt;)</span>
344331
</code></dt>
345332
<dd>
346333
<div class="desc"><p>The installation store interface.</p>
@@ -429,6 +416,10 @@ <h3>Methods</h3>
429416
f.write(entity)
430417

431418
def save_bot(self, bot: Bot):
419+
if bot.bot_token is None:
420+
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
421+
return
422+
432423
none = &#34;none&#34;
433424
e_id = bot.enterprise_id or none
434425
t_id = bot.team_id or none
@@ -521,10 +512,13 @@ <h3>Methods</h3>
521512
data = json.loads(f.read())
522513
installation = Installation(**data)
523514

524-
if installation is not None and user_id is not None:
515+
has_user_installation = user_id is not None and installation is not None
516+
no_bot_token_installation = installation is not None and installation.bot_token is None
517+
should_find_bot_installation = has_user_installation or no_bot_token_installation
518+
if should_find_bot_installation:
525519
# Retrieve the latest bot token, just in case
526520
# See also: https://github.com/slackapi/bolt-python/issues/664
527-
latest_bot_installation = self.find_installation(
521+
latest_bot_installation = self.find_bot(
528522
enterprise_id=enterprise_id,
529523
team_id=team_id,
530524
is_enterprise_install=is_enterprise_install,
@@ -781,14 +775,9 @@ <h3>Inherited members</h3>
781775
else:
782776
self.bot_scopes = bot_scopes
783777
self.bot_refresh_token = bot_refresh_token
778+
784779
if bot_token_expires_at is not None:
785-
if type(bot_token_expires_at) == datetime:
786-
ts: float = bot_token_expires_at.timestamp() # type: ignore
787-
self.bot_token_expires_at = int(ts)
788-
elif type(bot_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, bot_token_expires_at):
789-
self.bot_token_expires_at = int(_from_iso_format_to_unix_timestamp(bot_token_expires_at))
790-
else:
791-
self.bot_token_expires_at = bot_token_expires_at # type: ignore
780+
self.bot_token_expires_at = _timestamp_to_type(bot_token_expires_at, int)
792781
elif bot_token_expires_in is not None:
793782
self.bot_token_expires_at = int(time()) + bot_token_expires_in
794783
else:
@@ -801,14 +790,9 @@ <h3>Inherited members</h3>
801790
else:
802791
self.user_scopes = user_scopes
803792
self.user_refresh_token = user_refresh_token
793+
804794
if user_token_expires_at is not None:
805-
if type(user_token_expires_at) == datetime:
806-
ts: float = user_token_expires_at.timestamp() # type: ignore
807-
self.user_token_expires_at = int(ts)
808-
elif type(user_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, user_token_expires_at):
809-
self.user_token_expires_at = int(_from_iso_format_to_unix_timestamp(user_token_expires_at))
810-
else:
811-
self.user_token_expires_at = user_token_expires_at # type: ignore
795+
self.user_token_expires_at = _timestamp_to_type(user_token_expires_at, int)
812796
elif user_token_expires_in is not None:
813797
self.user_token_expires_at = int(time()) + user_token_expires_in
814798
else:
@@ -824,17 +808,8 @@ <h3>Inherited members</h3>
824808

825809
if installed_at is None:
826810
self.installed_at = datetime.now().timestamp()
827-
elif type(installed_at) == float:
828-
self.installed_at = installed_at # type: ignore
829-
elif type(installed_at) == datetime:
830-
self.installed_at = installed_at.timestamp() # type: ignore
831-
elif type(installed_at) == str:
832-
if re.match(&#34;^\\d+.\\d+$&#34;, installed_at):
833-
self.installed_at = float(installed_at)
834-
else:
835-
self.installed_at = _from_iso_format_to_unix_timestamp(installed_at)
836811
else:
837-
raise ValueError(f&#34;Unsupported data format for installed_at {installed_at}&#34;)
812+
self.installed_at = _timestamp_to_type(installed_at, float)
838813

839814
self.custom_values = custom_values if custom_values is not None else {}
840815

docs/api-docs/slack_sdk/oauth/installation_store/internals.html

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,53 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.internals</cod
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">import platform
30-
import datetime
29+
<pre><code class="python">import sys
30+
from datetime import datetime, timezone
31+
from typing import Type, TypeVar, Union
3132

32-
(major, minor, patch) = platform.python_version_tuple()
33-
is_python_3_6: bool = int(major) == 3 and int(minor) &gt;= 6
3433

35-
utc_timezone = datetime.timezone.utc
36-
37-
38-
def _from_iso_format_to_datetime(iso_datetime_str: str) -&gt; datetime.datetime:
39-
if is_python_3_6:
40-
elements = iso_datetime_str.split(&#34; &#34;)
41-
ymd = elements[0].split(&#34;-&#34;)
42-
hms = elements[1].split(&#34;:&#34;)
43-
return datetime.datetime(
44-
int(ymd[0]),
45-
int(ymd[1]),
46-
int(ymd[2]),
47-
int(hms[0]),
48-
int(hms[1]),
49-
int(hms[2]),
50-
0,
51-
utc_timezone,
52-
)
34+
def _from_iso_format_to_datetime(iso_datetime_str: str) -&gt; datetime:
35+
if sys.version_info[:2] == (3, 6):
36+
format = &#34;%Y-%m-%d %H:%M:%S&#34;
37+
if &#34;.&#34; in iso_datetime_str:
38+
format += &#34;.%f&#34;
39+
return datetime.strptime(iso_datetime_str, format).replace(tzinfo=timezone.utc)
5340
else:
5441
if &#34;+&#34; not in iso_datetime_str:
5542
iso_datetime_str += &#34;+00:00&#34;
56-
return datetime.datetime.fromisoformat(iso_datetime_str)
43+
return datetime.fromisoformat(iso_datetime_str)
5744

5845

5946
def _from_iso_format_to_unix_timestamp(iso_datetime_str: str) -&gt; float:
60-
return _from_iso_format_to_datetime(iso_datetime_str).timestamp()</code></pre>
47+
return _from_iso_format_to_datetime(iso_datetime_str).timestamp()
48+
49+
50+
TimestampType = TypeVar(&#34;TimestampType&#34;, float, int)
51+
52+
53+
def _timestamp_to_type(ts: Union[TimestampType, datetime, str], target_type: Type[TimestampType]) -&gt; TimestampType:
54+
result: TimestampType
55+
56+
if isinstance(ts, target_type):
57+
# unnecessary type casting makes pytype happy
58+
result = target_type(ts)
59+
60+
# although a type of the timestamp is just checked,
61+
# pytype doesn&#39;t consider the following line valid:
62+
# result = ts
63+
# see https://github.com/google/pytype/issues/1012
64+
65+
elif isinstance(ts, datetime):
66+
result = target_type(ts.timestamp())
67+
elif isinstance(ts, str):
68+
try:
69+
result = target_type(ts)
70+
except ValueError:
71+
result = target_type(_from_iso_format_to_unix_timestamp(ts))
72+
else:
73+
raise ValueError(f&#34;Unsupported data format for timestamp {ts}&#34;)
74+
75+
return result</code></pre>
6176
</details>
6277
</section>
6378
<section>

0 commit comments

Comments
 (0)