瀏覽代碼

current keys

ming 3 年之前
父節點
當前提交
2c87dab5c1
共有 1 個文件被更改,包括 14 次插入22 次删除
  1. 14 22
      newbot.py

+ 14 - 22
newbot.py

@@ -107,27 +107,20 @@ def get_hotkeys(past=False):
     keys = get_hotkeys_ls(past)
     num = 1
     for k in keys:
-        row_dict = {}
-        row_dict['type'] = 'box'
-        row_dict['layout'] = 'baseline'
-        row_dict['contents']= [
-            {
-               "type": "text",
-                "text": "第"+str(num)+"名",
-                "size": "sm",
-                "color": "#aaaaaa",
-                "flex": 2
-            },
-            {
-                "type": "text",
-                "text": k,
-                "flex": 5,
-                "weight": "regular"
-            }
-            ]
-        num = num + 1
-        js['body']['contents'] = js['body']['contents'] + [row_dict]
-    return js
+
+    carousel_dict = {"type": "carousel","contents": []}
+    carousel_idx = -1
+    num = 1
+    for k in keys:
+        if (num-1)%12 ==0:
+            carousel_dict['contents'] = carousel_dict['contents']+[make_bubble()]
+            carousel_idx+=1
+       
+        carousel_dict['contents'][carousel_idx]['body']['contents'] += [make_box(num,k)] 
+        num+=1
+
+    return carousel_dict
+
 
 @app.get("/aws")
 async def aws():
@@ -321,7 +314,6 @@ def message_text(event):
 
     if event.message.text=='熱門關鍵字':
         js = get_hotkeys(False)
-        js = make_carousel()
         line_bot_api.reply_message(event.reply_token, FlexSendMessage('ChoozMo',js))
         return