/
kreyndelHam
/
Konstructorium
Обзор
Документация
Войти
/
kreyndelHam
/
Konstructorium
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
dev
scripts/telegram/verify_dev.ps1
71 строка
2 KB
MihahamYT
Telegram Bot Working
25 май 2026, 20:20
25 май 2026, 20:20
1089971
Код
Авторство
О чём код?
# Verify Docker API ports and optionally Telegram Bot API (VPN dev, native PowerShell). param( [switch]$Ci ) $ErrorActionPreference = "Stop" $Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path $EnvFile = if ($env:ENV_FILE) { $env:ENV_FILE } else { Join-Path $Root "telegram_bot_service\.env" } function Test-HttpOk { param([string]$Label, [string]$Url, [int]$TimeoutSec = 10) try { $null = Invoke-WebRequest -Uri $Url -UseBasicParsing -TimeoutSec $TimeoutSec -Method Get Write-Host "[OK] $Label ($Url)" return $true } catch { Write-Host "[FAIL] $Label ($Url)" return $false } } function Import-DotEnvFile { param([string]$Path) if (-not (Test-Path $Path)) { return } Get-Content $Path | ForEach-Object { $line = $_.TrimEnd("`r") if ($line -match '^\s*#' -or $line -notmatch '^[A-Za-z_][A-Za-z0-9_]*=') { return } $name, $value = $line -split '=', 2 [System.Environment]::SetEnvironmentVariable($name.Trim(), $value.Trim().Trim('"').Trim("'"), "Process") } } $failed = 0 Write-Host "=== Konstructorium telegram VPN dev checks ===" if (-not (Test-HttpOk "auth_service health" "http://127.0.0.1:8001/api/health/")) { $failed = 1 } if (-not (Test-HttpOk "user_service health" "http://127.0.0.1:8002/api/health/")) { $failed = 1 } if (-not (Test-HttpOk "product_service models" "http://127.0.0.1:8003/api/models/")) { $failed = 1 } if (-not (Test-HttpOk "order_service health" "http://127.0.0.1:8004/api/health/")) { $failed = 1 } if ($Ci) { if ($failed -ne 0) { Write-Host "CI mode: one or more local API checks failed." exit 1 } Write-Host "CI mode: local API checks passed (Telegram skipped)." exit 0 } Import-DotEnvFile $EnvFile $token = $env:TELEGRAM_BOT_TOKEN if (-not $token) { Write-Host "[SKIP] TELEGRAM_BOT_TOKEN not set; Telegram getMe skipped." Write-Host "Set token in telegram_bot_service/.env and enable VPN (or TELEGRAM_PROXY_URL)." if ($failed -ne 0) { exit 1 } exit 0 } $telegramUrl = "https://api.telegram.org/bot$token/getMe" if (Test-HttpOk "Telegram API getMe" $telegramUrl 20) { Write-Host "Telegram route OK (VPN/proxy on host)." } else { Write-Host "[FAIL] Telegram API getMe unreachable." Write-Host " Enable VPN on the host or set TELEGRAM_PROXY_URL in telegram_bot_service/.env" $failed = 1 } if ($failed -ne 0) { exit 1 } Write-Host "All checks passed." exit 0