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:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user