♻️ 重构(message.py):改进变量命名,从bastUrl改为bast_url,以符合Python的PEP8命名规范

This commit is contained in:
shitao 2024-03-08 10:10:19 +08:00
parent fac507ec7a
commit 7fcc3406bc

View File

@ -123,14 +123,20 @@ def message2qywxrobot(qywx_key, content):
def message2qywxapp( def message2qywxapp(
qywx_corpid, qywx_agentid, qywx_corpsecret, qywx_touser, qywx_media_id, qywx_origin, content qywx_corpid,
qywx_agentid,
qywx_corpsecret,
qywx_touser,
qywx_media_id,
qywx_origin,
content,
): ):
print("企业微信应用消息推送开始") print("企业微信应用消息推送开始")
bastUrl = "https://qyapi.weixin.qq.com" bast_url = "https://qyapi.weixin.qq.com"
if qywx_origin: if qywx_origin:
bastUrl = qywx_origin; bast_url = qywx_origin
res = requests.get( res = requests.get(
f"{bastUrl}/cgi-bin/gettoken?corpid={qywx_corpid}&corpsecret={qywx_corpsecret}" f"{bast_url}/cgi-bin/gettoken?corpid={qywx_corpid}&corpsecret={qywx_corpsecret}"
) )
token = res.json().get("access_token", False) token = res.json().get("access_token", False)
if qywx_media_id: if qywx_media_id:
@ -164,7 +170,7 @@ def message2qywxapp(
}, },
} }
requests.post( requests.post(
url=f"{bastUrl}/cgi-bin/message/send?access_token={token}", url=f"{bast_url}/cgi-bin/message/send?access_token={token}",
data=json.dumps(data), data=json.dumps(data),
) )
return return