INNER CODE UNIT · Python
_read_tg_bot_username
browser-use/bux · agent/box_agent.py:102
def _read_tg_bot_username() -> str | None:
"""Read TG_BOT_USERNAME from /etc/bux/tg.env if present.
The file is root:bux 0640; box-agent runs as bux which is in the bux
group, so the read works without sudo. Returns None when bux-tg
isn't set up yet (no tg.env), or when the file exists but doesn't
carry TG_BOT_USERNAME (older installs that pre-date this field —
the user can re-Set up Telegram to populate it).
Surfaced in the hello payload so the cloud can backfill its
tg_bot_username column for boxes provisioned before
install_telegram() started persisting it server-side.
"""
if not TG_ENV.exists():
return None
try:
for line in TG_ENV.read_text().splitlines():
line = line.strip()