飞书机器人发送消息py脚本
2020-11-28 本文已影响0人
醉眼看人间_个个都温柔
[root@Zabbix-server alertscripts]# cat feishu.py
#!/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://open.feishu.cn/open-apis/bot/v2/hook/fc213828-a46b-4d95-b15e-5xxxx" #飞书机器人Webhook地址
def msg(text):
json_text= {
"msg_type": "text",
"content": {
"text": text
},
}
print requests.post(api_url,json.dumps(json_text),headers=headers).content
if __name__ == '__main__':
text = sys.argv[1]
msg(text)
[root@Zabbix-server alertscripts]#