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

This commit is contained in:
hanyabo 2024-03-06 14:31:45 +08:00
parent 67416d1f9a
commit 95fef73ce1
2 changed files with 14 additions and 5 deletions

View File

@ -122,7 +122,7 @@ 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("企业微信应用消息推送开始")
res = requests.get(
@ -159,10 +159,16 @@ def message2qywxapp(
"btntxt": "开源项目",
},
}
requests.post(
url=f"https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}",
data=json.dumps(data),
)
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),
)
return
@ -218,6 +224,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")
@ -270,6 +277,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:

View File

@ -17,6 +17,7 @@
"QYWX_KEY":"",
"QYWX_MEDIA_ID":"",
"QYWX_TOUSER":"",
"QYWX_ORIGIN":"",
"SCKEY":"",
"SENDKEY":"",
"TG_API_HOST":"",