From 5e5cea7b10d2c68758af71a7b58f18d237ffb42b Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 22 Oct 2020 14:51:59 -0700 Subject: [PATCH] Add links to puzzle url and sheet_url on the turbot home app So that whatever links people want, they can all be easily found. --- turbot/events.py | 16 +++++++++++++--- turbot/interaction.py | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/turbot/events.py b/turbot/events.py index db03af8..38199e2 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -3,7 +3,6 @@ from turbot.blocks import ( ) import turbot.sheets import turbot.slack -import itertools TURBOT_USER_ID = 'U01B9QM4P9R' @@ -20,6 +19,8 @@ def puzzle_block(puzzle): status = puzzle['status'] solution = puzzle['solution'] channel_id = puzzle['channel_id'] + url = puzzle.get('url', None) + sheet_url = puzzle.get('sheet_url', None) status_emoji = '' solution_str = '' @@ -31,8 +32,17 @@ def puzzle_block(puzzle): if len(solution): solution_str = "*`" + '`, `'.join(solution) + "`*" - puzzle_text = "{}{} <{}|{}>".format( - status_emoji, solution_str, channel_url(channel_id), name) + links = [] + if url: + links.append("<{}|Puzzle>".format(url)) + if channel_id: + links.append("<{}|Channel>".format(channel_url(channel_id))) + if sheet_url: + links.append("<{}|Sheet>".format(sheet_url)) + + puzzle_text = "{}{} {} ({})".format( + status_emoji, solution_str, name, ', '.join(links) + ) return section_block(text_block(puzzle_text)) diff --git a/turbot/interaction.py b/turbot/interaction.py index 4e626f3..7a4f3e6 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -245,7 +245,9 @@ def puzzle(turb, body, args): channel_name = body['channel_name'][0] trigger_id = body['trigger_id'][0] - (hunt_id, hunt_name) = find_hunt_for_channel(turb, channel_id, channel_name) + (hunt_id, hunt_name) = find_hunt_for_channel(turb, + channel_id, + channel_name) if not hunt_id: return bot_reply("Sorry, this channel doesn't appear to " -- 2.43.0