21 lines
714 B
Python
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}"
|