From cc6eaf43ba4c9b27702da152054cbbb1f18e7d7c Mon Sep 17 00:00:00 2001 From: CharlieAlex <42445052+CharlieAlex@users.noreply.github.com> Date: Thu, 23 May 2024 21:45:24 +0800 Subject: [PATCH] automate command again 6 --- .github/workflows/get_prediction.yml | 85 ++++++++++++++++++++++++++++ .github/workflows/get_result.yml | 73 ++++++++++++++++++++++++ .github/workflows/send_line.yml | 72 ----------------------- 3 files changed, 158 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/get_prediction.yml create mode 100644 .github/workflows/get_result.yml delete mode 100644 .github/workflows/send_line.yml diff --git a/.github/workflows/get_prediction.yml b/.github/workflows/get_prediction.yml new file mode 100644 index 0000000..1a5897f --- /dev/null +++ b/.github/workflows/get_prediction.yml @@ -0,0 +1,85 @@ +name: Get Prediction + +on: + schedule: + - cron: "03 16 * * *" + +jobs: + send-message: + runs-on: ubuntu-latest + + steps: + - name: Send message to LINE + env: + LINE_ACCESS_TOKEN: ${{ secrets.LINE_CHANNEL_ACCESS_TOKEN }} + LINE_USER_ID: ${{ secrets.LINE_USER_ID }} + run: | + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"喚醒 Line 機器人" + } + ] + }' + + sleep 300 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"NBA thismonth 30" + }, + { + "type":"text", + "text":"NBA lastmonth 30" + } + ] + }' + + sleep 60 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"NHL冰球 thismonth 30" + }, + { + "type":"text", + "text":"NHL冰球 lastmonth 30" + } + ] + }' + + sleep 60 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"MLB thismonth 30" + }, + { + "type":"text", + "text":"MLB lastmonth 30" + } + ] + }' diff --git a/.github/workflows/get_result.yml b/.github/workflows/get_result.yml new file mode 100644 index 0000000..56ef89b --- /dev/null +++ b/.github/workflows/get_result.yml @@ -0,0 +1,73 @@ +name: Get Result + +on: + schedule: + - cron: "46 13 * * *" + +jobs: + send-message: + runs-on: ubuntu-latest + + steps: + - name: Send message to LINE + env: + LINE_ACCESS_TOKEN: ${{ secrets.LINE_CHANNEL_ACCESS_TOKEN }} + LINE_USER_ID: ${{ secrets.LINE_USER_ID }} + run: | + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"喚醒 Line 機器人" + } + ] + }' + + sleep 300 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"NBA yesterday 20" + } + ] + }' + + sleep 60 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"NHL冰球 yesterday 20" + } + ] + }' + + sleep 60 + + curl -X POST https://api.line.me/v2/bot/message/push \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ + -d '{ + "to": "'$LINE_USER_ID'", + "messages":[ + { + "type":"text", + "text":"MLB yesterday 20" + } + ] + }' diff --git a/.github/workflows/send_line.yml b/.github/workflows/send_line.yml deleted file mode 100644 index 43d3695..0000000 --- a/.github/workflows/send_line.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Send LINE Messages - -on: - schedule: - - cron: "03 16 * * *" - - cron: "08 16 * * *" - - cron: "09 16 * * *" - - cron: "10 16 * * *" - - cron: "11 16 * * *" - - cron: "13 16 * * *" - - cron: "14 16 * * *" - - cron: "00 01 * * *" - - cron: "05 01 * * *" - - cron: "06 01 * * *" - - cron: "07 01 * * *" - - cron: "09 13 * * *" # 每天台北時間 21:00 觸發 - -jobs: - send-message: - runs-on: ubuntu-latest - - steps: - - name: Determine message - id: set-message - run: | - TIME=$(date +'%H:%M') - if [ "$TIME" == "16:03" ]; then - echo "MESSAGE=NBA thismonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:08" ]; then - echo "MESSAGE=NBA lastmonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:09" ]; then - echo "MESSAGE=NBA thismonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:10" ]; then - echo "MESSAGE=NHL冰球 thismonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:11" ]; then - echo "MESSAGE=NHL冰球 lastmonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:13" ]; then - echo "MESSAGE=MLB lastmonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "16:14" ]; then - echo "MESSAGE=MLB thismonth 30" >> $GITHUB_ENV - elif [ "$TIME" == "01:00" ]; then - echo "MESSAGE=NBA yesterday 20" >> $GITHUB_ENV - elif [ "$TIME" == "01:05" ]; then - echo "MESSAGE=NBA yesterday 20" >> $GITHUB_ENV - elif [ "$TIME" == "01:06" ]; then - echo "MESSAGE=NHL冰球 yesterday 10" >> $GITHUB_ENV - elif [ "$TIME" == "01:07" ]; then - echo "MESSAGE=MLB yesterday 15" >> $GITHUB_ENV - elif [ "$TIME" == "13:09" ]; then - echo "MESSAGE=台北時間 21:00 消息" >> $GITHUB_ENV - else - echo "MESSAGE=Current time is $TIME" >> $GITHUB_ENV - fi - - - name: Send message to LINE - env: - LINE_ACCESS_TOKEN: ${{ secrets.LINE_CHANNEL_ACCESS_TOKEN }} - LINE_USER_ID: ${{ secrets.LINE_USER_ID }} - MESSAGE: ${{ env.MESSAGE }} - run: | - curl -X POST https://api.line.me/v2/bot/message/push \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $LINE_ACCESS_TOKEN" \ - -d '{ - "to": "'$LINE_USER_ID'", - "messages":[ - { - "type":"text", - "text":"'"$MESSAGE"'" - } - ] - }'