feat(telegram): add dedicated TELEGRAM_PROXY env var and config.yaml proxy_url support

Pass platform_env_var="TELEGRAM_PROXY" to resolve_proxy_url() in both
telegram.py (main connect) and telegram_network.py (fallback transport),
so a Telegram-specific proxy takes priority over the generic HTTPS_PROXY.

Also bridge telegram.proxy_url from config.yaml to the TELEGRAM_PROXY
env var (env var takes precedence if both are set), add OPTIONAL_ENV_VARS
entry, docs, and tests.

Composite salvage of four community PRs:
- Core approach (both call sites): #9414 by @leeyang1990
- config.yaml bridging + docs: #6530 by @WhiteWorld
- Naming convention: #9074 by @brantzh6
- Earlier proxy work: #7786 by @ten-ltw

Closes #9414, closes #9074, closes #7786, closes #6530

Co-authored-by: WhiteWorld <WhiteWorld@users.noreply.github.com>
Co-authored-by: brantzh6 <brantzh6@users.noreply.github.com>
Co-authored-by: ten-ltw <ten-ltw@users.noreply.github.com>
This commit is contained in:
leeyang1990 2026-04-15 20:03:48 -07:00 committed by Teknium
parent ff5bf0d6c8
commit c5acc6edb6
7 changed files with 68 additions and 2 deletions

View file

@ -172,6 +172,27 @@ fly deploy
The gateway log should show: `[telegram] Connected to Telegram (webhook mode)`.
## Proxy Support
If Telegram's API is blocked or you need to route traffic through a proxy, set a Telegram-specific proxy URL. This takes priority over the generic `HTTPS_PROXY` / `HTTP_PROXY` env vars.
**Option 1: config.yaml (recommended)**
```yaml
telegram:
proxy_url: "socks5://127.0.0.1:1080"
```
**Option 2: environment variable**
```bash
TELEGRAM_PROXY=socks5://127.0.0.1:1080
```
Supported schemes: `http://`, `https://`, `socks5://`.
The proxy applies to both the main Telegram connection and the fallback IP transport. If no Telegram-specific proxy is set, the gateway falls back to `HTTPS_PROXY` / `HTTP_PROXY` / `ALL_PROXY` (or macOS system proxy auto-detection).
## Home Channel
Use the `/sethome` command in any Telegram chat (DM or group) to designate it as the **home channel**. Scheduled tasks (cron jobs) deliver their results to this channel.