Linebot Django 3

less than 1 minute read

LINE BOT Message 初學者記錄(三) 參考 LINE 官方網站提供新的 API referense 加入不同 Messaging API 功能並做出: Weather, Eats, News

構思與結果:

Step1.

Input word: Test Output: Pumpkin picture with three buttons and Echo test in description

Step 2.

Input: Click “Weather” button Output:Text “Enter a city name” Input:Text “Taipei” Output: Text “It’s “25.5”C and “Rain” in “TW”” and a weather picture

Step 3.

Input: Click “Eat” button Output: Confirm message Input: Click “Delicious” button Output: Random “Delicious food” picture PS. Allow click buttons again and again.

Step 4.

Input: Click “News” button Output: Four “News template” with Title, Description, and HyperLink.

Code:

views.py

Reference:

Get knowhow:

  • Python: List and Dictionary “add” or “del”
  • LINE 多筆資訊放於同個 payload 內.
  • Global variable
  • Function 引數 “Request” 再替 client 送出需含 http header and content 才用到

Wait to fix:

  • Weather 功能只取下一個參數, 當有兩個字以上的城市名會無法取得完整.
  • 尚未做出迴圈提醒功能, 執行在記憶體內. 怎 kill.
  • Azure ㄧ個月到期, 是否要轉換平台.
  • Eat data 還太少.
  • 此 Openweather 雖免費. 但有些國家判斷的溫度好像不太準…
  • News 內容是否需可直接顯示內容無需開啟新網頁(還不可佔我伺服器流量)

心得:

  • 搞定, 頭有點暈, 後面寫出的 function 很少能被重複使用 XD

2016.10.10

下一篇:  Line Bot - Django - Platform to RHC

Leave a comment