Skip to content

Commit

Permalink
新增定时处理恢复vless服务
Browse files Browse the repository at this point in the history
  • Loading branch information
yixiu001 committed Jul 17, 2024
1 parent 240a0a3 commit 4cc754f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cv.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: 测试
name: 恢复vless服务并发送Telegram消息

on:
schedule:
- cron: '*/20 * * * *' # 每20分钟执行一次
workflow_dispatch:

jobs:
restore:
restore_and_notify:
runs-on: ubuntu-latest

steps:
Expand All @@ -21,13 +21,13 @@ jobs:
- name: 安装依赖
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt # 如果有依赖文件,请替换为实际的文件名
pip install requests # 只需安装需要的依赖,此处假设使用 requests 发送 HTTP 请求
- name: 执行Python脚本恢复vless服务并发送Telegram消息
env:
ACCOUNTS_JSON: ${{ secrets.ACCOUNTS_JSON }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
run: |
python test.py
python3 test.py # 替换为您的 Python 脚本文件名
5 changes: 3 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import subprocess
import requests

# 从环境变量中获取密钥
accounts_json = os.getenv('ACCOUNTS_JSON')
Expand Down Expand Up @@ -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 消息成功")

0 comments on commit 4cc754f

Please sign in to comment.