钉钉自定义机器人
commit
eeb4942140
@ -0,0 +1,26 @@
|
||||
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)
|
Binary file not shown.
Loading…
Reference in New Issue