新增大量WhatsApp适配器相关代码,包括账号管理、会话处理、消息收发、验证授权、媒体处理、互动命令、审批流程、健康检测等完整功能模块,搭建基础的Baileys协议WhatsApp接入能力
22 lines
666 B
Python
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"}
|