From d3a7ae2de90d00bc50781853fd60f4a5ae48e288 Mon Sep 17 00:00:00 2001 From: Evan Lin Date: Fri, 12 Jan 2024 21:44:18 +0800 Subject: [PATCH] chore: refactor GitHub action names and remove unused files - Change the name of the GitHub action from "Deploy" to "Heroku Deploy" - Delete the file "render_deploy.yml" from the GitHub workflows - Modify the "README.md" file by removing two image tags - Modify the "bot.go" file by adding a condition for the "card_prompt" variable - Modify the "main.go" file by adding the "ChannelSecret" variable Signed-off-by: Evan Lin --- .github/workflows/heroku.yml | 2 +- .github/workflows/render_deploy.yml | 16 ---------------- README.md | 7 ------- bot.go | 6 ++++-- main.go | 2 ++ 5 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/render_deploy.yml diff --git a/.github/workflows/heroku.yml b/.github/workflows/heroku.yml index 10bf6dd..bb9635a 100644 --- a/.github/workflows/heroku.yml +++ b/.github/workflows/heroku.yml @@ -1,4 +1,4 @@ -name: Deploy +name: Heroku Deploy on: release: diff --git a/.github/workflows/render_deploy.yml b/.github/workflows/render_deploy.yml deleted file mode 100644 index d40f389..0000000 --- a/.github/workflows/render_deploy.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: My Deploy - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Deploy to production - uses: johnbeynon/render-deploy-action@v0.0.8 - with: - service-id: ${{ secrets.MY_RENDER_SERVICE_ID }} - api-key: ${{ secrets.MY_RENDER_API_KEY }} - wait-for-success: true \ No newline at end of file diff --git a/README.md b/README.md index 1bc9245..46e08f9 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,8 @@ LINE Bot 使用 Google Gemini Pro 來做的名片小幫手 [![GoDoc](https://godoc.org/github.com/kkdai/linebot-gemini-pro.svg?status.svg)](https://godoc.org/github.com/kkdai/LineBotTemplate) ![Go](https://github.com/kkdai/linebot-gemini-pro/workflows/Go/badge.svg) [![goreportcard.com](https://goreportcard.com/badge/github.com/kkdai/linebot-gemini-pro)](https://goreportcard.com/report/github.com/kkdai/linebot-gemini-pro) - - # LINE Bot Screen - - ## 如何快速架設在自己平台 請根據以下的流程,來直接透過開源的程式碼來架設一個 LINEBot 跟 GCP STT 與 GCS (Google Cloud Storage) 的結合。 @@ -31,9 +27,6 @@ LINE Bot 使用 Google Gemini Pro 來做的名片小幫手 2.1. 按下: [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 來部署到你的 Heroku 帳號 - 2.2 按下: [![Deploy to Render](http://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy) - 來部署到你的 Render 帳號 - 3. 除了填寫 App Name 以外,以下的參數必須要填入才能完整運行。 1. **ChannelAccessToken**: 請到 LINE Developers Console issue 一個。 diff --git a/bot.go b/bot.go index 0067b7b..5abf2bd 100644 --- a/bot.go +++ b/bot.go @@ -34,9 +34,11 @@ func replyText(replyToken, text string) error { // callbackHandler: Handle callback from LINE server. func callbackHandler(w http.ResponseWriter, r *http.Request) { card_prompt := os.Getenv("CARD_PROMPT") - channelToken = os.Getenv("ChannelAccessToken") + if card_prompt == "" { + card_prompt = ImagePrompt + } - cb, err := webhook.ParseRequest(os.Getenv("ChannelSecret"), r) + cb, err := webhook.ParseRequest(ChannelSecret, r) if err != nil { if err == linebot.ErrInvalidSignature { w.WriteHeader(400) diff --git a/main.go b/main.go index e81bbae..247c4cb 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ import ( var bucketName string var geminiKey string var channelToken string +var ChannelSecret string var bot *messaging_api.MessagingApiAPI var blob *messaging_api.MessagingApiBlobAPI @@ -32,6 +33,7 @@ func main() { var err error geminiKey = os.Getenv("GOOGLE_GEMINI_API_KEY") channelToken = os.Getenv("ChannelAccessToken") + ChannelSecret = os.Getenv("ChannelSecret") bot, err = messaging_api.NewMessagingApiAPI(channelToken) if err != nil {