新增BlueBubbles适配器全套核心工具类与服务,包含会话管理、消息去重、Webhook验证、缓存系统、账号配置解析、聊天消息处理等完整功能模块,支持iMessage消息收发、群管理、反应特效、语音合成等能力,提供完善的健康检查与配置校验流程。
17 lines
570 B
Python
17 lines
570 B
Python
from __future__ import annotations
|
|
|
|
import hashlib
|
|
from typing import Any
|
|
|
|
|
|
class ConversationID:
|
|
def generate(self, channel_id: str, chat_id: str, thread_id: str = "") -> str:
|
|
raw = f"{channel_id}:{chat_id}:{thread_id}"
|
|
return hashlib.sha256(raw.encode()).hexdigest()[:32]
|
|
|
|
def generate_from_context(self, context: dict[str, Any]) -> str:
|
|
channel_id = context.get("channel_id", "")
|
|
chat_id = context.get("chat_id", "")
|
|
thread_id = context.get("thread_id", "")
|
|
return self.generate(channel_id, chat_id, thread_id)
|