From ddc41779d0e78098056cee75204e23266e38e55a Mon Sep 17 00:00:00 2001 From: Oleg Proskurin Date: Mon, 8 Jun 2026 01:53:57 +0700 Subject: [PATCH] tune scripts --- scripts/telegram-mcp.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/telegram-mcp.sh b/scripts/telegram-mcp.sh index 3866c62..cf66dad 100755 --- a/scripts/telegram-mcp.sh +++ b/scripts/telegram-mcp.sh @@ -17,12 +17,23 @@ PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" [ -f "$PROJECT_ROOT/.env" ] || { echo "missing $PROJECT_ROOT/.env (copy .env.example and fill it in)" >&2; exit 1; } set -a; . "$PROJECT_ROOT/.env"; set +a +# Pick the session string for the requested account, then aggressively drop all +# suffixed TELEGRAM_SESSION_STRING_* vars from the environment so telegram-mcp's +# auto-discovery (runtime.py: _discover_accounts) does NOT load the other +# account as a secondary client on this server. Each MCP server must expose +# exactly one identity = "default". case "$ACCOUNT" in - usulsu) export TELEGRAM_SESSION_STRING="${TELEGRAM_SESSION_STRING:-}" ;; - helper) export TELEGRAM_SESSION_STRING="${TELEGRAM_SESSION_STRING_HELPER:-}" ;; + usulsu) SESSION="${TELEGRAM_SESSION_STRING:-}" ;; + helper) SESSION="${TELEGRAM_SESSION_STRING_HELPER:-}" ;; *) echo "account must be 'usulsu' or 'helper'" >&2; exit 1 ;; esac +while IFS='=' read -r name _; do + case "$name" in TELEGRAM_SESSION_STRING_*|TELEGRAM_SESSION_NAME_*) unset "$name" ;; esac +done < <(env) + +export TELEGRAM_SESSION_STRING="$SESSION" + if [ -z "${TELEGRAM_API_ID:-}" ] || [ -z "${TELEGRAM_API_HASH:-}" ]; then echo "TELEGRAM_API_ID / TELEGRAM_API_HASH missing in $PROJECT_ROOT/.env" >&2 exit 1