42 lines
1.2 KiB
PowerShell
42 lines
1.2 KiB
PowerShell
param(
|
|
[string]$BindHost = "127.0.0.1",
|
|
[int]$Port = 8000
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-RepoRoot {
|
|
param([string]$ScriptPath)
|
|
$scriptsFolder = Split-Path -Parent $ScriptPath
|
|
return Resolve-Path (Join-Path $scriptsFolder "..")
|
|
}
|
|
|
|
$repoRoot = Resolve-RepoRoot -ScriptPath $MyInvocation.MyCommand.Path
|
|
Set-Location $repoRoot
|
|
|
|
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
|
|
throw "Python is required on PATH to run this project locally."
|
|
}
|
|
|
|
$dataDir = Join-Path $repoRoot "data"
|
|
if (-not (Test-Path $dataDir)) {
|
|
New-Item -ItemType Directory -Path $dataDir | Out-Null
|
|
}
|
|
|
|
if (-not $env:TELEGRAM_SESSION_PATH) {
|
|
$env:TELEGRAM_SESSION_PATH = Join-Path $dataDir "telegram.session"
|
|
}
|
|
|
|
if (-not $env:DATABASE_PATH) {
|
|
$env:DATABASE_PATH = Join-Path $dataDir "hooks.json"
|
|
}
|
|
|
|
Write-Host "Starting Telegram Message Hook locally..." -ForegroundColor Cyan
|
|
Write-Host ("API listening on http://{0}:{1}" -f $BindHost, $Port) -ForegroundColor Green
|
|
Write-Host "Session file: $($env:TELEGRAM_SESSION_PATH)" -ForegroundColor DarkGray
|
|
Write-Host "Database file: $($env:DATABASE_PATH)" -ForegroundColor DarkGray
|
|
|
|
$uvicornArgs = @("app.main:app", "--host", $BindHost, "--port", $Port, "--reload")
|
|
|
|
python -m uvicorn @uvicornArgs
|