Skip to content

Commit

Permalink
version 3.26.1
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Dec 4, 2023
1 parent d82de19 commit ef883ad
Show file tree
Hide file tree
Showing 19 changed files with 281 additions and 279 deletions.
18 changes: 15 additions & 3 deletions docs/api-docs/slack_sdk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3095,12 +3095,18 @@ <h2 id="note">Note</h2>
*,
channel: str,
users: Union[str, Sequence[str]],
force: Optional[bool] = None,
**kwargs,
) -&gt; SlackResponse:
&#34;&#34;&#34;Invites users to a channel.
https://api.slack.com/methods/conversations.invite
&#34;&#34;&#34;
kwargs.update({&#34;channel&#34;: channel})
kwargs.update(
{
&#34;channel&#34;: channel,
&#34;force&#34;: force,
}
)
if isinstance(users, (list, Tuple)):
kwargs.update({&#34;users&#34;: &#34;,&#34;.join(users)})
else:
Expand Down Expand Up @@ -9760,7 +9766,7 @@ <h3>Methods</h3>
</details>
</dd>
<dt id="slack_sdk.WebClient.conversations_invite"><code class="name flex">
<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>
<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>
</code></dt>
<dd>
<div class="desc"><p>Invites users to a channel.
Expand All @@ -9774,12 +9780,18 @@ <h3>Methods</h3>
*,
channel: str,
users: Union[str, Sequence[str]],
force: Optional[bool] = None,
**kwargs,
) -&gt; SlackResponse:
&#34;&#34;&#34;Invites users to a channel.
https://api.slack.com/methods/conversations.invite
&#34;&#34;&#34;
kwargs.update({&#34;channel&#34;: channel})
kwargs.update(
{
&#34;channel&#34;: channel,
&#34;force&#34;: force,
}
)
if isinstance(users, (list, Tuple)):
kwargs.update({&#34;users&#34;: &#34;,&#34;.join(users)})
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.amazon_s3</cod
self.logger.debug(f&#34;S3 put_object response: {response}&#34;)

def save_bot(self, bot: Bot):
if bot.bot_token is None:
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
return

none = &#34;none&#34;
e_id = bot.enterprise_id or none
t_id = bot.team_id or none
Expand Down Expand Up @@ -243,10 +247,13 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.amazon_s3</cod
data = json.loads(body)
installation = Installation(**data)

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

def save_bot(self, bot: Bot):
if bot.bot_token is None:
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
return

none = &#34;none&#34;
e_id = bot.enterprise_id or none
t_id = bot.team_id or none
Expand Down Expand Up @@ -610,10 +621,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
data = json.loads(body)
installation = Installation(**data)

if installation is not None and user_id is not None:
has_user_installation = user_id is not None and installation is not None
no_bot_token_installation = installation is not None and installation.bot_token is None
should_find_bot_installation = has_user_installation or no_bot_token_installation
if should_find_bot_installation:
# Retrieve the latest bot token, just in case
# See also: https://github.com/slackapi/bolt-python/issues/664
latest_bot_installation = self.find_installation(
latest_bot_installation = self.find_bot(
enterprise_id=enterprise_id,
team_id=team_id,
is_enterprise_install=is_enterprise_install,
Expand Down
24 changes: 19 additions & 5 deletions docs/api-docs/slack_sdk/oauth/installation_store/file/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.file</code></h
f.write(entity)

def save_bot(self, bot: Bot):
if bot.bot_token is None:
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
return

none = &#34;none&#34;
e_id = bot.enterprise_id or none
t_id = bot.team_id or none
Expand Down Expand Up @@ -197,10 +201,13 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.file</code></h
data = json.loads(f.read())
installation = Installation(**data)

if installation is not None and user_id is not None:
has_user_installation = user_id is not None and installation is not None
no_bot_token_installation = installation is not None and installation.bot_token is None
should_find_bot_installation = has_user_installation or no_bot_token_installation
if should_find_bot_installation:
# Retrieve the latest bot token, just in case
# See also: https://github.com/slackapi/bolt-python/issues/664
latest_bot_installation = self.find_installation(
latest_bot_installation = self.find_bot(
enterprise_id=enterprise_id,
team_id=team_id,
is_enterprise_install=is_enterprise_install,
Expand Down Expand Up @@ -284,7 +291,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="slack_sdk.oauth.installation_store.file.FileInstallationStore"><code class="flex name class">
<span>class <span class="ident">FileInstallationStore</span></span>
<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>
<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>
</code></dt>
<dd>
<div class="desc"><p>The installation store interface.</p>
Expand Down Expand Up @@ -373,6 +380,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
f.write(entity)

def save_bot(self, bot: Bot):
if bot.bot_token is None:
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
return

none = &#34;none&#34;
e_id = bot.enterprise_id or none
t_id = bot.team_id or none
Expand Down Expand Up @@ -465,10 +476,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
data = json.loads(f.read())
installation = Installation(**data)

if installation is not None and user_id is not None:
has_user_installation = user_id is not None and installation is not None
no_bot_token_installation = installation is not None and installation.bot_token is None
should_find_bot_installation = has_user_installation or no_bot_token_installation
if should_find_bot_installation:
# Retrieve the latest bot token, just in case
# See also: https://github.com/slackapi/bolt-python/issues/664
latest_bot_installation = self.find_installation(
latest_bot_installation = self.find_bot(
enterprise_id=enterprise_id,
team_id=team_id,
is_enterprise_install=is_enterprise_install,
Expand Down
63 changes: 19 additions & 44 deletions docs/api-docs/slack_sdk/oauth/installation_store/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,17 @@ <h2 class="section-title" id="header-classes">Classes</h2>
else:
self.bot_scopes = bot_scopes
self.bot_refresh_token = bot_refresh_token

if bot_token_expires_at is not None:
if type(bot_token_expires_at) == datetime:
self.bot_token_expires_at = int(bot_token_expires_at.timestamp()) # type: ignore
elif type(bot_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, bot_token_expires_at):
self.bot_token_expires_at = int(_from_iso_format_to_unix_timestamp(bot_token_expires_at))
else:
self.bot_token_expires_at = int(bot_token_expires_at)
self.bot_token_expires_at = _timestamp_to_type(bot_token_expires_at, int)
elif bot_token_expires_in is not None:
self.bot_token_expires_at = int(time()) + bot_token_expires_in
else:
self.bot_token_expires_at = None

self.is_enterprise_install = is_enterprise_install or False

if type(installed_at) == float:
self.installed_at = installed_at # type: ignore
elif type(installed_at) == datetime:
self.installed_at = installed_at.timestamp() # type: ignore
elif type(installed_at) == str:
if re.match(&#34;^\\d+.\\d+$&#34;, installed_at):
self.installed_at = float(installed_at)
else:
self.installed_at = _from_iso_format_to_unix_timestamp(installed_at)
else:
raise ValueError(f&#34;Unsupported data format for installed_at {installed_at}&#34;)
self.installed_at = _timestamp_to_type(installed_at, float)

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

Expand Down Expand Up @@ -340,7 +327,7 @@ <h3>Methods</h3>
</dd>
<dt id="slack_sdk.oauth.installation_store.FileInstallationStore"><code class="flex name class">
<span>class <span class="ident">FileInstallationStore</span></span>
<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>
<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>
</code></dt>
<dd>
<div class="desc"><p>The installation store interface.</p>
Expand Down Expand Up @@ -429,6 +416,10 @@ <h3>Methods</h3>
f.write(entity)

def save_bot(self, bot: Bot):
if bot.bot_token is None:
self.logger.debug(&#34;Skipped saving a new row because of the absense of bot token in it&#34;)
return

none = &#34;none&#34;
e_id = bot.enterprise_id or none
t_id = bot.team_id or none
Expand Down Expand Up @@ -521,10 +512,13 @@ <h3>Methods</h3>
data = json.loads(f.read())
installation = Installation(**data)

if installation is not None and user_id is not None:
has_user_installation = user_id is not None and installation is not None
no_bot_token_installation = installation is not None and installation.bot_token is None
should_find_bot_installation = has_user_installation or no_bot_token_installation
if should_find_bot_installation:
# Retrieve the latest bot token, just in case
# See also: https://github.com/slackapi/bolt-python/issues/664
latest_bot_installation = self.find_installation(
latest_bot_installation = self.find_bot(
enterprise_id=enterprise_id,
team_id=team_id,
is_enterprise_install=is_enterprise_install,
Expand Down Expand Up @@ -781,14 +775,9 @@ <h3>Inherited members</h3>
else:
self.bot_scopes = bot_scopes
self.bot_refresh_token = bot_refresh_token

if bot_token_expires_at is not None:
if type(bot_token_expires_at) == datetime:
ts: float = bot_token_expires_at.timestamp() # type: ignore
self.bot_token_expires_at = int(ts)
elif type(bot_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, bot_token_expires_at):
self.bot_token_expires_at = int(_from_iso_format_to_unix_timestamp(bot_token_expires_at))
else:
self.bot_token_expires_at = bot_token_expires_at # type: ignore
self.bot_token_expires_at = _timestamp_to_type(bot_token_expires_at, int)
elif bot_token_expires_in is not None:
self.bot_token_expires_at = int(time()) + bot_token_expires_in
else:
Expand All @@ -801,14 +790,9 @@ <h3>Inherited members</h3>
else:
self.user_scopes = user_scopes
self.user_refresh_token = user_refresh_token

if user_token_expires_at is not None:
if type(user_token_expires_at) == datetime:
ts: float = user_token_expires_at.timestamp() # type: ignore
self.user_token_expires_at = int(ts)
elif type(user_token_expires_at) == str and not re.match(&#34;^\\d+$&#34;, user_token_expires_at):
self.user_token_expires_at = int(_from_iso_format_to_unix_timestamp(user_token_expires_at))
else:
self.user_token_expires_at = user_token_expires_at # type: ignore
self.user_token_expires_at = _timestamp_to_type(user_token_expires_at, int)
elif user_token_expires_in is not None:
self.user_token_expires_at = int(time()) + user_token_expires_in
else:
Expand All @@ -824,17 +808,8 @@ <h3>Inherited members</h3>

if installed_at is None:
self.installed_at = datetime.now().timestamp()
elif type(installed_at) == float:
self.installed_at = installed_at # type: ignore
elif type(installed_at) == datetime:
self.installed_at = installed_at.timestamp() # type: ignore
elif type(installed_at) == str:
if re.match(&#34;^\\d+.\\d+$&#34;, installed_at):
self.installed_at = float(installed_at)
else:
self.installed_at = _from_iso_format_to_unix_timestamp(installed_at)
else:
raise ValueError(f&#34;Unsupported data format for installed_at {installed_at}&#34;)
self.installed_at = _timestamp_to_type(installed_at, float)

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

Expand Down
63 changes: 39 additions & 24 deletions docs/api-docs/slack_sdk/oauth/installation_store/internals.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,53 @@ <h1 class="title">Module <code>slack_sdk.oauth.installation_store.internals</cod
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">import platform
import datetime
<pre><code class="python">import sys
from datetime import datetime, timezone
from typing import Type, TypeVar, Union

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

utc_timezone = datetime.timezone.utc


def _from_iso_format_to_datetime(iso_datetime_str: str) -&gt; datetime.datetime:
if is_python_3_6:
elements = iso_datetime_str.split(&#34; &#34;)
ymd = elements[0].split(&#34;-&#34;)
hms = elements[1].split(&#34;:&#34;)
return datetime.datetime(
int(ymd[0]),
int(ymd[1]),
int(ymd[2]),
int(hms[0]),
int(hms[1]),
int(hms[2]),
0,
utc_timezone,
)
def _from_iso_format_to_datetime(iso_datetime_str: str) -&gt; datetime:
if sys.version_info[:2] == (3, 6):
format = &#34;%Y-%m-%d %H:%M:%S&#34;
if &#34;.&#34; in iso_datetime_str:
format += &#34;.%f&#34;
return datetime.strptime(iso_datetime_str, format).replace(tzinfo=timezone.utc)
else:
if &#34;+&#34; not in iso_datetime_str:
iso_datetime_str += &#34;+00:00&#34;
return datetime.datetime.fromisoformat(iso_datetime_str)
return datetime.fromisoformat(iso_datetime_str)


def _from_iso_format_to_unix_timestamp(iso_datetime_str: str) -&gt; float:
return _from_iso_format_to_datetime(iso_datetime_str).timestamp()</code></pre>
return _from_iso_format_to_datetime(iso_datetime_str).timestamp()


TimestampType = TypeVar(&#34;TimestampType&#34;, float, int)


def _timestamp_to_type(ts: Union[TimestampType, datetime, str], target_type: Type[TimestampType]) -&gt; TimestampType:
result: TimestampType

if isinstance(ts, target_type):
# unnecessary type casting makes pytype happy
result = target_type(ts)

# although a type of the timestamp is just checked,
# pytype doesn&#39;t consider the following line valid:
# result = ts
# see https://github.com/google/pytype/issues/1012

elif isinstance(ts, datetime):
result = target_type(ts.timestamp())
elif isinstance(ts, str):
try:
result = target_type(ts)
except ValueError:
result = target_type(_from_iso_format_to_unix_timestamp(ts))
else:
raise ValueError(f&#34;Unsupported data format for timestamp {ts}&#34;)

return result</code></pre>
</details>
</section>
<section>
Expand Down
Loading

0 comments on commit ef883ad

Please sign in to comment.