新增BlueBubbles适配器全套核心工具类与服务,包含会话管理、消息去重、Webhook验证、缓存系统、账号配置解析、聊天消息处理等完整功能模块,支持iMessage消息收发、群管理、反应特效、语音合成等能力,提供完善的健康检查与配置校验流程。
66 lines
1.4 KiB
Python
66 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from yuxi.channels.adapters.bluebubbles.client import BlueBubblesClient
|
|
|
|
|
|
async def rename_chat(
|
|
client: BlueBubblesClient,
|
|
chat_guid: str,
|
|
new_name: str,
|
|
) -> dict[str, Any]:
|
|
return await client.put(
|
|
f"/api/v1/chat/{chat_guid}",
|
|
json={"displayName": new_name},
|
|
)
|
|
|
|
|
|
async def set_group_icon(
|
|
client: BlueBubblesClient,
|
|
chat_guid: str,
|
|
file_path: str,
|
|
) -> dict[str, Any]:
|
|
import asyncio
|
|
from pathlib import Path
|
|
|
|
path = Path(file_path)
|
|
content = await asyncio.to_thread(path.read_bytes)
|
|
files = {"chatIcon": (path.name, content)}
|
|
return await client.post(
|
|
f"/api/v1/chat/{chat_guid}/icon",
|
|
files=files,
|
|
)
|
|
|
|
|
|
async def add_participant(
|
|
client: BlueBubblesClient,
|
|
chat_guid: str,
|
|
address: str,
|
|
) -> dict[str, Any]:
|
|
return await client.post(
|
|
f"/api/v1/chat/{chat_guid}/participant",
|
|
json={"address": address},
|
|
)
|
|
|
|
|
|
async def remove_participant(
|
|
client: BlueBubblesClient,
|
|
chat_guid: str,
|
|
address: str,
|
|
) -> dict[str, Any]:
|
|
return await client.post(
|
|
f"/api/v1/chat/{chat_guid}/removeparticipant",
|
|
json={"address": address},
|
|
)
|
|
|
|
|
|
async def leave_chat(
|
|
client: BlueBubblesClient,
|
|
chat_guid: str,
|
|
) -> dict[str, Any]:
|
|
return await client.post(
|
|
f"/api/v1/chat/{chat_guid}/leave",
|
|
json={},
|
|
)
|