+import turbot.views
+
def new_hunt(turb, payload):
print("In new_hunt function")
+ view = turbot.views.new_hunt()
+ turb.slack_client.views_open(trigger_id=payload['trigger_id'],
+ view=view)
return {
'statusCode': 200,
"value": name
}
+def input(label, name, placeholder):
+ return {
+ "type": "input",
+ "element": {
+ "type": "plain_text_input",
+ "action_id": name,
+ "placeholder": {
+ "type": "plain_text",
+ "text": placeholder,
+ }
+ },
+ "label": {
+ "type": "plain_text",
+ "text": label
+ }
+ }
+
def hunt_block(hunt):
text = "{}: <#{}>".format(hunt['name'], hunt['channel'])
return section(text_block(text))
actions(button("New hunt", "new_hunt"))
]
}
+
+def new_hunt():
+ """Returns a view to be published as the new_hunt modal"""
+
+ return {
+ "type": "modal",
+ "title": { "type": "plain_text", "text": "New Hunt" },
+ "submit": { "type": "plain_text", "text": "Create" },
+ "blocks": [
+ input("Hunt name", "name", "Name of the hunt"),
+ input("Hunt ID", "slug", "Short prefix for hunt (no spaces)"),
+ input("Hunt URL", "url", "External URL of hunt")
+ ]
+ }