FeishuBot.py 886 B

12345678910111213141516171819202122
  1. import requests
  2. class FeishuBot:
  3. webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/cbf0bc0f-994a-489b-9f77-de0c5be107cd"
  4. def send_message(self, message_text):
  5. headers = {'Content-Type': 'application/json'}
  6. data = {
  7. "msg_type": "text",
  8. "content": {"text": message_text}
  9. }
  10. response = requests.post(self.webhook_url, json=data, headers=headers)
  11. response.raise_for_status() # 如果响应状态码不是200,则抛出HTTPError异常
  12. return response.json() # 返回JSON响应(如果需要的话)
  13. # if __name__ == '__main__':
  14. # bot = FeishuBot()
  15. # msg = (f'推荐模型数据更新 \n step1【校验hive数据源】【success】:\n'
  16. # f'读取project.table,分区:dt= partitionDt/hh=partitionHh,数据总量:count')
  17. # msg = ('1')
  18. # print(bot.send_message(msg))