fix: Telegram-бот через прокси (xray на host:10808)

- telegram_bot.py: HTTPXRequest с proxy из HTTPS_PROXY env
- docker-compose.yml: host.docker.internal:10808, extra_hosts gateway

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-22 18:05:42 +10:00
co-authored by Claude Opus 4.6
parent 00d3a7cefa
commit c429e48603
2 changed files with 15 additions and 1 deletions
+5
View File
@@ -6,6 +6,11 @@ services:
container_name: smeta-bot
restart: unless-stopped
env_file: .env
environment:
- HTTPS_PROXY=http://host.docker.internal:10808
- HTTP_PROXY=http://host.docker.internal:10808
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./resources.json:/app/resources.json:ro
- ./data:/app/data:ro
+10 -1
View File
@@ -207,7 +207,16 @@ def run_bot():
logging.basicConfig(level=logging.INFO)
logger.info("Starting smeta bot...")
app = Application.builder().token(token).build()
# Configure proxy if available
proxy_url = os.environ.get("HTTPS_PROXY") or os.environ.get("HTTP_PROXY")
builder = Application.builder().token(token)
if proxy_url:
from telegram.request import HTTPXRequest
request = HTTPXRequest(proxy=proxy_url)
builder = builder.request(request).get_updates_request(HTTPXRequest(proxy=proxy_url))
logger.info(f"Using proxy: {proxy_url}")
app = builder.build()
app.add_handler(CommandHandler("start", start_command))
app.add_handler(CommandHandler("help", help_command))