From 691bd894941bd2b34168327b31aa87d014c260fd Mon Sep 17 00:00:00 2001 From: hanyabo Date: Thu, 7 Mar 2024 16:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8F=8D=E5=90=91=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=8F=82=E6=95=B0=E8=AF=B4=E6=98=8E=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dailycheckin/utils/message.py | 19 ++++++++----------- docs/pages/settings/notify/qywx.mdx | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/dailycheckin/utils/message.py b/dailycheckin/utils/message.py index 62cb79c..3909f0c 100755 --- a/dailycheckin/utils/message.py +++ b/dailycheckin/utils/message.py @@ -125,8 +125,11 @@ def message2qywxapp( qywx_corpid, qywx_agentid, qywx_corpsecret, qywx_touser, qywx_media_id, qywx_origin, content ): print("企业微信应用消息推送开始") + bastUrl = "https://qyapi.weixin.qq.com" + if qywx_origin: + bastUrl = qywx_origin; res = requests.get( - f"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={qywx_corpid}&corpsecret={qywx_corpsecret}" + f"{bastUrl}/cgi-bin/gettoken?corpid={qywx_corpid}&corpsecret={qywx_corpsecret}" ) token = res.json().get("access_token", False) if qywx_media_id: @@ -159,16 +162,10 @@ def message2qywxapp( "btntxt": "开源项目", }, } - if qywx_origin: - requests.post( - url=f"{qywx_origin}/cgi-bin/message/send?access_token={token}", - data=json.dumps(data), - ) - else: - requests.post( - url=f"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}", - data=json.dumps(data), - ) + requests.post( + url=f"{bastUrl}/cgi-bin/message/send?access_token={token}", + data=json.dumps(data), + ) return diff --git a/docs/pages/settings/notify/qywx.mdx b/docs/pages/settings/notify/qywx.mdx index 96812ec..1620a72 100644 --- a/docs/pages/settings/notify/qywx.mdx +++ b/docs/pages/settings/notify/qywx.mdx @@ -70,5 +70,5 @@ import { Cards, Card } from 'nextra/components' | _**QYWX_CORPSECRET**_ | corpsecret | | _**QYWX_TOUSER**_ | touser | | _**QYWX_MEDIA_ID**_ | media_id | -| _**QYWX_ORIGIN**_ | 企业微信反向代理地址 | +| _**QYWX_ORIGIN**_ | 企业微信反向代理地址 https://qyapi.weixin.qq.com/cgi-bin/gettoken将其中的https://qyapi.weixin.qq.com替换为**QYWX_ORIGIN** | | _**MERGE_PUSH**_ | **true**: 将推送消息合并;**false**: 分开推送 |