Skip to content

Commit

Permalink
Fix #738 Add more keyword args to say utility (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Oct 18, 2022
1 parent 4f1b4f8 commit 31146a2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
20 changes: 20 additions & 0 deletions slack_bolt/context/say/async_say.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Optional, Union, Dict, Sequence

from slack_sdk.models.metadata import Metadata

from slack_bolt.context.say.internals import _can_say
from slack_bolt.util.utils import create_copy
from slack_sdk.models.attachments import Attachment
Expand All @@ -26,9 +28,18 @@ async def __call__(
blocks: Optional[Sequence[Union[Dict, Block]]] = None,
attachments: Optional[Sequence[Union[Dict, Attachment]]] = None,
channel: Optional[str] = None,
as_user: Optional[bool] = None,
thread_ts: Optional[str] = None,
reply_broadcast: Optional[bool] = None,
unfurl_links: Optional[bool] = None,
unfurl_media: Optional[bool] = None,
icon_emoji: Optional[str] = None,
icon_url: Optional[str] = None,
username: Optional[str] = None,
mrkdwn: Optional[bool] = None,
link_names: Optional[bool] = None,
parse: Optional[str] = None, # none, full
metadata: Optional[Union[Dict, Metadata]] = None,
**kwargs,
) -> AsyncSlackResponse:
if _can_say(self, channel):
Expand All @@ -40,9 +51,18 @@ async def __call__(
text=text,
blocks=blocks,
attachments=attachments,
as_user=as_user,
thread_ts=thread_ts,
reply_broadcast=reply_broadcast,
unfurl_links=unfurl_links,
unfurl_media=unfurl_media,
icon_emoji=icon_emoji,
icon_url=icon_url,
username=username,
mrkdwn=mrkdwn,
link_names=link_names,
parse=parse,
metadata=metadata,
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
Expand Down
19 changes: 19 additions & 0 deletions slack_bolt/context/say/say.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from slack_sdk import WebClient
from slack_sdk.models.attachments import Attachment
from slack_sdk.models.blocks import Block
from slack_sdk.models.metadata import Metadata
from slack_sdk.web import SlackResponse

from slack_bolt.context.say.internals import _can_say
Expand All @@ -27,9 +28,18 @@ def __call__(
blocks: Optional[Sequence[Union[Dict, Block]]] = None,
attachments: Optional[Sequence[Union[Dict, Attachment]]] = None,
channel: Optional[str] = None,
as_user: Optional[bool] = None,
thread_ts: Optional[str] = None,
reply_broadcast: Optional[bool] = None,
unfurl_links: Optional[bool] = None,
unfurl_media: Optional[bool] = None,
icon_emoji: Optional[str] = None,
icon_url: Optional[str] = None,
username: Optional[str] = None,
mrkdwn: Optional[bool] = None,
link_names: Optional[bool] = None,
parse: Optional[str] = None, # none, full
metadata: Optional[Union[Dict, Metadata]] = None,
**kwargs,
) -> SlackResponse:
if _can_say(self, channel):
Expand All @@ -41,9 +51,18 @@ def __call__(
text=text,
blocks=blocks,
attachments=attachments,
as_user=as_user,
thread_ts=thread_ts,
reply_broadcast=reply_broadcast,
unfurl_links=unfurl_links,
unfurl_media=unfurl_media,
icon_emoji=icon_emoji,
icon_url=icon_url,
username=username,
mrkdwn=mrkdwn,
link_names=link_names,
parse=parse,
metadata=metadata,
**kwargs,
)
elif isinstance(text_or_whole_response, dict):
Expand Down
5 changes: 5 additions & 0 deletions tests/slack_bolt/context/test_say.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def test_say_unfurl_options(self):
response: SlackResponse = say(text="Hi there!", unfurl_media=True, unfurl_links=True)
assert response.status_code == 200

def test_say_reply_in_thread(self):
say = Say(client=self.web_client, channel="C111")
response: SlackResponse = say(text="Hi there!", thread_ts="111.222", reply_broadcast=True)
assert response.status_code == 200

def test_say_dict(self):
say = Say(client=self.web_client, channel="C111")
response: SlackResponse = say({"text": "Hi!"})
Expand Down
6 changes: 6 additions & 0 deletions tests/slack_bolt_async/context/test_async_say.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ async def test_say_unfurl_options(self):
response: AsyncSlackResponse = await say(text="Hi there!", unfurl_links=True, unfurl_media=True)
assert response.status_code == 200

@pytest.mark.asyncio
async def test_say_reply_in_thread(self):
say = AsyncSay(client=self.web_client, channel="C111")
response: AsyncSlackResponse = await say(text="Hi there!", thread_ts="111.222", reply_broadcast=True)
assert response.status_code == 200

@pytest.mark.asyncio
async def test_say_dict(self):
say = AsyncSay(client=self.web_client, channel="C111")
Expand Down

0 comments on commit 31146a2

Please sign in to comment.