今天要來簡單說明一下bot背後到底是怎麼運作的,並用一張圖來概括
【 Discord 頻道裡輸入 !last-commit 】
-> 這個指令會被 Discord 傳給 Bot(透過 Gateway)
【 Bot 程式(寫在 Python)收到指令後,開始處理 】
-> ex : 判斷「指令是查 commit」
【 Bot 透過 HTTP 請求,帶著 Token(保存在 GitHub Secrets 裡),向 GitHub API 發出查詢 】
【 GitHub API 以 JSON 格式回覆 】
-> ex :
"commit": "abc123",
"author": "nikki",
"message": "fix bug"
【 Bot 把回傳的 JSON 抽取成一段可讀的文字 】
【 Bot 最後在頻道裡輸出 】
-> ex :
✅ 最近一次 commit:fix bug (by author)
流程圖示意