20 lines
582 B
Python
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}"
|