You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
866 B
Python

import requests
import json
2 years ago
def send_dingtalk_message(webhook_url,message,all):
# 构建钉钉消息
message = {
"msgtype": "text",
"text": {
2 years ago
"content": message
},
"at": {
"isAtAll": all
}
}
# 发送HTTP POST请求
headers = {
"Content-Type": "application/json"
}
# 将消息转换为JSON格式
message_json = json.dumps(message)
# 发送请求
2 years ago
requests.post(webhook_url, data=message_json, headers=headers)
if __name__ == "__main__":
2 years ago
#webhook_url机器人的token号码message:呈现内容。all是否@全体发送
webhook_url='https://oapi.dingtalk.com/robot/send?access_token=ab20a597f1c8a6c8c7a68a2e4ed724af7c5ece4678616ac6efe95fb722583f0d'
message='更新禅道'
all=True
send_dingtalk_message(webhook_url,message,all)