"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,
import shlex
actions = {}
+actions['button'] = {}
commands = {}
submission_handlers = {}
# Hunt/Puzzle IDs are restricted to lowercase letters, numbers, and underscores
+#
+# Note: This restriction not only allows for hunt and puzzle ID values to
+# be used as Slack channel names, but it also allows for '-' as a valid
+# separator between a hunt and a puzzle ID (for example in the puzzle
+# edit dialog where a single attribute must capture both values).
valid_id_re = r'^[_a-z0-9]+$'
lambda_ok = {'statusCode': 200}
actions['multi_static_select'] = {"*": multi_static_select}
+def edit_puzzle(turb, payload):
+ """Handler for the action of user pressing an edit_puzzle button"""
+
+ print("DEBUG: In edit_puzzle with payload: {}".format(str(payload)))
+
+ return lambda_ok
+
+actions['button']['edit_puzzle'] = edit_puzzle
+
def new_hunt(turb, payload):
"""Handler for the action of user pressing the new_hunt button"""
return lambda_ok
-actions['button'] = {"new_hunt": new_hunt}
+actions['button']['new_hunt'] = new_hunt
def new_hunt_submission(turb, payload, metadata):
"""Handler for the user submitting the new hunt modal
', '.join(links), state_str
)
+ # Combining hunt ID and puzzle ID together here is safe because
+ # both IDs are restricted to not contain a hyphen, (see
+ # valid_id_re in interaction.py)
+ hunt_and_puzzle = "{}-{}".format(puzzle['hunt_id'], puzzle['puzzle_id'])
+
return [
accessory_block(
section_block(text_block(puzzle_text)),
- button_block("✏", puzzle['puzzle_id'])
+ button_block("✏", "edit_puzzle", hunt_and_puzzle)
)
]