ForcePilot/backend/package/yuxi/channels/adapters/whatsapp/probe.py
Kris e9b57546ea feat(whatsapp): 新增WhatsApp适配器完整功能模块
新增大量WhatsApp适配器相关代码,包括账号管理、会话处理、消息收发、验证授权、媒体处理、互动命令、审批流程、健康检测等完整功能模块,搭建基础的Baileys协议WhatsApp接入能力
2026-05-12 00:51:58 +08:00

22 lines
666 B
Python

from __future__ import annotations
from typing import Any
from yuxi.channels.models import HealthStatus
async def probe_bridge(bridge) -> HealthStatus:
return await bridge.health_check()
async def wait_for_connection(bridge, timeout: float = 30.0) -> dict[str, Any]:
import asyncio
deadline = asyncio.get_event_loop().time() + timeout
while asyncio.get_event_loop().time() < deadline:
health = await bridge.health_check()
if health.status == "healthy":
return {"connected": True, "jid": health.metadata.get("jid", "")}
await asyncio.sleep(1.0)
return {"connected": False, "error": "Connection timeout"}