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
1 change: 1 addition & 0 deletions block-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes

### 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/elements/attachment_mention.py).
- **[Broadcast](https://docs.slack.dev/reference/block-kit/block-elements/broadcast-element)**: Displays a broadcast mention such as here, channel, or everyone. [Implementation](./src/elements/broadcast.py).
- **[Button](https://docs.slack.dev/reference/block-kit/block-elements/button-element)**: Allows users a direct path to performing basic actions. [Implementation](./src/elements/button.py).
- **[Channel](https://docs.slack.dev/reference/block-kit/block-elements/channel-element)**: Renders as a mention of a channel. [Implementation](./src/elements/channel.py).
Expand Down
26 changes: 26 additions & 0 deletions block-kit/src/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
23 changes: 23 additions & 0 deletions block-kit/tests/elements/test_attachment_mention.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

from src.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