from __future__ import annotations from app.clients.pywechat_client import ClientRegistry, OnlineStatus, registry class SendService: def __init__(self, registry: ClientRegistry): self.registry = registry def send_text(self, account_id: str, conversation_id: str, text: str) -> dict: client = self.registry.get(account_id) if client is None: return {"success": False, "error": f"account {account_id} not registered"} if client.state.online_status != OnlineStatus.ONLINE: return {"success": False, "error": "account not online"} return client.send_text(conversation_id, text) def send_image(self, account_id: str, conversation_id: str, image_url: str) -> dict: # Placeholder for image sending via pywechat. client = self.registry.get(account_id) if client is None: return {"success": False, "error": f"account {account_id} not registered"} if client.state.online_status != OnlineStatus.ONLINE: return {"success": False, "error": "account not online"} return { "success": True, "message_id": f"mock-img-{image_url.split('/')[-1]}", "conversation_id": conversation_id, "type": "image", } send_service = SendService(registry)