agnes-the-ai-analyst/services/telegram_bot/config.py
Vojtech 38f6b639d2
feat(observability): request_id end-to-end + dev debug toolbar + centralized logging (#136)
Cuts release 0.20.0.

## Highlights
- X-Request-ID header on every response + sanitized to [A-Za-z0-9_-] (CRLF log-forging mitigation)
- Error pages (HTML + JSON 500) surface request_id for support tickets
- Dev debug toolbar gated by DEBUG=1 — fastapi-debug-toolbar with custom DuckDBPanel
- Centralized app.logging_config.setup_logging() replaces 23 scattered basicConfig calls
- Telegram bot drops bot.log file — stdout only (BREAKING)

## Devin findings addressed
- BUG_0001: .env.template no longer claims FastAPI debug=True
- BUG_0002: subprocess extractor logs INFO to stderr again
- ANALYSIS_0003: _wants_html no longer matches Accept: */* (curl gets JSON as before)
- BUG on b1c6ee9: HTML 500 page no longer leaks str(exc) in production
- BUG on b13d2fe: 2 CLAUDE.md compliance flags (transform.py + ws_gateway) accepted as scope-limited logging refactor — follow-up to update CLAUDE.md if needed

See CHANGELOG [0.20.0] for full notes.
2026-04-29 22:54:21 +02:00

34 lines
932 B
Python

"""
Configuration for the Telegram notification bot.
All values loaded from environment variables - no hardcoded defaults for secrets.
"""
import os
# Telegram Bot API token (required)
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
# Paths
NOTIFICATIONS_DIR = os.path.join(os.environ.get("DATA_DIR", "/data"), "notifications")
TELEGRAM_USERS_FILE = os.path.join(NOTIFICATIONS_DIR, "telegram_users.json")
PENDING_CODES_FILE = os.path.join(NOTIFICATIONS_DIR, "pending_codes.json")
# Unix socket for internal send API (in /run/notify-bot/, managed by systemd RuntimeDirectory)
SOCKET_PATH = "/run/notify-bot/bot.sock"
# Verification code settings
CODE_LENGTH = 6
CODE_TTL_SECONDS = 600 # 10 minutes
# Telegram polling
POLL_TIMEOUT_SECONDS = 30
POLL_ERROR_RETRY_SECONDS = 5
# Send API
MAX_MESSAGE_LENGTH = 4096
MAX_CAPTION_LENGTH = 1024
# Script execution (for /status run buttons)
SCRIPT_TIMEOUT_SECONDS = 60