Remove env file support from monitoring TG
This commit is contained in:
47
.env.example
47
.env.example
@@ -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
|
|
||||||
26
README.md
26
README.md
@@ -23,29 +23,9 @@ MTProto/Telethon-адаптер для авторизации, опроса ка
|
|||||||
|
|
||||||
## Конфигурация
|
## Конфигурация
|
||||||
|
|
||||||
Основные переменные:
|
Сервис рассчитан на запуск только в k8s. Настройки хранятся в
|
||||||
|
`k8s/configmap.yaml`, секреты — в `k8s/secrets.yaml`. Локальный `.env` не
|
||||||
```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
|
|
||||||
```
|
|
||||||
|
|
||||||
Локального админ-пароля нет: админские API доступны только через роль `admin`
|
Локального админ-пароля нет: админские API доступны только через роль `admin`
|
||||||
в Portal.
|
в Portal.
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ dependencies = [
|
|||||||
"apscheduler>=3.10",
|
"apscheduler>=3.10",
|
||||||
"pydantic>=2.9",
|
"pydantic>=2.9",
|
||||||
"pydantic-settings>=2.6",
|
"pydantic-settings>=2.6",
|
||||||
"python-dotenv>=1.0",
|
|
||||||
"structlog>=24.4",
|
"structlog>=24.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Interactive Telethon login. Run once on a dev machine, copy the printed
|
"""Interactive Telethon login. Run once on a dev machine, copy the printed
|
||||||
TG_SESSION_STRING into your .env / k8s Secret, then deploy without ever
|
TG_SESSION_STRING into k8s/secrets.yaml, then deploy without ever touching
|
||||||
touching auth again.
|
auth again.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python -m parser_bot.auth
|
python -m parser_bot.auth
|
||||||
@@ -36,7 +36,7 @@ async def main() -> int:
|
|||||||
print()
|
print()
|
||||||
print(f"authorized as {me.username or me.id}")
|
print(f"authorized as {me.username or me.id}")
|
||||||
print()
|
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()
|
||||||
print(f"TG_SESSION_STRING={session_str}")
|
print(f"TG_SESSION_STRING={session_str}")
|
||||||
print()
|
print()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
|||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
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_id: int = Field(..., alias="TG_API_ID")
|
||||||
tg_api_hash: str = Field(..., alias="TG_API_HASH")
|
tg_api_hash: str = Field(..., alias="TG_API_HASH")
|
||||||
|
|||||||
Reference in New Issue
Block a user