From: Carl Worth Date: Thu, 22 Oct 2020 12:15:04 +0000 (-0700) Subject: Use absolute URLs to link to channels X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=fe6175fcab04c52da376db4f130ced23d91b8f26;p=turbot Use absolute URLs to link to channels This way we can just make the puzzle name a link rather than having the noise of the channel name present in the view too, (which doesn't actually add anything). --- diff --git a/turbot/events.py b/turbot/events.py index c054982..db03af8 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -12,18 +12,27 @@ events = {} lambda_success = {'statusCode': 200} lambda_error = {'statusCode': 400} +def channel_url(channel_id): + return "https://halibutthatbass.slack.com/archives/{}".format(channel_id) + def puzzle_block(puzzle): name = puzzle['name'] status = puzzle['status'] + solution = puzzle['solution'] channel_id = puzzle['channel_id'] status_emoji = '' + solution_str = '' if status == 'solved': status_emoji = ":ballot_box_with_check:" else: status_emoji = ":white_square:" - puzzle_text = "{} {}: <#{}>".format(status_emoji, name, channel_id) + if len(solution): + solution_str = "*`" + '`, `'.join(solution) + "`*" + + puzzle_text = "{}{} <{}|{}>".format( + status_emoji, solution_str, channel_url(channel_id), name) return section_block(text_block(puzzle_text)) @@ -35,7 +44,7 @@ def hunt_block(turb, hunt): response = turb.db.Table(hunt_id).scan() puzzles = response['Items'] - hunt_text = "*{}*: <#{}>".format(name, channel_id) + hunt_text = "*<{}|{}>*".format(channel_url(channel_id), name) return [ section_block(text_block(hunt_text)),