ForcePilot/backend/package/yuxi/channel/extensions/imessage/status.py
Kris 4d52f634fe feat(imessage): 新增iMessage渠道插件完整实现
该提交新增了基于BlueBubbles的iMessage渠道插件,支持单聊和群组消息,包含文本、图片、语音、文件和视频消息收发,支持消息编辑、撤回、回复、 reactions和输入状态提示,同时实现了账号配置、安全校验、配对授权、消息格式化与分片等完整功能。
2026-05-21 10:50:15 +08:00

48 lines
1.4 KiB
Python

from __future__ import annotations
import logging
import httpx
logger = logging.getLogger(__name__)
class IMessageStatusAdapter:
async def probe(self, account: dict | None = None) -> bool:
if not account:
return False
server_url = account.get("server_url", "")
password = account.get("password", "")
if not server_url or not password:
return False
try:
async with httpx.AsyncClient(timeout=httpx.Timeout(5.0)) as client:
resp = await client.get(
f"{server_url}/api/v1/server/info",
headers={"Password": password},
)
if resp.status_code == 200:
data = resp.json()
return data.get("data", {}).get("imessage_ready", False)
return False
except Exception as e:
logger.warning("iMessage probe failed: %s", e)
return False
def build_summary(self, snapshot: object) -> dict:
return {
"channel": "imessage",
"mode": "bluebubbles",
}
def resolve_account_state(
self, account: dict, config: dict, configured: bool, enabled: bool
) -> str:
if not configured:
return "unconfigured"
if not enabled:
return "disabled"
return "ok"