ForcePilot/backend/package/yuxi/channels/adapters/line/session.py
Kris a4ec94ef9d feat(line): 实现完整的 LINE 聊天适配器功能
新增 LINE 官方账号对接的全套功能,包括:
1. 基础的 Bot 探测、会话解析、消息格式化能力
2. 富媒体消息模板、快速回复、卡片指令支持
3. Webhook 签名验证、重放防护、多账户路由管理
4. 消息发送、回复、分块传输、用户绑定管理
5. 交互式配置向导与诊断工具
2026-05-12 00:45:33 +08:00

21 lines
714 B
Python

from __future__ import annotations
from yuxi.channels.models import ChatType
def resolve_chat_type(source_type: str) -> ChatType:
if source_type == "user":
return ChatType.DIRECT
return ChatType.GROUP
def resolve_channel_chat_id(source_type: str, source_id: str) -> str:
prefix_map = {"user": "user_", "group": "group_", "room": "room_"}
return f"{prefix_map.get(source_type, 'unknown_')}{source_id}"
def resolve_thread_key(agent_id: str, source_type: str, source_id: str, account_id: str = "default") -> str:
if source_type == "user":
return f"agent:{agent_id}:line:{account_id}:dm:{source_id}"
return f"agent:{agent_id}:line:{account_id}:{source_type}:{source_id}"