From dde31c03fed9da8f5b819c4cf7e3f77553c677fb Mon Sep 17 00:00:00 2001 From: anor Date: Mon, 16 Mar 2026 02:56:42 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20SOCKS5=20proxy=20=D0=B4=D0=BB=D1=8F=20T?= =?UTF-8?q?elegram=20(=D0=BE=D0=B1=D1=85=D0=BE=D0=B4=20RKN=20=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=20Xray=20VLESS-Reality)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TelegramConfig.proxy — новое поле конфига - send_telegram(), poll_loop, _send_with_keyboard — proxy параметр - config.yaml — socks5://127.0.0.1:10808 Co-Authored-By: Claude Opus 4.6 --- config.yaml | 1 + src/remizov_trader/cli.py | 6 ++++-- src/remizov_trader/config.py | 1 + src/remizov_trader/notify.py | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 1044bb5..6ad891c 100644 --- a/config.yaml +++ b/config.yaml @@ -112,6 +112,7 @@ telegram: enabled: false bot_token: "" # set via REMIZOV_TG_TOKEN env var chat_id: "" + proxy: "socks5://127.0.0.1:10808" # Xray VLESS-Reality (RKN bypass) llm: enabled: false diff --git a/src/remizov_trader/cli.py b/src/remizov_trader/cli.py index 3ce4b41..d71e0db 100644 --- a/src/remizov_trader/cli.py +++ b/src/remizov_trader/cli.py @@ -367,7 +367,8 @@ def _send_with_keyboard(cfg, text: str, keyboard=None): if keyboard: payload["reply_markup"] = keyboard try: - httpx.post(url, json=payload, timeout=30) + proxy = cfg.telegram.proxy or None + httpx.post(url, json=payload, timeout=30, proxy=proxy) except Exception: pass @@ -496,9 +497,10 @@ def _start_telegram_listener(cfg, get_db_fn): log.info("Telegram listener started") while True: try: + proxy = cfg.telegram.proxy or None resp = httpx.get(f"{base_url}/getUpdates", params={"offset": offset, "timeout": 30}, - timeout=60) + timeout=60, proxy=proxy) if resp.status_code != 200: log.warning(f"Telegram poll: HTTP {resp.status_code}") time.sleep(5) diff --git a/src/remizov_trader/config.py b/src/remizov_trader/config.py index 68872b2..83ce09a 100644 --- a/src/remizov_trader/config.py +++ b/src/remizov_trader/config.py @@ -99,6 +99,7 @@ class TelegramConfig: enabled: bool = False bot_token: str = "" chat_id: str = "" + proxy: str = "" # SOCKS5/HTTP proxy, e.g. "socks5://127.0.0.1:10808" @dataclass diff --git a/src/remizov_trader/notify.py b/src/remizov_trader/notify.py index 2af5d3f..bceaf58 100644 --- a/src/remizov_trader/notify.py +++ b/src/remizov_trader/notify.py @@ -22,13 +22,14 @@ def send_telegram(cfg: TelegramConfig, message: str) -> bool: return False url = f"https://api.telegram.org/bot{cfg.bot_token}/sendMessage" + proxy = cfg.proxy or None for attempt in range(2): try: resp = httpx.post(url, json={ "chat_id": cfg.chat_id, "text": message, "parse_mode": "HTML", - }, timeout=20) + }, timeout=20, proxy=proxy) if resp.status_code != 200: log.warning("Telegram API error: %s", resp.text) return False