]> git.cworth.org Git - turbot/blobdiff - turbot/events.py
Add links to puzzle url and sheet_url on the turbot home app
[turbot] / turbot / events.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))