Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信企业通知增加反向代理功能 #311

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dailycheckin/utils/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ def message2qywxrobot(qywx_key, content):


def message2qywxapp(
qywx_corpid, qywx_agentid, qywx_corpsecret, qywx_touser, qywx_media_id, content
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:
Expand Down Expand Up @@ -160,7 +163,7 @@ def message2qywxapp(
},
}
requests.post(
url=f"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}",
url=f"{bastUrl}/cgi-bin/message/send?access_token={token}",
data=json.dumps(data),
)
return
Expand Down Expand Up @@ -218,6 +221,7 @@ def push_message(content_list: list, notice_info: dict):
qywx_corpsecret = notice_info.get("qywx_corpsecret")
qywx_touser = notice_info.get("qywx_touser")
qywx_media_id = notice_info.get("qywx_media_id")
qywx_origin = notice_info.get("qywx_origin")
pushplus_token = notice_info.get("pushplus_token")
pushplus_topic = notice_info.get("pushplus_topic")
merge_push = notice_info.get("merge_push")
Expand Down Expand Up @@ -270,6 +274,7 @@ def push_message(content_list: list, notice_info: dict):
qywx_corpsecret=qywx_corpsecret,
qywx_touser=qywx_touser,
qywx_media_id=qywx_media_id,
qywx_origin=qywx_origin,
content=message,
)
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions docker/config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"QYWX_KEY":"",
"QYWX_MEDIA_ID":"",
"QYWX_TOUSER":"",
"QYWX_ORIGIN":"",
"SCKEY":"",
"SENDKEY":"",
"TG_API_HOST":"",
Expand Down
1 change: 1 addition & 0 deletions docs/pages/settings/notify/qywx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ import { Cards, Card } from 'nextra/components'
| _**QYWX_CORPSECRET**_ | corpsecret |
| _**QYWX_TOUSER**_ | touser |
| _**QYWX_MEDIA_ID**_ | media_id |
| _**QYWX_ORIGIN**_ | 企业微信反向代理地址 https://qyapi.weixin.qq.com/cgi-bin/gettoken将其中的https://qyapi.weixin.qq.com替换为**QYWX_ORIGIN** |
| _**MERGE_PUSH**_ | **true**: 将推送消息合并;**false**: 分开推送 |