]> git.cworth.org Git - turbot/commitdiff
Use absolute URLs to link to channels
authorCarl Worth <cworth@cworth.org>
Thu, 22 Oct 2020 12:15:04 +0000 (05:15 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 22 Oct 2020 22:46:37 +0000 (15:46 -0700)
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).

turbot/events.py

index c0549828b069d7cf0e8f5e9c0dc527325617ad39..db03af8e022721cf1fedc0508a7a8d7a3a9991e0 100644 (file)
@@ -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)),