Your Name 4 years ago
parent
commit
7ff4e991e0
1 changed files with 19 additions and 1 deletions
  1. 19 1
      apis/newbot.py

+ 19 - 1
apis/newbot.py

@@ -70,6 +70,16 @@ def get_aws():
     return result
 
 
+def get_idea():
+    result=''
+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
+    cursor=db.query('SELECT query FROM hhh.gsc_weekly where clicks > 500 order by rand() limit 10;')
+    for c in cursor:
+        result+=str(c['query'])+"\n"
+    return result
+
+
+
 @app.get("/aws")
 async def aws():
     result='<html><head><link href="https://getbootstrap.com/docs/4.1/dist/css/bootstrap.min.css" rel="stylesheet"></head><body>'
@@ -146,6 +156,14 @@ def message_text(event):
                     
         return
 
+    if event.message.text == 'q_idea':
+        s_news=True
+        line_bot_api.reply_message(
+            event.reply_token,
+            TextSendMessage(text=get_idea()))
+        return
+
+
 
     if event.message.text == 'seo':
         seo=True
@@ -167,7 +185,7 @@ def message_text(event):
                         quick_reply=QuickReply(
                             items=[
                                 QuickReplyButton(
-                                    action=MessageAction(label="按我測試", text="text2")
+                                    action=MessageAction(label="幸福空間靈感", text="q_idea")
                                 ),
                                 QuickReplyButton(
                                     action=MessageAction(label="查AWS", text="q_aws")