#!/usr/bin/env python3 """发送卡片图片""" import asyncio import sys sys.path.insert(0, '/app') from app.services.wecom_service import WecomService async def main(): wecom = WecomService() try: # 读取图片 with open('/tmp/it_reminder_card_v2.png', 'rb') as f: image_data = f.read() # 上传 print("📤 上传卡片...") media_id = await wecom.upload_temp_media("image", image_data, "card.png") print(f" media_id: {media_id}") # 发送 print("📨 发送消息...") result = await wecom.send_image_message("sxn", media_id) if result.get("errcode") == 0: print(f"✅ 发送成功! msgid: {result.get('msgid')}") else: print(f"❌ 失败: {result}") finally: await wecom.close() if __name__ == "__main__": asyncio.run(main())