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

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

如何使用:

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

钉钉机器人发送消息脚本

钉钉机器人发送消息脚本


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)

本文最后更新时间 2024-03-31
文章链接地址:
https://me.jinchuang.org/archives/451.html
本站文章除注明[转载|引用],均为本站原创内容,转载前请注明出处
使用腾讯云CDN的SDK 用脚本去刷新URL缓存
pip 安装错误 Command "python setup.py egg_info" failed with error code
Linux命令行界面使用Python+Selenium+Chrome对网页截图
warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless

2015年买的二手笔记本电脑,发现功能还是很强的!

Kubernetes部署Dashboard UI

留言列表

  1. cloudcone
    Windows 8.1 Google Chrome
    中国上海市松江区电信

    钉钉办公利器

  2. 张小仙
    Windows 10 Google Chrome
    中国天津市电信IDC机房

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

    1. Awking
      Windows 10 Google Chrome
      中国上海市松江区电信

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

我要留言