From 4cc754f14447ff429c4929266bc8b7f46144319a Mon Sep 17 00:00:00 2001 From: yixiu Date: Wed, 17 Jul 2024 15:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=9A=E6=97=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=81=A2=E5=A4=8Dvless=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cv.yml | 8 ++++---- test.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cv.yml b/.github/workflows/cv.yml index d816a02..4508809 100644 --- a/.github/workflows/cv.yml +++ b/.github/workflows/cv.yml @@ -1,4 +1,4 @@ -name: 测试 +name: 恢复vless服务并发送Telegram消息 on: schedule: @@ -6,7 +6,7 @@ on: workflow_dispatch: jobs: - restore: + restore_and_notify: runs-on: ubuntu-latest steps: @@ -21,7 +21,7 @@ jobs: - name: 安装依赖 run: | python -m pip install --upgrade pip - pip install -r requirements.txt # 如果有依赖文件,请替换为实际的文件名 + pip install requests # 只需安装需要的依赖,此处假设使用 requests 发送 HTTP 请求 - name: 执行Python脚本恢复vless服务并发送Telegram消息 env: @@ -29,5 +29,5 @@ jobs: TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} run: | - python test.py + python3 test.py # 替换为您的 Python 脚本文件名 diff --git a/test.py b/test.py index a367a8e..d887584 100644 --- a/test.py +++ b/test.py @@ -1,6 +1,7 @@ import os import json import subprocess +import requests # 从环境变量中获取密钥 accounts_json = os.getenv('ACCOUNTS_JSON') @@ -38,9 +39,9 @@ "parse_mode": "Markdown", "reply_markup": '{"inline_keyboard":[[{"text":"问题反馈❓","url":"https://t.me/yxjsjl"}]]}' } -response = subprocess.run(["curl", "-s", "-X", "POST", telegram_url, "-d", json.dumps(telegram_payload)]) +response = requests.post(telegram_url, json=telegram_payload) -if response.returncode != 0: +if response.status_code != 200: print("发送 Telegram 消息失败") else: print("发送 Telegram 消息成功")