Vic
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
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
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    # Line Assistant Bot:Line多功能機器人 ###### tags: `Side Project` `python` ## Introduction - 前言 為了使我們的生活更加方便,我決定開發一個多功能機器人,類似於個人助理,能夠在某些時候節省我們許多時間去翻閱、處理資訊。 ## Process 過程 常常在緊急的時候需要查資料,但是卻因為繁雜的手續(搜尋、翻閱、尋找自己需要的資料)而拖延了許多時間,因此我希望透過自己的雙手實作一個類似於個人助理的機器人,在某些緊要關頭能夠幫助到我們,平時也可以透過這個機器人整理排序資料,獲得自己所需。 於是我便於2023/3/30開始了我的第一個小專題,我對這個主題有幾大原則: * **具擴充性** - 能夠擴充功能,給予無限可能 * **具公開性** - 能夠使好友們也使用這個功能 * **方便迅速** - 本次專題的首要目標 經過評估後,我決定在LINE上面進行架設,製作一個能滿足我需求的LINE-BOT,俗話說的好:「**人類會進步源自於需求。**」 本次專題架構圖: ![](https://i.imgur.com/pLep6st.png) 圖片來自於:[LEARN CODE WITH MIKE](https://www.learncodewithmike.com/2020/06/python-line-bot.html) 本次專題前期都依賴著MIKE的網站完成,非常感謝他的無私奉獻他所擁有的知識。 本次專題機器人邏輯判斷所使用的語言為Python,透過LineBotApi進行傳送資料、錯誤判斷,伺服器方面則是使用Django框架進行建置。 若對架設有興趣,可以參考MIKE的[教學網站。](https://www.learncodewithmike.com/2020/06/python-line-bot.html) 由於是首次製作專案(雖然連大型都稱不上),對於專案、程式撰寫架構也很不熟,Python更是這幾天才在學...,因此過程中充滿了艱辛,日誌上看的出來,每天都在優化架構,不斷思考才能讓自己的程式碼看起來簡潔。從把程式碼全部寫在一個檔案,到後面學習了寫成多檔案、OOP的概念,將專題整個打散,化零為整,使其具**擴充性、可讀性**。 這中間也是下了很多功夫...,尤其是 Class 四大方法,看了許多遍才能實際運用在自己的作品上,一路上也是使自己不斷成長,看著自己的機器人越來越厲害,挺有成就感的XD(好像怪怪的...)。 ## Function - 功能 程式碼已開源在 [GitHub](https://github.com/vicwen0418/Line-Assistant-Bot) 上,我是小白,不要電我嗚嗚QQ 截至於目前(2023/04/05),已具備四種功能,並預留兩個位置未來實現。 四種功能分別為: * 美食推薦 * 景點推薦 * 天氣預覽 * AI對話 ![](https://i.imgur.com/RnggHdJ.jpg =400x750) 透過圖文選單(rich-menu)一目瞭然的功能列表,只需用手指輕觸即可獲取資訊,少掉了打開瀏覽器、輸入文字、尋找可用資料的冗長過程。 功能所獲取的資料皆是使用爬蟲(BeautifulSoup)實現。 選擇縣市的按鈕面板則是使用line-models API裡的CarouselTemplate實現。 AI架構則是使用GPT-3.5實現 未來會持續更新,使其完整。 ## Instruction - 成果 #### 2023/3/30 - 初始框架 雖然非常簡陋,但是萬事起頭難,有了開頭,後面都不算難了!此時的功能只有重複你所說的話而已。 ![](https://i.imgur.com/Dca8SyM.png =400x500) #### 2023/3/31 - 新增各縣市美食推薦。 ![](https://i.imgur.com/m1vw2aq.png =400x600) #### 2023/04/01 - 新增各縣市景點推薦。 ![](https://i.imgur.com/X0jmpzQ.png =400x700) #### 2023/04/02 - 新增各縣市氣象預報。 ![](https://i.imgur.com/DRZp1gx.png =400x500) #### 2023/04/03 - 新增縣市選擇面板,增加方便性。 ![](https://i.imgur.com/mOXywVL.png =400x700) #### 2023/04/05 - 新增圖文選單、AI對話。 ![](https://i.imgur.com/0l6XtJG.jpg =400x800) ## epilogue - 結語 由於本專題具擴充性,因此仍會持續更新,如同我的學習之路一樣,永不中斷。 若你對於我的作品有甚麼想法,可以聯繫我~ > [name=Vic] 2023/08/30 - 由於伺服器經費問題,將此專案暫停更新及結束。 ## Platform & Else - 平台和雜項 * 撰寫平台 - Visual Studio Code * 撰寫語言 - Python * 伺服器框架 - django * AI框架 - GPT-3.5 * 架設平台 - LINE * API名稱 - linebotapi, line.models, requests, beautifulSoup, openai ## Log - 更新日誌 | 日期 | 內容 | | -------- | -------- | | 2023/03/29 | 初步架設 | | 2023/03/31 | 新增功能(美食餐廳、旅遊景點) - 待優化 | | 2023/04/02 | 新增功能(縣市天氣報告)、優化架構 | | 2023/04/03 | 更改表達方式(改為CarouselTemplate選擇縣市)、優化架構 | | 2023/04/04 | 新增縣市、修改bug、優化架構 | | 2023/04/05 | 新增圖文選單(rich-menu)、新增OpenAI功能、隔離使用者、優化架構 | ## Reference - 參考資料 1. [LINE Developers](https://developers.line.biz/zh-hant/) 2. [LINE Official Account Manager](https://manager.line.biz/) 3. [[Python+LINE Bot教學]6步驟快速上手LINE Bot機器人](https://www.learncodewithmike.com/2020/06/python-line-bot.html) 4. [[Python+LINE Bot教學]提升使用者體驗的按鈕樣板訊息(Buttons template message)實用技巧](https://www.learncodewithmike.com/2020/07/line-bot-buttons-template-message.html) 5. [[Python物件導向]Python封裝(Encapsulation)實用教學](https://www.learncodewithmike.com/2020/01/python-encapsulation.html) 6. [[Python教學] 物件導向-Class類的封裝/繼承/多型](https://www.maxlist.xyz/2019/12/12/python-oop/) 7. [關於Python的類別(Class)...基本篇](https://weilihmen.medium.com/%E9%97%9C%E6%96%BCpython%E7%9A%84%E9%A1%9E%E5%88%A5-class-%E5%9F%BA%E6%9C%AC%E7%AF%87-5468812c58f2) 8. [[Python物件導向]解析Python物件導向設計的3種類型方法(Instance,Class,Static Method)](https://www.learncodewithmike.com/2020/01/python-method.html) 9. [Python進階技巧 (2) — Static/Class/Abstract Methods之實現](https://medium.com/citycoddee/python%E9%80%B2%E9%9A%8E%E6%8A%80%E5%B7%A7-2-static-class-abstract-methods%E4%B9%8B%E5%AF%A6%E7%8F%BE-1e3b3998bccf) 10. [[Python教學] Class / Static /Abstract Method 初探](https://www.maxlist.xyz/2019/12/08/python-class-static-abstract-method/) 11. [使用 OpenAI ChatGPT](https://steam.oxxostudio.tw/category/python/example/openai.html)

    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