初始化

This commit is contained in:
van
2026-04-23 22:06:19 +08:00
commit e9823c2261
26 changed files with 840 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
"""Telethon Connection 模式(与 Telegram Desktop 使用的传输类似可选用 obfuscated"""
from __future__ import annotations
from typing import Type
from telethon.network.connection import (
Connection,
ConnectionTcpAbridged,
ConnectionTcpFull,
ConnectionTcpIntermediate,
ConnectionTcpObfuscated,
)
def resolve_connection_class(mode: str) -> Type[Connection]:
m = (mode or "").strip().lower().replace("-", "_")
if not m or m == "tcp_full":
return ConnectionTcpFull
if m == "tcp_obfuscated":
return ConnectionTcpObfuscated
if m == "tcp_intermediate":
return ConnectionTcpIntermediate
if m == "tcp_abridged":
return ConnectionTcpAbridged
raise ValueError(
f"不支持的 TELEGRAM_CONNECTION={mode!r},可用: "
"tcp_full, tcp_obfuscated, tcp_intermediate, tcp_abridged"
)