未验证 提交 5045098c 编写于 作者: 李伟强 提交者: GitHub

Update notify.py (#748)

上级 20e34bfe
......@@ -249,9 +249,37 @@ class Send(object):
print("send_mail_success")
@classmethod
def send_wecom(cls, payload):
def send_wecom(cls, alert_content, payload):
users = payload.get("users")
for u in users:
contacts = u.get("contacts")
print(contacts)
wecom_robot_token = contacts.get(WECOM_ROBOT_TOKEN_NAME, "")
if wecom_robot_token == "":
print("wecom_robot_token_not_found")
continue
wecom_api_url = "{}?key={}".format(WECOM_API, wecom_robot_token)
atMobiles = [u.get("phone")]
headers = {'Content-Type': 'application/json;charset=utf-8'}
payload = {
"msgtype": "text",
"text": {
"content": alert_content
},
"at": {
"atMobiles": atMobiles,
"isAtAll": False
}
}
res = requests.post(wecom_api_url, json.dumps(payload), headers=headers)
print(res.status_code)
print(res.text)
print("send_wecom")
@classmethod
def send_dingtalk(cls, alert_content, payload):
# 钉钉发群信息需要群的webhook机器人 token,这个信息可以在user的contacts map中
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册