新增BlueBubbles适配器全套核心工具类与服务,包含会话管理、消息去重、Webhook验证、缓存系统、账号配置解析、聊天消息处理等完整功能模块,支持iMessage消息收发、群管理、反应特效、语音合成等能力,提供完善的健康检查与配置校验流程。
35 lines
857 B
Python
35 lines
857 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
def resolve_account(
|
|
accounts: dict[str, Any],
|
|
account_id: str | None = None,
|
|
sender_address: str | None = None,
|
|
) -> dict[str, Any] | None:
|
|
if account_id and account_id in accounts:
|
|
return accounts[account_id]
|
|
|
|
if not accounts:
|
|
return None
|
|
|
|
if "default" in accounts:
|
|
return accounts["default"]
|
|
|
|
first_key = next(iter(accounts))
|
|
return accounts[first_key]
|
|
|
|
|
|
def resolve_account_for_handle(
|
|
accounts: dict[str, Any],
|
|
handle: str,
|
|
) -> dict[str, Any] | None:
|
|
for acc_id, acc_config in accounts.items():
|
|
if not isinstance(acc_config, dict):
|
|
continue
|
|
mapping = acc_config.get("handle_mapping", {})
|
|
if isinstance(mapping, dict) and handle in mapping:
|
|
return acc_config
|
|
return None
|