| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | 
							- # Author renyupeng
 
- # coding=utf-8
 
- # @Time    : 2021/11/3 4:00 下午
 
- # @Site    : 
 
- # @File    : sendMessage.py
 
- # @Software: PyCharm
 
- # @contact: renyupeng@c-top.com.cn
 
- # @Tel 1501435553
 
- import json
 
- import logging
 
- import traceback
 
- import requests
 
- class feishuMsg:
 
-     @classmethod
 
-     def send_robot_msg(cls, msg_content):
 
-         try:
 
-             url = 'https://open.feishu.cn/open-apis/bot/v2/hook/3476829c-29a4-4db8-b53b-4a83194a4759'
 
-             headers = {
 
-                 'Content-Type': 'application/json'
 
-             }
 
-             req_data = {
 
-                 "msg_type": "text",
 
-                 "content": {
 
-                     "text": str(msg_content)
 
-                 }
 
-             }
 
-             data = json.dumps(req_data)
 
-             logging.info("send_robot_msg req_url:{}, req_data:{}".format(url, data))
 
-             response = requests.post(url=url, data=data, headers=headers)
 
-             result = response.json()
 
-             print(result)
 
-             logging.info("send_robot_msg response:{}".format(response.json()))
 
-             if result.get("StatusCode") == 0:
 
-                 logging.info("钉钉通知发送成功")
 
-                 return True
 
-             else:
 
-                 logging.error("钉钉通知发送失败,请检查!")
 
-                 return False
 
-         except Exception as e:
 
-             logging.error("send_robot_msg Error:{}".format(traceback.format_exc()))
 
 
  |