From b0f1183a9cc6e424ca47b03c32c0bf27b55d1980 Mon Sep 17 00:00:00 2001 From: lun3322 Date: Fri, 19 Feb 2021 11:22:23 +0800 Subject: [PATCH 1/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 443c1f02..ffe863ea 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,5 @@ first push + 2020-12-12 修复如果没有填写`SERVERCHAN_SECRETKEY`,会在正常签到后报错的问题。 -现在没有`SERVERCHAN_SECRETKEY`也可以正常签到并不报错。 \ No newline at end of file +现在没有`SERVERCHAN_SECRETKEY`也可以正常签到并不报错。 + From e3aef04287db251144e6f3fd70f9dcc5869a6712 Mon Sep 17 00:00:00 2001 From: hong Date: Sun, 21 Feb 2021 16:12:40 +0800 Subject: [PATCH 2/5] update ServerChan to Turbo version --- utils/serverchan_push.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/serverchan_push.py b/utils/serverchan_push.py index cd25c7d0..964181df 100644 --- a/utils/serverchan_push.py +++ b/utils/serverchan_push.py @@ -11,7 +11,7 @@ def push_to_wechat(text,desp,secretKey): :param desp: 内容 :return resp: json """ - url = f'http://sc.ftqq.com/{secretKey}.send' + url = f'http://sctapi.ftqq.com/{secretKey}.send' session = requests.Session() data = {'text':text,'desp':desp} resp = session.post(url,data = data) From 64ff3a12579bfcf470c0ee57a53655bea10788d6 Mon Sep 17 00:00:00 2001 From: lun3322 Date: Wed, 23 Jun 2021 09:23:56 +0800 Subject: [PATCH 3/5] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ffe863ea..ea0ef4d6 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,3 @@ first push + 2020-12-12 修复如果没有填写`SERVERCHAN_SECRETKEY`,会在正常签到后报错的问题。 现在没有`SERVERCHAN_SECRETKEY`也可以正常签到并不报错。 - From 76d9960ab73bd217817c2c67911a48f39db5a5cb Mon Sep 17 00:00:00 2001 From: lun3322 Date: Wed, 23 Jun 2021 09:26:13 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ea0ef4d6..ffe863ea 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,4 @@ first push + 2020-12-12 修复如果没有填写`SERVERCHAN_SECRETKEY`,会在正常签到后报错的问题。 现在没有`SERVERCHAN_SECRETKEY`也可以正常签到并不报错。 + From b45bfc4252aacae1b59269d283839876d965f4b3 Mon Sep 17 00:00:00 2001 From: hong Date: Mon, 5 Jul 2021 11:21:06 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 ++ main.py | 11 ++++++----- utils/serverchan_push.py | 32 +++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 162a70fd..9d7639f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,4 +38,6 @@ jobs: env: COOKIES: ${{ secrets.SMZDM_COOKIE }} SERVERCHAN_SECRETKEY: ${{ secrets.SERVERCHAN_SECRETKEY }} + WX_PUSHER: ${{ secrets.WX_PUSHER }} + WX_PUSHER_UID: ${{ secrets.WX_PUSHER_UID }} run: python main.py #>SMZDM_Bot.log \ No newline at end of file diff --git a/main.py b/main.py index 538f39b5..e31c13a5 100644 --- a/main.py +++ b/main.py @@ -56,11 +56,12 @@ def checkin(self): sb.load_cookie_str(cookies) res = sb.checkin() print(res) - SERVERCHAN_SECRETKEY = os.environ["SERVERCHAN_SECRETKEY"] - print('sc_key: ', SERVERCHAN_SECRETKEY) - if isinstance(SERVERCHAN_SECRETKEY,str) and len(SERVERCHAN_SECRETKEY)>0: - print('检测到 SCKEY, 准备推送') + WX_PUSHER_UID = os.environ["WX_PUSHER_UID"] + WX_PUSHER = os.environ["WX_PUSHER"] + if isinstance(WX_PUSHER,str) and len(WX_PUSHER)>0: + print('检测到 WX_PUSHER 准备推送') push_to_wechat(text = '什么值得买每日签到', desp = str(res), - secretKey = SERVERCHAN_SECRETKEY) + appToken=WX_PUSHER, + uid=WX_PUSHER_UID) print('代码完毕') \ No newline at end of file diff --git a/utils/serverchan_push.py b/utils/serverchan_push.py index 964181df..12a36dae 100644 --- a/utils/serverchan_push.py +++ b/utils/serverchan_push.py @@ -3,21 +3,31 @@ import requests -def push_to_wechat(text,desp,secretKey): +def push_to_wechat(text, desp, appToken, uid): """ - 通过serverchan将消息推送到微信 - :param secretKey: severchan secretKey - :param text: 标题 - :param desp: 内容 - :return resp: json + 通过wxpusher将消息推送到微信 """ - url = f'http://sctapi.ftqq.com/{secretKey}.send' + url = f'http://wxpusher.zjiecode.com/api/send/message' session = requests.Session() - data = {'text':text,'desp':desp} - resp = session.post(url,data = data) + data = { + "appToken": appToken, + "content": desp, + "summary": text, + "contentType": 1, + "topicIds": [], + "uids": [ + uid + ], + } + headers = { + 'Content-Type': 'application/json' + } + resp = session.post(url, json=data, headers=headers) return resp.json() if __name__ == '__main__': - resp = push_to_wechat(text = 'test', desp='hi', secretKey= config.SERVERCHAN_SECRETKEY) - print(resp) \ No newline at end of file + resp = push_to_wechat(text='test', desp='hi', + appToken='', + uid='') + print(resp)