王麒淞
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- title: 2020 計理 Project tags: ToC, 2020 description: View the slide with "Slide Mode". --- # ToC Project 2020 slide: https://hackmd.io/@TTW/ToC-2019-Project# TAs: 陳彥儒、王麒淞 ---- # Goal Build a Line Bot with FSM ([SampleCode](https://github.com/NCKU-CCS/TOC-Project-2020)) ![](https://i.imgur.com/KIZVSN3.png) --- ## Outline - Requestments - Sample Code - 評分標準 - 教學文件 - 參考題材 - 注意事項 --- ## Requestments 1. Python ver. >= 3.6 2. Line Developer 3. 部署 - Heroku / AWS(加分項) Deadline: 2019/12/11 --- # 1.Python [python安裝教學](https://hackmd.io/@sky/local-pyenv) --- # 2.Line Bot ![](https://i.imgur.com/KIZVSN3.png) ---- 註冊網站:https://developers.line.biz/zh-hant/ ![](https://i.imgur.com/0CVqw8d.jpg) ---- 登入帳號 ![](https://i.imgur.com/5P41cDw.png) ---- 登入帳號 ![](https://i.imgur.com/cY7EMkA.png) ---- 選擇 Create New Provider 以建立 Bot ![](https://i.imgur.com/ISXIQH6.png) ---- 設定 Provider name ![](https://i.imgur.com/WfWfsp0.png) ---- Create ![](https://i.imgur.com/zndXrUT.png) ---- Messaging API > Create Channel ![](https://i.imgur.com/5eX5McA.png) ---- 上傳照片、填寫 APP 名稱、描述、信箱 ![](https://i.imgur.com/KebrkNG.png) 注意: APP 名稱註冊後 7 天內不能更改 ---- Done ![](https://i.imgur.com/9f5JPte.png) ---- 取得 secret ![](https://i.imgur.com/KjVzW7h.png) ---- 取得 access token ![](https://i.imgur.com/zCDKHna.png) --- # 3.部署 - Heroku ---- 註冊網站: https://signup.heroku.com/ ![](https://i.imgur.com/BWkjpIQ.png) 語言選 python ---- new APP ![](https://i.imgur.com/8FTZNTE.png) ---- new APP ![](https://i.imgur.com/e0rr6eQ.png) app-name 只能小寫 地區只能選美國或歐洲, 選哪個都行 ---- Get CLI ![](https://i.imgur.com/O32coOV.png) ---- Get CLI ![](https://i.imgur.com/aSPvLyW.png) ---- Get CLI ![](https://i.imgur.com/rjYODtH.png) ---- login CLI ![](https://i.imgur.com/9oEvsKQ.png) 在 terminal 輸入 `heroku login` 按下任意鍵會打開瀏覽器進行 login ---- login CLI ![](https://i.imgur.com/OPa9VEu.png) ---- login CLI ![](https://i.imgur.com/jiPY0cN.png) ---- login CLI ![](https://i.imgur.com/Tqi2Moj.png) ---- push to heroku (use git) ``` heroku git:remote -a {HEROKU_APP_NAME} git add . git commit -m "commint msg" git push -f heroku master ``` [git tutorial](https://backlog.com/git-tutorial/tw/intro/intro2_1.html) ---- 將 Heroku 與 Line 綁定 ![](https://i.imgur.com/IYFSSxi.png) URL = https://{HEROKU_APP_NAME}.herokuapp.com/{route} --- ## Sample Code ![](https://i.imgur.com/ztHSXnr.png) https://github.com/NCKU-CCS/TOC-Project-2020 ---- "go to state1" -> Triger state1 "go to state2" -> Triger state2 ![](https://i.imgur.com/WFJ0biX.png) ---- # 檔案結構 ![](https://i.imgur.com/07PMIjY.png) ---- ## 安裝套件 [ref](https://medium.com/@chihsuan/pipenv-%E6%9B%B4%E7%B0%A1%E5%96%AE-%E6%9B%B4%E5%BF%AB%E9%80%9F%E7%9A%84-python-%E5%A5%97%E4%BB%B6%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-135a47e504f4) `pip3 install -r requirements.txt` or `pipenv install --three` ---- /.env ![](https://i.imgur.com/uri183C.png) ---- /utils.py ![](https://i.imgur.com/z2OK21W.png) ---- /fsm.py ![](https://i.imgur.com/E9l5VBA.png) ---- Webhook event objects ```{ "destination": "xxxxxxxxxx", "events": [ { "replyToken": "0f3779fba3b349968c5d07db31eab56f", "type": "message", "timestamp": 1462629479859, "source": { "type": "user", "userId": "U4af4980629..." }, "message": { "id": "325708", "type": "text", "text": "Hello, world" } } ] } ``` ---- /app.py - fsm ![](https://i.imgur.com/wDNmONL.png) ---- /app.py - line setting ![](https://i.imgur.com/waKvErW.png) ---- /app.py - line bot route ![](https://i.imgur.com/WXsPeSM.png) ---- /app.py - print fsm ![](https://i.imgur.com/Et0R9wv.png) --- ### 評分方式 - 基本(60%) - 呈現(10%) - 功能性(10%) - 創意(10%) - 額外加分(5~10%) ---- 基本(60%) 1. FSM Diagram 2. Demo 運作正常 3. 最少兩個 states ---- 呈現(10%) - Doc - Demo 操作流暢度 - 講解 ---- 功能性(10%) - FSM 複雜度 (不是單看 states 多寡) - CRUD (Create, Read, Update, Delete) - Parsing ---- 創意(10%) - 主題, 產業, 時事 ---- 額外加分(4~10%) ``` 1. AWS (10%) AWS 教育版回報: https://forms.gle/vWMY1ZwVYbjHvw7S8 2. 增加功能 - 圖像, 影片 (4%) - 爬蟲 (火車時刻表, 新聞, 天氣...) (6%) - 連 DB (4%) - ML (8%) - BlockChain (8%) - ... ``` ---- 額外加分(4~10%) ``` 3. 用戶獨立的 state machine (10%) 讓每個連進 Bot 的用戶都有獨立的 machine, 而不是後加入的人會進到前面人目前的 state 並共用 machine 4. 多平台 (FB, IG, ...) (5%) ``` --- ### 繳交方式 1. 截止日期前將專案上傳至 GitHub 並設成 public 2. 在 Google 表單填入 repo 網址 3. Deadline : 12/11 12pm 4. 預約 DEMO 時間 (12/12-12/17) 表單:https://forms.gle/VL3NA65jYyXvKWC2A --- ### 去年範例 1. [網美ig](https://github.com/iknowright/messengerbot) [name=張財實] 100分 2. [圈圈叉叉](https://hackmd.io/@44WIexypT0qDttURuc98iA/S1GCfktbE?type=slide#/) [name=林郁翔] 99分 3. [女朋友解惑](https://github.com/ire33164/Girlfriend_chatbot) [name=林志嘉] 91分 --- ## 參考題材 [台灣事實查核中心](https://tfc-taiwan.org.tw/) [2020總統候選人知識時查核計畫](https://www.readr.tw/project/fact-check-2020?fbclid=IwAR067uvtENS6lwUoh-W3yQGCNiKvnZ3kriRuRriKBiwynv2eiKbbpPJt1OM) [Cofacts 真的假的](https://cofacts.g0v.tw/) --- ### 教學文件 - [Line Developer 註冊](/34brdrfLS92MpgTrECa5gg) - [LINE 開發環境](/ZOyAxFZcRBe8v4kcscb0zQ) - [Heroku](https://devcenter.heroku.com/articles/getting-started-with-python) - [LineBot + python + Heroku](https://yaoandy107.github.io/line-bot-tutorial/) - [ngrok](https://blog.techbridge.cc/2018/05/24/ngrok/) --- ## 注意事項 Heroku 太久沒用可能會休眠,請耐心等待 Line Reply Token 僅能使用一次 免費版 Line Bot 好友上限 50 人 ---- ### 如遇到問題想詢問,請 follow 以下格式 主旨:[Final Project] 簡述遇到的問題 ``` 內文: - 姓名學號: - 系統環境: - 系統版本: - 套件版本: - 在哪一個步驟遇到的問題: - 詳述問題: - 完整的錯誤訊息: - 已經試過的解決方法: - 在這個問題上已經花費的時間: ``` --- ## 參考資料 - [去年 FAQ](https://hackmd.io/@ccw/B1Xw7E8kN?type=view) ---

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully