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)