]> git.cworth.org Git - turbot/blob - turbot/blocks.py
Turbot home: Report "you do not belong to any hunts" if that is the case
[turbot] / turbot / blocks.py
1 def divider_block():
2     return {
3         "type": "divider"
4     }
5
6 def text_block(body):
7     return {
8         "text": {
9             "type": "mrkdwn",
10             "text": body
11         }
12     }
13
14 def section_block(block):
15     return {
16         "type": "section",
17         **block
18     }
19
20 def actions_block(*elements):
21     return {
22         "type": "actions",
23         "elements": list(elements)
24     }
25
26 def button_block(label, name):
27     return {
28         "type": "button",
29         "text": {
30             "type": "plain_text",
31             "text": label,
32             "emoji": True
33         },
34         "value": name
35     }
36
37 def input_block(label, name, placeholder, optional=False):
38     return {
39         "type": "input",
40         "block_id": name,
41         "optional": optional,
42         "element": {
43             "type": "plain_text_input",
44             "action_id": name,
45             "placeholder": {
46                 "type": "plain_text",
47                 "text": placeholder,
48             }
49         },
50         "label": {
51             "type": "plain_text",
52             "text": label
53         }
54     }