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.
27 lines
779 B
Python
27 lines
779 B
Python
import requests
|
|
import json
|
|
# 配置你的Webhook URL
|
|
webhook_url = 'https://oapi.dingtalk.com/robot/send?access_token='
|
|
def send_dingtalk_message(token,all):
|
|
# 构建钉钉消息
|
|
message = {
|
|
"msgtype": "text",
|
|
"text": {
|
|
"content": "小助手提醒大家要写禅道啦~。"
|
|
},
|
|
"at": {
|
|
"isAtAll": all
|
|
}
|
|
}
|
|
# 发送HTTP POST请求
|
|
headers = {
|
|
"Content-Type": "application/json"
|
|
}
|
|
# 将消息转换为JSON格式
|
|
message_json = json.dumps(message)
|
|
# 发送请求
|
|
url=webhook_url+token
|
|
requests.post(url, data=message_json, headers=headers)
|
|
if __name__ == "__main__":
|
|
send_dingtalk_message('ab20a597f1c8a6c8c7a68a2e4ed724af7c5ece4678616ac6efe95fb722583f0d',False)
|