feat: SOCKS5 proxy для Telegram (обход RKN через Xray VLESS-Reality)

- 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 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-16 02:56:42 +10:00
co-authored by Claude Opus 4.6
parent 5872c6ff35
commit dde31c03fe
4 changed files with 8 additions and 3 deletions
+1
View File
@@ -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
+4 -2
View File
@@ -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)
+1
View File
@@ -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
+2 -1
View File
@@ -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