opentele2.consistency
Server-side checks of a connected TelegramClient: seven requests an official client makes,
whose answers tell whether the session looks like the client it claims to be. Every detail line,
summary and pass rule comes from the core.
from opentele2.consistency import CheckResult, ConsistencyChecker, ConsistencyReportTelegramClient.RunConsistencyChecks(auto_warn=True) is the short form of
ConsistencyChecker(client, auto_warn=auto_warn).run_all().
ConsistencyChecker
opentele2/consistency.py
class ConsistencyChecker:
def __init__(self, client: TelegramClient, *, auto_warn: bool = True) -> None: ...
async def run_all(self) -> ConsistencyReport: ...
async def check_get_config(self) -> CheckResult: ...
async def check_nearest_dc(self) -> CheckResult: ...
async def check_current_session(self) -> CheckResult: ...
async def check_layer_match(self) -> CheckResult: ...
async def check_lang_pack(self) -> CheckResult: ...
async def check_app_update(self) -> CheckResult: ...
async def check_terms_of_service(self) -> CheckResult: ...run_all runs the checks in this order and builds the report; with auto_warn a failing check
emits one warning with the summary. A check that raises out of its own handling fails with the
error text.
| Check | Request | Passes when |
|---|---|---|
get_config | help.getConfig | the request succeeds; the detail names the DC |
nearest_dc | help.getNearestDc | the request succeeds; the detail names the country and DCs |
current_session | account. | the current session is flagged official_app |
layer_match | none | the installed Telethon layer is within 15 of LAYER |
lang_pack | langpack.getLanguages | the request for the client’s lang pack succeeds; an empty lang pack passes without a request |
app_update | help.getAppUpdate | the request succeeds; the detail tells whether an update is offered |
terms_of_service | help. | the request succeeds |
ConsistencyReport
opentele2/consistency.py
@dataclass
class ConsistencyReport:
checks: list[CheckResult] = field(default_factory=list)
@property
def all_passed(self) -> bool: ...
@property
def summary(self) -> str: ...| Name | Description |
|---|---|
checks | One result per check, in run order. |
all_passed | Whether every check passed. |
summary | A count line, then one [OK] name: detail or [FAIL] name: detail line per check; also str() of the report. |
CheckResult
opentele2/consistency.py
@dataclass
class CheckResult:
name: str
passed: bool
detail: str = ""
server_response: Any = Noneserver_response holds the Telethon object the server answered with, None for a check without
a request or one that failed.
checks.py
import asyncio
from opentele2.td import TDesktop
from opentele2.api import UseCurrentSession
async def main():
client = await TDesktop("tdata").ToTelethon("checks.session", UseCurrentSession)
await client.connect()
report = await client.RunConsistencyChecks(auto_warn=False)
print(report.summary)
print(report.all_passed)
asyncio.run(main())Last updated on