No project description provided
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slacktools-blockkit-0.11.0.tar.gz.
File metadata
- Download URL: slacktools-blockkit-0.11.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c970fd5cb92383a1defb1ee60b8c1e0b8debc36b22e77e80b84c6dc57e5da864
|
|
| MD5 |
fa31fca219d904e48580e21aaa8e21ee
|
|
| BLAKE2b-256 |
139e1ce7c890733a75993646297d897c3f6557b7400ac501112dafb83c954e82
|
File details
Details for the file slacktools_blockkit-0.11.0-py3-none-any.whl.
File metadata
- Download URL: slacktools_blockkit-0.11.0-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5560ca737c01e2c33ce6a6c30a63938182a04fb94b17ecc05a5e10c3dee1001a
|
|
| MD5 |
4ac05f0ceabffbba4ba394644effd805
|
|
| BLAKE2b-256 |
d0f40af83255b7b0c4be0f2632cc7e2c686f868716fc4d54c7502aed1c3743e9
|