Skip to main content

Tools#

Every tool takes project_dir — an absolute path to a tgcloud project (create_project takes parent_dir and name instead).

Lifecycle #

ToolCLI commandDescription
create_projectnpm create @tgcloud/botScaffold a new project (parent_dir, name)
init_projecttgcloud initScaffold into an existing directory, including a detected Mini App
login_bottgcloud loginLink a bot via CLI access token (app<id>:<secret>); token via stdin, masked
add_moduletgcloud addNew module: handlers/<type>, endpoints/<name>, lib/<path>
upgradetgcloud upgradeMove a pre-0.2.0 layout into tgcloud/. dry_run: true by default; applying needs confirm: true

Sync #

ToolCLI commandDescription
statustgcloud statusLocal changes vs snapshot (offline), including static diffs and webhook drift
difftgcloud diffLine-by-line diff (offline)
pushtgcloud pushAtomic deploy. Does not build the front-end and does not migrate. force: true requires confirm: true
deploynpm run build + tgcloud pushBuild when package.json has a build script, then push. skip_build: true pushes only
pulltgcloud pullCloud → snapshot and working files. Does not write the Mini App build folder
fetchtgcloud fetchCloud → snapshot only
resettgcloud resetDiscard local module edits; requires confirm: true

Data #

ToolCLI commandDescription
run_handlertgcloud runRun a handler or endpoint without deploying. args and ctx are JSON5. args is the first argument (the payload: a Message for a handler, the input for an endpoint); ctx is the second (ctx.update is the raw Update for a handler, including update_id; initData for an endpoint)
migratetgcloud migratedry_run: true (default) previews. Applying needs dry_run: false and confirm: true. apply: "safe" is --safe; apply: "yes" (default when applying) is --yes. local: true is --local

Webhook #

ToolCLI commandDescription
webhook_statustgcloud webhookURL, allowed_updates, pending updates, delivery errors, in sync or not
webhook_synctgcloud webhook syncRe-point the webhook. drop_pending: true requires confirm: true

Adding or removing a handler can leave the webhook out of sync. push does not guarantee a refresh. Call webhook_sync after that kind of deploy.

Recipes#

  • Silent bot: webhook_status → status / diff → push → webhook_sync
  • Deployed logs: no command downloads them; read webhook_status’s last delivery error, then reproduce with run_handler (its console.* is local output, not the deployed bot’s)
  • Revision conflict on push: fetch → diff → push (or force with confirm)
  • Schema change: edit schema.js → push → migrate (dry-run) → migrate with confirm. Prefer apply: "safe" when nothing is dropped
  • Mini App front-end: deploy, not a bare push