#!/usr/bin/env python3 """Print TELEGRAM_* assignments from known VPS env files (stdout only).""" from __future__ import annotations from pathlib import Path WANTED = ( 'TELEGRAM_BOT_TOKEN', 'TELEGRAM_GROUP_CHAT_ID', 'TELEGRAM_GROUP_THREAD_ID', 'TELEGRAM_CHAT_ID', ) PATHS = ( Path('/opt/ghabilee-backend/.env'), Path('/opt/ghabilee/backend/.env'), Path('/opt/ghabilee-admin/.env'), ) def main() -> None: found: dict[str, str] = {} for path in PATHS: if not path.is_file() or path.stat().st_size == 0: continue for raw in path.read_text(encoding='utf-8', errors='replace').splitlines(): line = raw.strip() if not line or line.startswith('#') or '=' not in line: continue key, value = line.split('=', 1) key = key.strip() if key not in WANTED or key in found: continue value = value.strip() if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": value = value[1:-1] value = value.replace('\n', '').replace('\r', '') found[key] = value if 'TELEGRAM_BOT_TOKEN' in found: break for key in WANTED: if key in found and found[key]: print(f'{key}={found[key]}') if __name__ == '__main__': main()