|
@@ -96,13 +96,8 @@ def get_hotkeys(past=False):
|
|
|
ls = []
|
|
|
for row in db.query(sqls):
|
|
|
ls.append(row['ts_word'])
|
|
|
- ls = list(dict.fromkeys(ls))
|
|
|
- out_result = ''
|
|
|
- num = 1
|
|
|
- for w in ls:
|
|
|
- out_result = out_result + "第"+str(num)+"名 :"+ w+'\n'
|
|
|
- num = num + 1
|
|
|
- return out_result
|
|
|
+ #ls = list(dict.fromkeys(ls))
|
|
|
+ return ls
|
|
|
|
|
|
|
|
|
@app.get("/aws")
|
|
@@ -160,10 +155,10 @@ def flex_test():
|
|
|
row_dict['contents']= [
|
|
|
{
|
|
|
"type": "text",
|
|
|
- "text": "第"+str(i)+"名次",
|
|
|
+ "text": "第"+str(i)+"名",
|
|
|
"size": "sm",
|
|
|
"color": "#aaaaaa",
|
|
|
- "flex": 1
|
|
|
+ "flex": 2
|
|
|
},
|
|
|
{
|
|
|
"type": "text",
|
|
@@ -240,11 +235,32 @@ def message_text(event):
|
|
|
|
|
|
|
|
|
if event.message.text=='熱門關鍵字':
|
|
|
- out_result = get_hotkeys(False)
|
|
|
-
|
|
|
- line_bot_api.reply_message(
|
|
|
- event.reply_token,
|
|
|
- TextSendMessage(text=out_result))
|
|
|
+ js=json.load(open('test.json','r',encoding='utf-8'))
|
|
|
+ keys = get_hotkeys(past=False)
|
|
|
+ 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]
|
|
|
+ line_bot_api.reply_message(event.reply_token, FlexSendMessage('ChoozMo',FlexMessage))
|
|
|
+ return
|
|
|
|
|
|
if event.message.text=='關鍵字歷史走勢':
|
|
|
out_result = get_hotkeys(True)
|