From 5625abc8fb702aa0ff6a045809ab0581fca83d41 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 8 Jun 2022 17:03:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Github=20Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/python beta.yml | 34 ------------------------------- .github/workflows/python.yml | 10 ++++----- telegram_update.py | 8 ++++---- telegram_update_beta.py | 22 -------------------- 4 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/python beta.yml delete mode 100644 telegram_update_beta.py diff --git a/.github/workflows/python beta.yml b/.github/workflows/python beta.yml deleted file mode 100644 index 4cd66a5..0000000 --- a/.github/workflows/python beta.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Github Beta commit to telegram - -on: - push: - branches: - - beta - -jobs: - build: - runs-on: ubuntu-latest - steps: - # 此步骤使用 GitHub 的 https://github.com/actions/checkout - - name: checkout actions - uses: actions/checkout@v1 - - # 设置python环境 - # 此步骤使用 GitHub 的 https://github.com/actions/setup-python - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - # 安装依赖 - - name: Install dependencies - run: | - mkdir tmp && cd tmp - python -m pip install --upgrade pip - pip install requests - # 发送通知 - - name: Send notice - run: | - cd tmp - cp ../telegram_update_beta.py ./ - python telegram_update_beta.py ${{ secrets.TG_BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6f7f6ca..9a259b6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -11,21 +11,21 @@ jobs: steps: # 此步骤使用 GitHub 的 https://github.com/actions/checkout - name: checkout actions - uses: actions/checkout@v1 + uses: actions/checkout@v3 # 设置python环境 # 此步骤使用 GitHub 的 https://github.com/actions/setup-python - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 with: - python-version: 3.7 + python-version: 3.9 # 安装依赖 - name: Install dependencies run: | mkdir tmp && cd tmp python -m pip install --upgrade pip - pip install requests + pip install httpx # 发送通知 - name: Send notice diff --git a/telegram_update.py b/telegram_update.py index ad93e65..3877a6b 100644 --- a/telegram_update.py +++ b/telegram_update.py @@ -1,10 +1,10 @@ import json, time, sys -from requests import get, post +from httpx import get, post token = str(sys.argv[1]) -main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/master").content) +main = json.loads(get("https://api.github.com/repos/TeamPGM/PagerMaid_Plugins/commits/master").content) text = "#更新日志 #" + main['commit']['author']['name'].replace('_', '') + \ - ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \ + ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/TeamPGM/PagerMaid_Plugins/commit/' + \ main['sha'] + '): ' + main['commit']['message'] push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown', 'text': text} @@ -16,7 +16,7 @@ except: push_content['chat_id'] = '-1001319957857' time.sleep(1) try: - main_req = get(url, data=push_content) + main_req = post(url, data=push_content) except: pass print(main['sha'] + " ok!") diff --git a/telegram_update_beta.py b/telegram_update_beta.py deleted file mode 100644 index 63dd87a..0000000 --- a/telegram_update_beta.py +++ /dev/null @@ -1,22 +0,0 @@ -import json, time, sys -from requests import get, post - -token = str(sys.argv[1]) -main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/beta").content) -text = "#更新日志 #beta #" + main['commit']['author']['name'].replace('_', '') + \ - ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \ - main['sha'] + '): ' + main['commit']['message'] -push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown', - 'text': text} -url = 'https://api.telegram.org/bot' + token + '/sendMessage' -try: - main_req = post(url, data=push_content) -except: - pass -push_content['chat_id'] = '-1001319957857' -time.sleep(1) -try: - main_req = get(url, data=push_content) -except: - pass -print(main['sha'] + " ok!")