FeishuBot.py 591 B

123456789101112131415
  1. import requests
  2. class FeishuBot:
  3. webhook_url = "https://open.feishu.cn/open-apis/bot/v2/hook/842434bd-516b-4e0d-86d5-8e14b5a15346"
  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响应(如果需要的话)