Skip to content

Commit 973af99

Browse files
authored
feat: accept markdown_text argument from the say helper (#1372)
1 parent 39bf678 commit 973af99

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

slack_bolt/context/say/async_say.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from typing import Optional, Union, Dict, Sequence, Callable, Awaitable
1+
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
22

3-
from slack_sdk.models.metadata import Metadata
4-
5-
from slack_bolt.context.say.internals import _can_say
6-
from slack_bolt.util.utils import create_copy
73
from slack_sdk.models.attachments import Attachment
84
from slack_sdk.models.blocks import Block
5+
from slack_sdk.models.metadata import Metadata
96
from slack_sdk.web.async_client import AsyncWebClient
107
from slack_sdk.web.async_slack_response import AsyncSlackResponse
118

9+
from slack_bolt.context.say.internals import _can_say
10+
from slack_bolt.util.utils import create_copy
11+
1212

1313
class AsyncSay:
1414
client: Optional[AsyncWebClient]
@@ -42,6 +42,7 @@ async def __call__(
4242
icon_emoji: Optional[str] = None,
4343
icon_url: Optional[str] = None,
4444
username: Optional[str] = None,
45+
markdown_text: Optional[str] = None,
4546
mrkdwn: Optional[bool] = None,
4647
link_names: Optional[bool] = None,
4748
parse: Optional[str] = None, # none, full
@@ -67,6 +68,7 @@ async def __call__(
6768
icon_emoji=icon_emoji,
6869
icon_url=icon_url,
6970
username=username,
71+
markdown_text=markdown_text,
7072
mrkdwn=mrkdwn,
7173
link_names=link_names,
7274
parse=parse,

slack_bolt/context/say/say.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Union, Dict, Sequence, Callable
1+
from typing import Callable, Dict, Optional, Sequence, Union
22

33
from slack_sdk import WebClient
44
from slack_sdk.models.attachments import Attachment
@@ -45,6 +45,7 @@ def __call__(
4545
icon_emoji: Optional[str] = None,
4646
icon_url: Optional[str] = None,
4747
username: Optional[str] = None,
48+
markdown_text: Optional[str] = None,
4849
mrkdwn: Optional[bool] = None,
4950
link_names: Optional[bool] = None,
5051
parse: Optional[str] = None, # none, full
@@ -70,6 +71,7 @@ def __call__(
7071
icon_emoji=icon_emoji,
7172
icon_url=icon_url,
7273
username=username,
74+
markdown_text=markdown_text,
7375
mrkdwn=mrkdwn,
7476
link_names=link_names,
7577
parse=parse,

tests/slack_bolt/context/test_say.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from slack_sdk.web import SlackResponse
44

55
from slack_bolt import Say
6-
from tests.mock_web_api_server import (
7-
setup_mock_web_api_server,
8-
cleanup_mock_web_api_server,
9-
)
6+
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
107

118

129
class TestSay:
@@ -24,6 +21,11 @@ def test_say(self):
2421
response: SlackResponse = say(text="Hi there!")
2522
assert response.status_code == 200
2623

24+
def test_say_markdown_text(self):
25+
say = Say(client=self.web_client, channel="C111")
26+
response: SlackResponse = say(markdown_text="**Greetings!**")
27+
assert response.status_code == 200
28+
2729
def test_say_unfurl_options(self):
2830
say = Say(client=self.web_client, channel="C111")
2931
response: SlackResponse = say(text="Hi there!", unfurl_media=True, unfurl_links=True)

tests/slack_bolt_async/context/test_async_say.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
from slack_sdk.web.async_client import AsyncWebClient
33
from slack_sdk.web.async_slack_response import AsyncSlackResponse
44

5-
from tests.utils import get_event_loop
65
from slack_bolt.context.say.async_say import AsyncSay
7-
from tests.mock_web_api_server import (
8-
cleanup_mock_web_api_server_async,
9-
setup_mock_web_api_server_async,
10-
)
6+
from tests.mock_web_api_server import cleanup_mock_web_api_server_async, setup_mock_web_api_server_async
7+
from tests.utils import get_event_loop
118

129

1310
class TestAsyncSay:
@@ -29,6 +26,12 @@ async def test_say(self):
2926
response: AsyncSlackResponse = await say(text="Hi there!")
3027
assert response.status_code == 200
3128

29+
@pytest.mark.asyncio
30+
async def test_say_markdown_text(self):
31+
say = AsyncSay(client=self.web_client, channel="C111")
32+
response: AsyncSlackResponse = await say(markdown_text="**Greetings!**")
33+
assert response.status_code == 200
34+
3235
@pytest.mark.asyncio
3336
async def test_say_unfurl_options(self):
3437
say = AsyncSay(client=self.web_client, channel="C111")

0 commit comments

Comments
 (0)