From 66ab88af9c0fec2110d106d10c692b249385e3c1 Mon Sep 17 00:00:00 2001 From: Shadownc <365172043@qq.com> Date: Tue, 8 Oct 2024 07:20:20 +0000 Subject: [PATCH] =?UTF-8?q?Server=E9=85=B1=E6=8E=A8=E9=80=81=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E5=8F=AF=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/follow.yml | 1 + .github/workflows/webp-cloud.yml | 1 + README.md | 1 + utils/serve_chan_notify.py | 12 +++++++----- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/follow.yml b/.github/workflows/follow.yml index 6b54da5..c463143 100644 --- a/.github/workflows/follow.yml +++ b/.github/workflows/follow.yml @@ -34,6 +34,7 @@ jobs: FOLLOW_COOKIE: ${{ secrets.FOLLOW_COOKIE }} WEBHOOK_KEY: ${{ secrets.WEBHOOK_KEY }} SERVER_CHAN_KEY: ${{ secrets.SERVER_CHAN_KEY }} + SERVER_CHAN_CHANNEL: ${{secrets.SERVER_CHAN_CHANNEL}} QMSG_KEY: ${{ secrets.QMSG_KEY }} run: | python scripts/follow.py diff --git a/.github/workflows/webp-cloud.yml b/.github/workflows/webp-cloud.yml index 7620998..eced80f 100644 --- a/.github/workflows/webp-cloud.yml +++ b/.github/workflows/webp-cloud.yml @@ -32,6 +32,7 @@ jobs: WEBPCLOUD_TOKEN: ${{ secrets.WEBPCLOUD_TOKEN }} WEBHOOK_KEY: ${{ secrets.WEBHOOK_KEY }} SERVER_CHAN_KEY: ${{ secrets.SERVER_CHAN_KEY }} + SERVER_CHAN_CHANNEL: ${{secrets.SERVER_CHAN_CHANNEL}} QMSG_KEY: ${{ secrets.QMSG_KEY }} run: | python scripts/webpCloud.py diff --git a/README.md b/README.md index 4f7d514..0708223 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ **配置步骤:** 1. 前往 `GitHub` 仓库的 `Settings` > `Secrets and variables` > `Actions`。 2. 添加名称为 `SERVER_CHAN_KEY` 的新 `secret`,并将管理后台的`key` 作为值输入。 +3. 添加名称为`SERVER_CHAN_CHANNEL` 不设置则为默认推送渠道 具体值详见文档。 ### **Qmsg酱消息推送** [文档地址](https://qmsg.zendee.cn/) diff --git a/utils/serve_chan_notify.py b/utils/serve_chan_notify.py index d1869ed..480457b 100644 --- a/utils/serve_chan_notify.py +++ b/utils/serve_chan_notify.py @@ -7,27 +7,29 @@ def send_server_chan_notification(title, desp): server_chan_key = os.getenv('SERVER_CHAN_KEY') + channel = os.getenv('SERVER_CHAN_CHANNEL', '9') # 从环境变量读取channel 默认为9 # 检查 server_chan_key 是否为 None 或空字符串 if not server_chan_key: print("⚠️ SERVER_CHAN_KEY 未设置 请设置后重试!") return + + data = { + 'title': title, + 'desp': desp + } # 根据 server_chan_key 的前缀决定使用不同的推送URL if server_chan_key.startswith('sctp'): server_chan_url = f'https://{server_chan_key}.push.ft07.com/send' else: server_chan_url = f'https://sctapi.ftqq.com/{server_chan_key}.send' + data['channel'] = channel # 推送通道 默认9 headers = { 'Content-Type': 'application/json;charset=utf-8' } - data = { - 'title': title, - 'desp': desp - } - try: response = requests.post(server_chan_url, json=data, headers=headers) response.raise_for_status()