Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions block-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes
- **[Table](https://docs.slack.dev/reference/block-kit/blocks/table-block)**: Displays structured information in a table. [Implementation](./src/blocks/table.py).
- **[Task card](https://docs.slack.dev/reference/block-kit/blocks/task-card-block)**: Displays a single task, representing a single action. [Implementation](./src/blocks/task_card.py).
- **[Video](https://docs.slack.dev/reference/block-kit/blocks/video-block)**: Displays an embedded video player. [Implementation](./src/blocks/video.py).

### Block elements

- **[Attachment mention](https://docs.slack.dev/reference/block-kit/block-elements/attachment-mention-element)**: Renders as a rich app attachment or entity reference. [Implementation](./src/block_elements/attachment_mention.py).
Empty file.
26 changes: 26 additions & 0 deletions block-kit/src/block_elements/attachment_mention.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from slack_sdk.models.blocks import RichTextBlock
from slack_sdk.models.blocks.block_elements import (
RichTextElementParts,
RichTextSectionElement,
)


def example01() -> RichTextBlock:
"""
Renders as a rich app attachment or entity reference.
https://docs.slack.dev/reference/block-kit/block-elements/attachment-mention-element/

An attachment mention referencing an app attachment by URL.
"""
block = RichTextBlock(
elements=[
RichTextSectionElement(
elements=[
RichTextElementParts.AttachmentMention(
url="https://example.com/attachment"
)
]
)
]
)
return block
Empty file.
23 changes: 23 additions & 0 deletions block-kit/tests/block_elements/test_attachment_mention.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

from src.block_elements import attachment_mention


def test_example01():
block = attachment_mention.example01()
actual = block.to_dict()
expected = {
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "attachment_mention",
"url": "https://example.com/attachment",
}
],
}
],
}
assert json.dumps(actual, sort_keys=True) == json.dumps(expected, sort_keys=True)
Loading