首页 > 其他 > 详细

钉钉发送消息通知

时间:2019-09-23 10:32:35      阅读:310      评论:0      收藏:0      [点我收藏+]
#coding=utf8
import requests
import json
import time
import sys


def send_report(reporter,report_text,url):
reporter = ‘‘
now_time = time.strftime(‘%Y-%m-%d %H:%M:%S‘, time.localtime(time.time()))
url = ‘https://oapi.dingtalk.com/robot/send?access_token=‘
if reporter:
reporter = ‘@{}‘.format(reporter)

data={
"msgtype": "markdown",
"markdown": {
"title":"一体化部署错误",
"text": "一体化部署错误 {} \n\n "
"{}\n\n"
"告警时间 {} [点击查看]({}) \n".format(reporter,report_text,now_time,url),
"at":{
"atMobiles":
[
],
"isAtAll": False
}
}
}
header={‘Content-Type‘: ‘application/json‘}
data=json.dumps(data,encoding=‘utf8‘)
res=requests.post(url,data=data,headers=header)
if res.status_code!=200:
print ‘发送通知失败‘,res.text
sys.exit(1)
else:
print ‘发送通知成功‘

send_report(‘‘,‘上传文件失败‘,‘‘)

钉钉发送消息通知

原文:https://www.cnblogs.com/slqt/p/11570768.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!