ForcePilot/backend/package/yuxi/channels/adapters/bluebubbles/directory.py
Kris 6aa1d52a8b feat(bluebubbles): 实现完整的BlueBubbles适配器基础组件
新增BlueBubbles适配器全套核心工具类与服务,包含会话管理、消息去重、Webhook验证、缓存系统、账号配置解析、聊天消息处理等完整功能模块,支持iMessage消息收发、群管理、反应特效、语音合成等能力,提供完善的健康检查与配置校验流程。
2026-05-12 00:42:57 +08:00

46 lines
1.4 KiB
Python

from __future__ import annotations
from typing import Any
from yuxi.channels.adapters.bluebubbles.client import BlueBubblesClient
from yuxi.utils.logging_config import logger
async def list_chats(client: BlueBubblesClient) -> list[dict[str, Any]]:
try:
result = await client.get("/api/v1/chat/query")
return result.get("data", [])
except Exception:
logger.warning("[BlueBubbles] Failed to list chats")
return []
async def list_contacts(client: BlueBubblesClient) -> list[dict[str, Any]]:
try:
result = await client.get("/api/v1/contact/query")
return result.get("data", [])
except Exception:
logger.warning("[BlueBubbles] Failed to list contacts")
return []
async def search_chats(client: BlueBubblesClient, query: str) -> list[dict[str, Any]]:
try:
result = await client.get("/api/v1/chat/query", params={"query": query})
return result.get("data", [])
except Exception:
logger.warning(f"[BlueBubbles] Failed to search chats for '{query}'")
return []
async def search_contacts(client: BlueBubblesClient, query: str) -> list[dict[str, Any]]:
try:
result = await client.post(
"/api/v1/contact/query",
json={"addresses": [query]},
)
return result.get("data", [])
except Exception:
logger.warning(f"[BlueBubbles] Failed to search contacts for '{query}'")
return []