mirror of
https://github.com/tiennm99/telegram-exporter.git
synced 2026-10-04 06:13:38 +00:00
First slice of replacing the three-script pipeline with one process. The scripts coordinate tdl and rclone as separate programs, so everything expensive in them exists to work around the fact that neither can see the other's state. A single process does not need that machinery. This slice covers only the foundations: open the session tdl login already wrote, resolve an rclone destination, and report on both via a doctor command. Downloading, uploading and verification follow. The session store is shared with the tdl CLI rather than copied, so the two cannot run against one namespace at the same time; -n selects another. AppID and AppHash are read from the store rather than hardcoded, because a session is bound to the application that created it and tdl records which one it used. No middlewares are passed to tclient.New, which already prepends its own defaults; the DC pool gets them instead, since gotd applies a client's middlewares only to direct invocations and not to pooled connections. The rclone config is loaded up front because the lazy path calls os.Exit on a config it cannot read, which would bypass every defer and exit with the code this tool reserves for an incomplete run. Exit codes follow the shell pipeline: 0 ok, 1 incomplete, 2 usage, 3 remote failure, 130 SIGINT, 143 SIGTERM. Cancellation is checked explicitly after the Telegram client returns, because gotd reports an interrupted run as success and a driver would read that as a finished archive.