Telegram settings
Skip to Content
Teldrive
Configuration

Telegram settings

Configure Telegram connectivity, concurrency, channels, proxies, and download clients.

Teldrive includes public Telegram application credentials. For your own credentials, follow Custom Telegram application.

Connection

telegram:
  backend: remote
  dial-timeout: 10s
  reconnect-timeout: 5m
  max-retries: 10
  rate-limit: true
  rate-interval: 50ms
  rate-burst: 10

Keep rate limiting enabled unless you have a specific reason to change it. The limit applies to each Telegram account separately: your user account and every bot each get their own rate-interval/rate-burst budget, so adding bots adds request capacity.

NTP clock

NTP is disabled by default. Enable it explicitly if the server clock is incorrect and Telegram rejects messages:

telegram:
  ntp: true
  ntp-server: pool.ntp.org

Or set TELDRIVE_TELEGRAM_NTP=true and optionally TELDRIVE_TELEGRAM_NTP_SERVER.

The remote Telegram backend queries the server once when its client factory starts and shares the resulting time offset across clients. It does not change the system clock or periodically resynchronize; restart Teldrive to refresh the offset. If the initial NTP query fails, startup fails rather than silently using the system clock. NTP requires direct outbound UDP (normally port 123); it does not use the Telegram proxy. The filesystem backend does not query NTP.

Uploads

telegram:
  upload-threads: 8

Valid range: 1–32. Increase only after measuring throughput and Telegram errors.

Downloads

telegram:
  download-bots: 0
  download-client-pool: false
  download-read-buffers: 32
  download-read-parallel: 4
  • download-bots: 0 uses the authenticated user; any positive value enables the first N enabled bots (by bot ID) for downloads.
  • download-client-pool: keeps one authenticated download client warm per download bot (or the user account) when enabled. Each download still goes to the least-loaded bot; idle warm clients do not count as load.
  • download-read-buffers: prefetched chunks per stream, range 1–256.
  • download-read-parallel: concurrent chunk fetches per stream, range 1–32.

Increasing buffering/parallelism raises memory and Telegram request pressure across simultaneous downloads.

Storage channels

telegram:
  randomize-part-names: true
  auto-channel-create: true
  channel-part-limit: 500000
  channel-name-prefix: teldrive

See Storage channels.

Bot rotation

telegram:
  bot-rotation-backend: memory

Each upload or download goes to the eligible bot with the fewest Telegram connections in use on this instance, so a busy bot is skipped while an idle one is available. When several bots are equally loaded, the rotation backend decides which goes next. Use memory for one instance and database when multiple instances must coordinate that rotation. Load is tracked per instance.

A bot whose token Telegram rejects as revoked or invalid (ACCESS_TOKEN_EXPIRED, ACCESS_TOKEN_INVALID) is disabled; Settings → Bots shows it as Disabled. If the failure happened before any work ran on that bot, the upload or download moves to the next eligible bot, or to your user account if no bots are left. Re-add the bot with a new token from BotFather to turn it back on.

Other failures that point at the bot keep it enabled but skip it for 30 seconds: any failed upload, and a download where the bot could not connect or sign in. A download stops on the bot’s first failed connection attempt instead of letting the client keep reconnecting for up to reconnect-timeout, so the bot is skipped even when the caller would have given up first. Download errors after the bot is connected, such as an expired file reference, would fail on any bot and do not skip it. A skipped bot is not replaced by one beyond the download-bots limit; if all of the first N bots are being skipped, downloads use your user account.

Proxy

Standard HTTP/HTTPS/SOCKS5 proxy:

telegram:
  proxy: "socks5://user:password@proxy.example.com:1080"

MTProxy:

telegram:
  mtproxy:
    address: "proxy.example.com:443"
    secret: "YOUR_SECRET"

Do not configure both. MTProxy address and secret must be set together.

Client logging

telegram:
  client-logging: false

Enable temporarily for low-level Telegram diagnostics.

Filesystem backend

For development/tests only:

telegram:
  backend: filesystem
  local-root: ./var/local-telegram

This stores payloads locally instead of in Telegram.