Imported from allypost-org/downloader-hub (
bins/downloader-bot/AGENTS.md). Install upstream withnpx skills add allypost-org/downloader-hub --skill downloader-bot. Copyright stays with the author.
downloader-bot
Multi-platform bot (Telegram + Discord + others) selected via the first positional subcommand. See root AGENTS.md for toolchain/build commands.
Layout
src/main.rs→cmd::run(CmdConfig)dispatches onCmdConfig::Telegram(cfg)/CmdConfig::Discord(cfg).src/cmd/_config.rs— shared subcommand enum (CmdConfig).src/cmd/telegram/— teloxide-based Telegram bot (bot/,common/,config.rs).src/cmd/discord/— serenity-based Discord bot (bot/,broadcaster.rs,config.rs).src/peering/— peer-comms integration.init_peering_endpoint(...)joins the iroh mesh (HTTPS bootstrap → iroh ticket) and connects an authenticated irpc session to central (rpc::RpcClient::init→Authwith the bot API key).reconnect.rsis the process-wide single-flight reconnect coordinator.src/peering/rpc/mod.rs— irpcRpcClient(overirpc-iroh):work_request_create, plus the per-request delivery RPCswork_request_wait(server-streaming),work_request_ack,work_request_finish_delivery,work_request_release_delivery, and the one-shotwork_request_list_mine_in_progressstartup scan.src/cmd/_common/request_processor.rs— process-local keyed task supervisor (one task per request id), thePlatformDeliverytrait (status-message + delivery ops), thewatch_and_processstate machine, anddownload_and_deliver.
Startup contract (async_main in src/main.rs)
Config::init_parsed().app_helpers::config::init(config.dependency_paths)— wires yt-dlp/ffmpeg paths.peering::init_peering_endpoint(config.peer)— fetches the iroh ticket from/api/v1/join-ticket, builds thePeeringEndpoint, thenRpcClient::init(theAuthirpc call).- Platform-specific
cmd::run(...)— each platform runs a one-shotstartup_scan(recovering in-progress/delivering requests as supervised per-request watchers) and then starts per-requestWorkRequestWaitstreams from the message handlers. Per-request watches own their own lifecycles; delivery is fenced by the databasedeliveringlease (ackDelivery/finishDelivery/releaseDelivery).
The bot-telegram and bot-discord entries in mprocs.yaml are the canonical dev invocations.