import requests
from loguru import logger
def send_warning_info(content, isAtAll=False):
url = 'https://oapi.dingtalk.com/robot/send?access_token=' \
'87b87ecd3a8fb86a8e6d3b44a41e45ba39e8ba45a4397983b610831cf3131dfb9'
keyword = '精益求精'
complete_content = "[%s] %s" % (keyword, content)
req_data = {
"msgtype": "text",
"text": {
"content": complete_content
},
"at": {
"isAtAll": isAtAll
}
}
json_data = json.dumps(req_data)
headers = {'Content-Type': 'application/json'}
try:
requests.post(url, json_data, headers=headers)
except Exception as e:
logger.error('Send dingtalk message failed. | Exception: %s' % str(e))
python 关键字发送钉钉消息示例
最新推荐文章于 2024-07-04 10:53:14 发布