ForcePilot/backend/package/yuxi/channels/adapters/telegram/session.py
Kris 71fec609bb feat(telegram-adapter): 实现完整的Telegram适配器基础代码
新增了Telegram适配器的全套基础模块,包括:
1.  核心适配器入口与会话工具
2.  账号管理、认证与配置系统
3.  连接相关的轮询、Webhook、更新偏移管理
4.  话题路由、管理与缓存系统
5.  消息反抖动、超时配置与工具类
6.  响应式UI与命令交互系统
7.  反应表情与通知系统
8.  审批与安全审计模块
9.  健康检查与状态监控
10. 贴纸缓存与视觉工具
11. 流式响应与协作功能
12. 群组迁移与目标归一化处理
2026-05-12 00:49:52 +08:00

20 lines
582 B
Python

from __future__ import annotations
from yuxi.channels.models import ChatType
def resolve_chat_type(telegram_chat_type: str) -> ChatType:
if telegram_chat_type == "private":
return ChatType.DIRECT
if telegram_chat_type in ("group", "supergroup"):
return ChatType.GROUP
if telegram_chat_type == "channel":
return ChatType.GUILD_CHANNEL
return ChatType.GROUP
def resolve_thread_key(chat_id: str, thread_id: str | None = None) -> str:
if thread_id:
return f"telegram:{chat_id}:topic:{thread_id}"
return f"telegram:{chat_id}"