"value": name
}
+def accessory_block(main, accessory):
+ return {
+ **main,
+ "accessory": {
+ **accessory
+ }
+ }
+
def input_block(label, name, placeholder, optional=False):
return {
"type": "input",
from turbot.blocks import section_block, text_block, divider_block
from turbot.round import round_blocks
-from turbot.puzzle import puzzle_block, puzzle_matches_all
+from turbot.puzzle import puzzle_blocks, puzzle_matches_all
from turbot.channel import channel_url
from boto3.dynamodb.conditions import Key
stray_text = "*Puzzles with no assigned round*"
blocks.append(section_block(text_block(stray_text)))
for puzzle in stray_puzzles:
- blocks.append(puzzle_block(puzzle))
+ blocks += puzzle_blocks(puzzle)
blocks.append(divider_block())
-from turbot.blocks import section_block, text_block
+from turbot.blocks import (
+ section_block, text_block, button_block, accessory_block
+)
from turbot.channel import channel_url
from boto3.dynamodb.conditions import Key
import re
return response['Items'][0]
-def puzzle_block(puzzle):
+def puzzle_blocks(puzzle):
"""Generate Slack blocks for a puzzle
The puzzle argument should be a dictionary as returned from the
', '.join(links), state_str
)
- return section_block(text_block(puzzle_text))
+ return [
+ accessory_block(
+ section_block(text_block(puzzle_text)),
+ button_block("✏", puzzle['puzzle_id'])
+ )
+ ]
def puzzle_matches_one(puzzle, pattern):
"""Returns True if this puzzle matches the given string (regexp)
-from turbot.puzzle import puzzle_block
+from turbot.puzzle import puzzle_blocks
from turbot.blocks import section_block, text_block
def round_blocks(round, puzzles):
continue
if round not in puzzle['rounds']:
continue
- blocks.append(puzzle_block(puzzle))
+ blocks += puzzle_blocks(puzzle)
return blocks