]> git.cworth.org Git - turbot/commitdiff
Add links to puzzle url and sheet_url on the turbot home app
authorCarl Worth <cworth@cworth.org>
Thu, 22 Oct 2020 21:51:59 +0000 (14:51 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 22 Oct 2020 22:46:40 +0000 (15:46 -0700)
So that whatever links people want, they can all be easily found.

turbot/events.py
turbot/interaction.py

index db03af8e022721cf1fedc0508a7a8d7a3a9991e0..38199e2270f4a08b8104326ecc3b5939b7dd5857 100644 (file)
@@ -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))
 
index 4e626f39fc0c7adc4ec2a3be32c63d9aec632216..7a4f3e6d5b0b26ffc737ad8a97d17b131c966e94 100644 (file)
@@ -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 "