| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- #!/usr/bin/env python
 
- # -*- encoding: utf-8 -*-
 
- """
 
- Author renyupeng
 
- coding=utf-8
 
- @Time    : 2023/2/7 下午
 
- @Site    :
 
- @File    : send_feishu_msg.py
 
- @Software: PyCharm
 
- @contact: renyupeng@c-top.com.cn
 
- @Tel 1501435553
 
- encoding=utf-8
 
- """
 
- import logging
 
- import json
 
- import requests
 
- import traceback
 
- class SendFeiShuMsg:
 
-     @staticmethod
 
-     def send_robot_msg(msg_content):
 
-         try:
 
-             url = 'https://open.feishu.cn/open-apis/bot/v2/hook/7abdd37f-4a8e-4d6c-840e-ed78e892f019'
 
-             req_head = {"Content-Type": "application/json"}
 
-             req_data = {
 
-                 "msg_type": "text",
 
-                 "content": {
 
-                     "text": 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=req_head)
 
-             result = response.json()
 
-             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()))
 
-     @staticmethod
 
-     def send_cookie_robot_msg(msg_content):
 
-         try:
 
-             url = 'https://open.feishu.cn/open-apis/bot/v2/hook/4c20b26f-6a58-4ebf-9754-80ab1b35387e'
 
-             req_head = {"Content-Type": "application/json"}
 
-             req_data = {
 
-                 "msg_type": "text",
 
-                 "content": {
 
-                     "text": 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=req_head)
 
-             result = response.json()
 
-             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()))
 
 
  |