+def divider_block():
+ return {
+ "type": "divider"
+ }
+
def text_block(body):
return {
"text": {
}
}
-def section_block(block):
- return {
+def section_block(block, block_id=None):
+
+ block = {
"type": "section",
**block
}
+ if block_id:
+ block['block_id'] = block_id
+
+ return block
+
def actions_block(*elements):
return {
"type": "actions",
"elements": list(elements)
}
-def button_block(label, name):
- return {
+def button_block(label, name, extra=None):
+
+ block = {
"type": "button",
"text": {
"type": "plain_text",
"value": name
}
+ if extra:
+ block['action_id'] = extra
+
+ return block
+
+def accessory_block(main, accessory):
+ return {
+ **main,
+ "accessory": {
+ **accessory
+ }
+ }
+
def input_block(label, name, placeholder, optional=False):
return {
"type": "input",
"text": label
}
}
+
+def multi_select_block(label, name, placeholder, options, default=None):
+
+ multi_select = {
+ "action_id": name,
+ "type": "multi_static_select",
+ "placeholder": {
+ "type": "plain_text",
+ "text": placeholder
+ },
+ "options": [
+ {
+ "text": {
+ "type": "plain_text",
+ "text": option
+ },
+ "value": option
+ } for option in options
+ ]
+ }
+
+ return accessory_block(
+ section_block(text_block("*{}*".format(label)), block_id=name),
+ multi_select
+ )