slacktools-blockkit
slacktools-blockkit provides an expressive interface for utilizing the Slack Block-kit UI framework.
Features:
- Build Slack UIs by composing classes instead of manually constructing dictionaries.
- Easily parse action payloads and modal submission payloads without manual dictionary traversal.
- Compose your own reusable blocks with fixed attributes and avoid magic string lookups when parsing interactive payloads.
Installation:
pip install slacktools-blockkit
Basic Usage:
from blockkit import Message, blocks, elements, objects
message = Message(blocks=[
blocks.Section(objects.MrkdwnText("*User Information: ")),
blocks.Divider(),
blocks.Section(
objects.PlainText("John Doe"),
fields=[
objects.MrkdwnText("Address:\n"),
objects.PlainText("123 Street, City, 11111"),
objects.MrkdwnText("Phone: \n"),
objects.PlainText("111-111-1111")
]
),
blocks.Actions(elements=[
elements.Button(
action_id="delete",
text="Delete User",
style=elements.Button.Styles.DANGER
)
])
])
Parsing action payloads:
from blockkit import elements
value = elements.Button.parse_value(action_payload["actions"][0])
Basic view submission payload parsing:
Define the view:
from blockkit import blocks, views, objects
modal = views.Modal(
title="User Data",
blocks=[
blocks.Section(objects.PlainText("Enter user information:")),
blocks.PlainTextInput(label="Username", block_id="user_data", action_id="username")
]
)
Parse the response:
from blockkit import blocks
value = blocks.PlainTextInput.parse(
view_payload,
block_id="user_data",
action_id="username"
)
Fixed blocks and view submission payload parsing:
Define the fixed block and view:
from blockkit import blocks, views, objects
from blockkit.fixed_blocks import FixedPlainTextInput
class UsernameInput(FixedPlainTextInput):
block_id = "user_data"
action_id = "username"
label = "Username"
modal = views.Modal(
title="User Data",
blocks=[
blocks.Section(objects.PlainText("Enter user information:")),
UsernameInput()
]
)
Parse the response:
value = UsernameInput.parse(view_payload)
Metadata
Release files for slacktools-blockkit 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| slacktools-blockkit-0.11.0.tar.gz | 22.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| slacktools_blockkit-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.6 kB
Release files / slacktools-blockkit-0.11.0.tar.gz
| Download URL | slacktools-blockkit-0.11.0.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c970fd5cb92383a1defb1ee60b8c1e0b8debc36b22e77e80b84c6dc57e5da864
|
|
BLAKE2b-256 checksum How to use checksums |
139e1ce7c890733a75993646297d897c3f6557b7400ac501112dafb83c954e82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|
Release files / slacktools_blockkit-0.11.0-py3-none-any.whl
| Download URL | slacktools_blockkit-0.11.0-py3-none-any.whl |
|---|---|
| Size | 34.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5560ca737c01e2c33ce6a6c30a63938182a04fb94b17ecc05a5e10c3dee1001a
|
|
BLAKE2b-256 checksum How to use checksums |
d0f40af83255b7b0c4be0f2632cc7e2c686f868716fc4d54c7502aed1c3743e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|