Holds utility methods for building a block.
src.block_kit_builder.block_util.
get_checkmark
(task_completed: bool) → str¶Returns a check mark emoji indicating the completed task status. If the task is complete, then a white check mark is returned. If not, an empty white square is.
task_completed (bool) – Whether or not the task was complete.
A checkmark emoji string based on whether or not the task was completed.
str
src.block_kit_builder.block_util.
get_information_block
(info_link: str, info_text: str) → dict¶Returns an information block, which is a section with an info icon followed by linked text.
info_link (str) – The link the block redirects the user to.
info_text (str) – The link text.
A dict in the format of a context block.
dict
src.block_kit_builder.block_util.
get_onboarding_block
() → list¶Constructs an onboarding block, which contains information on different channels and a link to the CodeDevils website.
The onboarding message block as a list.
list
src.block_kit_builder.block_util.
get_task_block
(text: str, info_link: str, info_text: str) → list¶Returns a task block, which is comprised of a paragraph of text followed by an information link at the bottom.
text (str) – Markdown-supported text to display in the paragraph.
info_link (str) – The link associated with the task block.
info_text (str) – The link text.
An array of blocks formatted for a block payload.
list
src.block_kit_builder.block_util.
get_text_block_with_accessory
(text_object: src.block_kit_builder.composition_object.text_object.TextObject, accessory: src.block_kit_builder.block_element.block_element.BlockElement) → dict¶Returns a text block with an accessory.
text_object (TextObject) – The text block object.
accessory (LayoutBlock) – The accessory object.
The text block with an accessory layout block.
dict
src.block_kit_builder.block_util.
get_text_block_with_image
(text: str, image_url: str, alt_text: str) → dict¶Returns a text block with an image to the right of it.
text (str) – The text in the text block.
image_url (str) – The URL to the image.
alt_text (str) – Alternate text (appears on image hover).
The block as a dict.
dict
src.block_kit_builder.block_generator.
BlockGenerator
(config, channel=None)¶Constructs block payloads that act as formatted messages for Slack. For more information on blocks, see https://api.slack.com/block-kit.
get_message_payload
(blocks: list, view_type: str = None) → dict¶Returns a message block payload used to post messages in a specific channel.
blocks (list) – The blocks to be inserted into the message payload.
view_type (str, optional) – Used to determine the type of block for a view publish, defaults to None
The message payload as a dict.
dict
get_welcome_block
(channel: str) → dict¶Sends the welcome message to the user.
channel (str) – The channel ID of the user as a string.
The response from the message payload.
dict