新增BlueBubbles适配器全套核心工具类与服务,包含会话管理、消息去重、Webhook验证、缓存系统、账号配置解析、聊天消息处理等完整功能模块,支持iMessage消息收发、群管理、反应特效、语音合成等能力,提供完善的健康检查与配置校验流程。
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
def merge_account_config(
|
|
top: dict[str, Any],
|
|
account: dict[str, Any],
|
|
) -> dict[str, Any]:
|
|
overridable_keys = {
|
|
"server_url",
|
|
"password",
|
|
"dm_policy",
|
|
"group_policy",
|
|
"dm_allow_from",
|
|
"group_allow_chats",
|
|
"require_mention",
|
|
"tapback_enabled",
|
|
"media_max_mb",
|
|
"media_local_roots",
|
|
"allow_private_network",
|
|
"webhook_path",
|
|
"webhook_secret",
|
|
"send_read_receipts",
|
|
"text_chunk_limit",
|
|
"chunk_mode",
|
|
"block_streaming",
|
|
"send_timeout_ms",
|
|
"dm_history_limit",
|
|
}
|
|
|
|
merged = dict(top)
|
|
for key in overridable_keys:
|
|
if key in account and account[key]:
|
|
merged[key] = account[key]
|
|
return merged
|
|
|
|
|
|
def apply_account_configs(
|
|
top_config: dict[str, Any],
|
|
accounts_config: dict[str, Any],
|
|
allow_config_writes: bool = True,
|
|
) -> dict[str, dict[str, Any]]:
|
|
if not allow_config_writes:
|
|
return {"default": dict(top_config)}
|
|
|
|
result: dict[str, dict[str, Any]] = {"default": dict(top_config)}
|
|
|
|
for account_id, raw in accounts_config.items():
|
|
if not isinstance(raw, dict):
|
|
continue
|
|
result[account_id] = merge_account_config(top_config, raw)
|
|
|
|
return result
|