钉钉机器人发送消息脚本
· 技术积累 · Python

钉钉群机器人发送消息python脚本,可用作监控告警使用

如何使用:

1、注册个钉钉账号
2、创建一个群
3、添加群机器人
4、复制webhook到脚本api_url中

dingding0.png
dingding.png


python脚本

#!/usr/bin/python
# -*- coding: utf-8 -*-
 
import requests
import json
import sys
import os
 
headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
 
def msg(text):
    json_text= {
     "msgtype": "text",
        #@群成员参数,填写手机号
        "at": {
            "atMobiles": [
                "xxxxxxxxxxx"
        ],
            "isAtAll": False
        },

    "text": {
            "content": text
    }    
    }
    print requests.post(api_url,json.dumps(json_text),headers=headers).content
     
if __name__ == '__main__':
    text = sys.argv[3]
    msg(text)

本文最后更新时间 2019-04-30
文章链接地址:https://me.jinchuang.org/archives/451.html
本站文章除注明[转载|引用|原文]出处外,均为本站原生内容,转载前请注明出处


留言列表

  1. cloudcone
    cloudcone Windows 8.1 Google Chrome · 上海市上海市 · 回复

    钉钉办公利器

  2. 张小仙
    张小仙 Windows 10 Google Chrome · 天津市天津市 · 回复

    :mrgreen:博客 的footer.php页面的站点地图代码,可否提供一下呢?

    1. J.C
      J.C Windows 10 Google Chrome · 上海市上海市 · 回复

      你用这个网站https://www.xml-sitemaps.com生成下就行了,我就用的它

留言

顶部
您当前正在使用Internet Explorer浏览器访问本站,本站在此浏览器上兼容性较差
建议使用 Chrome, Firefox, or Edge浏览器访问本网站