From a385f70906a74ebfec750d90a4c7d71462c9b59e Mon Sep 17 00:00:00 2001 From: Grendgi Date: Thu, 4 Jun 2026 16:14:12 +0300 Subject: [PATCH] Remove env file support from monitoring TG --- .env.example | 47 ---------------------------------------- README.md | 26 +++------------------- pyproject.toml | 1 - src/parser_bot/auth.py | 6 ++--- src/parser_bot/config.py | 2 +- 5 files changed, 7 insertions(+), 75 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 34b1e05..0000000 --- a/.env.example +++ /dev/null @@ -1,47 +0,0 @@ -# Telegram MTProto credentials — get from https://my.telegram.org -TG_API_ID= -TG_API_HASH= -TG_PHONE= - -# --- ONE OF THE TWO BELOW IS REQUIRED --- -# Preferred (no volumes, k8s-friendly): get the string by running -# docker compose run --rm -it app python -m parser_bot.auth -# It prints `TG_SESSION_STRING=...` — paste that line here. -TG_SESSION_STRING= - -# Fallback (file-based): only used if TG_SESSION_STRING is empty. -# Requires mounting ./data/session as a volume. -TG_SESSION_PATH=/data/session/parser.session - -# Postgres -POSTGRES_USER=parser -POSTGRES_PASSWORD=parser -POSTGRES_DB=parser -POSTGRES_HOST=db -POSTGRES_PORT=5432 - -# Polling -POLL_INTERVAL_SECONDS=60 -POLL_HISTORY_LIMIT=50 - -# Go public API -API_HOST=0.0.0.0 -API_PORT=8000 -PUBLIC_BASE_PATH=/api/monitoring-tg -PYTHON_BASE_URL=http://127.0.0.1:8001 - -# Media (downloaded photos / small videos / docs from parsed messages) -MEDIA_DIR=/data/media -MEDIA_MAX_BYTES=20971520 - -# OpenAI-compatible LLM endpoint used by the Go classifier. -LLM_ENABLED=true -LLM_BASE_URL=http://10.2.3.5:8002 -LLM_API_KEY= -LLM_MODEL=qwen2.5-14b -LLM_TIMEOUT_SECONDS=120 -LLM_MAX_TOKENS=600 -LLM_MIN_TEXT_LENGTH=20 -LLM_CLASSIFIER_OWNER=go -LLM_CLASSIFY_INTERVAL_SECONDS=20 -LLM_CLASSIFY_BATCH_SIZE=5 diff --git a/README.md b/README.md index 114038b..252cbf6 100644 --- a/README.md +++ b/README.md @@ -23,29 +23,9 @@ MTProto/Telethon-адаптер для авторизации, опроса ка ## Конфигурация -Основные переменные: - -```env -TG_API_ID= -TG_API_HASH= -TG_PHONE= -TG_SESSION_STRING= - -POSTGRES_HOST=postgres.monitoring-tg.svc.cluster.local -POSTGRES_PORT=5432 -POSTGRES_USER=parser -POSTGRES_PASSWORD=parser -POSTGRES_DB=parser - -PUBLIC_BASE_PATH=/api/monitoring-tg -PYTHON_BASE_URL=http://127.0.0.1:8001 - -LLM_ENABLED=true -LLM_BASE_URL=http://10.2.3.5:8002 -LLM_API_KEY= -LLM_MODEL=qwen2.5-14b -LLM_CLASSIFIER_OWNER=go -``` +Сервис рассчитан на запуск только в k8s. Настройки хранятся в +`k8s/configmap.yaml`, секреты — в `k8s/secrets.yaml`. Локальный `.env` не +используется. Локального админ-пароля нет: админские API доступны только через роль `admin` в Portal. diff --git a/pyproject.toml b/pyproject.toml index fcdaeb2..0c3a479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ dependencies = [ "apscheduler>=3.10", "pydantic>=2.9", "pydantic-settings>=2.6", - "python-dotenv>=1.0", "structlog>=24.4", ] diff --git a/src/parser_bot/auth.py b/src/parser_bot/auth.py index dce24dd..a8aabd4 100644 --- a/src/parser_bot/auth.py +++ b/src/parser_bot/auth.py @@ -1,6 +1,6 @@ """Interactive Telethon login. Run once on a dev machine, copy the printed -TG_SESSION_STRING into your .env / k8s Secret, then deploy without ever -touching auth again. +TG_SESSION_STRING into k8s/secrets.yaml, then deploy without ever touching +auth again. Usage: python -m parser_bot.auth @@ -36,7 +36,7 @@ async def main() -> int: print() print(f"authorized as {me.username or me.id}") print() - print("Add this line to your .env (or k8s Secret) and never share it:") + print("Add this value to k8s/secrets.yaml as TG_SESSION_STRING and never share it:") print() print(f"TG_SESSION_STRING={session_str}") print() diff --git a/src/parser_bot/config.py b/src/parser_bot/config.py index 3e26059..1322583 100644 --- a/src/parser_bot/config.py +++ b/src/parser_bot/config.py @@ -3,7 +3,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): - model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") + model_config = SettingsConfigDict(extra="ignore") tg_api_id: int = Field(..., alias="TG_API_ID") tg_api_hash: str = Field(..., alias="TG_API_HASH")