# -*- coding: utf-8 -*- import json from datetime import datetime import pytz import requests def send_card_msg_to_feishu(webhook, card_json): """发送消息到飞书""" headers = {'Content-Type': 'application/json'} payload_message = { "msg_type": "interactive", "card": card_json } print(f"推送飞书消息webhook地址 - {webhook}, 消息内容: {json.dumps(payload_message)}") response = requests.request('POST', url=webhook, headers=headers, data=json.dumps(payload_message)) print(f"推送飞书消息返回结果: {response.text}") def timestamp_format(timestamp: str) -> str: try: return (datetime.utcfromtimestamp(int(timestamp)) .replace(tzinfo=pytz.UTC) .astimezone(pytz.timezone('Asia/Shanghai')) .strftime('%Y-%m-%d %H:%M:%S') ) except ValueError as e: return timestamp