]> git.cworth.org Git - turbot/blobdiff - turbot/blocks.py
Add an edit button next to each puzzle
[turbot] / turbot / blocks.py
index 27e69f4d6d9d61140a16e4fa71cd30fcfe9d75e3..cfef7f6a76ecf481224043d5a52b41565f46280b 100644 (file)
@@ -34,6 +34,14 @@ def button_block(label, name):
         "value": name
     }
 
+def accessory_block(main, accessory):
+    return {
+        **main,
+        "accessory": {
+            **accessory
+        }
+    }
+
 def input_block(label, name, placeholder, optional=False):
     return {
         "type": "input",
@@ -52,3 +60,30 @@ def input_block(label, name, placeholder, optional=False):
             "text": label
         }
     }
+
+def multi_select_block(label, name, placeholder, options, default=None):
+    return {
+        "type": "section",
+        "block_id": name,
+        "text": {
+            "type": "mrkdwn",
+            "text": "*{}*".format(label)
+        },
+        "accessory": {
+            "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
+            ]
+        }
+    }