iT邦幫忙

2025 iThome 鐵人賽

DAY 17
0
自我挑戰組

用 Discord Bot 玩轉 DevOps系列 第 17

Bot 背後的流程圖

  • 分享至 

  • xImage
  •  

今天要來簡單說明一下bot背後到底是怎麼運作的,並用一張圖來概括


1. 使用者輸入指令

【 Discord 頻道裡輸入 !last-commit 】
-> 這個指令會被 Discord 傳給 Bot(透過 Gateway)

2. Bot 接收事件

【 Bot 程式(寫在 Python)收到指令後,開始處理 】
-> ex : 判斷「指令是查 commit」

3. 呼叫 GitHub API

【 Bot 透過 HTTP 請求,帶著 Token(保存在 GitHub Secrets 裡),向 GitHub API 發出查詢 】

4. GitHub 回傳資料

【 GitHub API 以 JSON 格式回覆 】
-> ex :

  "commit": "abc123",
  "author": "nikki",
  "message": "fix bug"

5. Bot 整理訊息

【 Bot 把回傳的 JSON 抽取成一段可讀的文字 】

6. 回傳給 Discord

【 Bot 最後在頻道裡輸出 】
-> ex :

  ✅ 最近一次 commit:fix bug (by author)

流程圖示意

https://ithelp.ithome.com.tw/upload/images/20250930/20169329odngoad6cy.png


上一篇
介紹「GitHub API」
系列文
用 Discord Bot 玩轉 DevOps17
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言