#钉钉机器人
import json
import requests
import sys
# reminders 提醒
def send_msg_to_dingding(msg,
url = r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxx',
reminders=[]):
headers = {
'Content-Type': 'application/json;charset=utf-8'
}
data = {
"msgtype": "text",
"text": {"content": msg},
"at": {
"atMobiles": reminders,#此处为需要@什么人。填写具体用户
"isAtAll": False #此处为是否@所有人
}
}
ret = requests.post(url,data=json.dumps(data),headers=headers)
return ret.text
'''
if __name__ == '__main__':
msg = r'jenkins test'
reminders = []
url = r'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxx'
#此处为丁丁机器人的地址,参考技术手册创建
# print(send_msg(url,msg))
print(send_msg(url, reminders, msg))
'''