]> git.cworth.org Git - turbot/blob - turbot/blocks.py
Teach '/puzzle' how to do its magic in a puzzle channel
[turbot] / turbot / blocks.py
1 def text_block(body):
2     return {
3         "text": {
4             "type": "mrkdwn",
5             "text": body
6         }
7     }
8
9 def section_block(block):
10     return {
11         "type": "section",
12         **block
13     }
14
15 def actions_block(*elements):
16     return {
17         "type": "actions",
18         "elements": list(elements)
19     }
20
21 def button_block(label, name):
22     return {
23         "type": "button",
24         "text": {
25             "type": "plain_text",
26             "text": label,
27             "emoji": True
28         },
29         "value": name
30     }
31
32 def input_block(label, name, placeholder, optional=False):
33     return {
34         "type": "input",
35         "block_id": name,
36         "optional": optional,
37         "element": {
38             "type": "plain_text_input",
39             "action_id": name,
40             "placeholder": {
41                 "type": "plain_text",
42                 "text": placeholder,
43             }
44         },
45         "label": {
46             "type": "plain_text",
47             "text": label
48         }
49     }