amangs commited on
Commit
ae9241e
·
verified ·
1 Parent(s): 874a702

Clean config.yaml and make all Telegram settings 100% environment driven

Browse files
Files changed (2) hide show
  1. config/config.yaml +0 -3
  2. entrypoint.sh +31 -1
config/config.yaml CHANGED
@@ -58,9 +58,6 @@ delegation:
58
  platforms:
59
  telegram:
60
  enabled: true
61
- extra:
62
- base_url: "https://tgp.ind.pp.ua/bot"
63
- base_file_url: "https://tgp.ind.pp.ua/file/bot"
64
 
65
  # API Server Configuration (Upstream proxy target for Web UI BFF)
66
  api_server:
 
58
  platforms:
59
  telegram:
60
  enabled: true
 
 
 
61
 
62
  # API Server Configuration (Upstream proxy target for Web UI BFF)
63
  api_server:
entrypoint.sh CHANGED
@@ -142,6 +142,36 @@ MERGE_SCRIPT
142
  rm -f "$RESTORED_CONFIG"
143
  fi
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  # ==================== Base URLs & Runtime Environment ====================
146
  if [ -n "$NVIDIA_API_KEY" ]; then
147
  export NVIDIA_BASE_URL="${NVIDIA_BASE_URL:-https://integrate.api.nvidia.com/v1}"
@@ -167,7 +197,7 @@ PERSISTENT_VARS=(
167
  "MODEL_PROVIDER" "MODEL_NAME" "HERMES_MODEL"
168
  "NVIDIA_API_KEY" "NVIDIA_BASE_URL"
169
  "API_SERVER_KEY" "API_SERVER_ENABLED" "API_SERVER_PORT" "API_SERVER_HOST"
170
- "TELEGRAM_BOT_TOKEN" "TELEGRAM_ALLOWED_USERS" "TELEGRAM_PROXY"
171
  "GATEWAY_ALLOW_ALL_USERS"
172
  "AUTH_TOKEN" "TZ"
173
  )
 
142
  rm -f "$RESTORED_CONFIG"
143
  fi
144
 
145
+ # ==================== Apply Dynamic Telegram Env Vars ====================
146
+ if [ -n "$TELEGRAM_BOT_TOKEN" ]; then
147
+ echo "📲 Configuring Telegram from environment variables..."
148
+ if command -v yq &>/dev/null; then
149
+ yq -i ".platforms.telegram.enabled = true" "$CONFIG_FILE"
150
+ yq -i ".platforms.telegram.token = \"$TELEGRAM_BOT_TOKEN\"" "$CONFIG_FILE"
151
+ if [ -n "$TELEGRAM_ALLOWED_USERS" ]; then
152
+ yq -i ".platforms.telegram.allowed_users = [\"$TELEGRAM_ALLOWED_USERS\"]" "$CONFIG_FILE"
153
+ fi
154
+ if [ -n "$TELEGRAM_BOT_APIBASE" ]; then
155
+ TG_URL="$TELEGRAM_BOT_APIBASE"
156
+ if [[ "$TG_URL" != http* ]]; then
157
+ TG_URL="https://$TG_URL"
158
+ fi
159
+ TG_URL="${TG_URL%/}"
160
+ if [[ "$TG_URL" != */bot ]]; then
161
+ TG_BASE_URL="$TG_URL/bot"
162
+ TG_FILE_URL="$TG_URL/file/bot"
163
+ else
164
+ TG_BASE_URL="$TG_URL"
165
+ TG_FILE_URL="${TG_URL%/bot}/file/bot"
166
+ fi
167
+ echo " ✅ Telegram Base URL: $TG_BASE_URL (resolved from TELEGRAM_BOT_APIBASE)"
168
+ yq -i ".platforms.telegram.extra.base_url = \"$TG_BASE_URL\"" "$CONFIG_FILE"
169
+ yq -i ".platforms.telegram.extra.base_file_url = \"$TG_FILE_URL\"" "$CONFIG_FILE"
170
+ yq -i ".platforms.telegram.base_url = \"$TG_BASE_URL\"" "$CONFIG_FILE"
171
+ fi
172
+ fi
173
+ fi
174
+
175
  # ==================== Base URLs & Runtime Environment ====================
176
  if [ -n "$NVIDIA_API_KEY" ]; then
177
  export NVIDIA_BASE_URL="${NVIDIA_BASE_URL:-https://integrate.api.nvidia.com/v1}"
 
197
  "MODEL_PROVIDER" "MODEL_NAME" "HERMES_MODEL"
198
  "NVIDIA_API_KEY" "NVIDIA_BASE_URL"
199
  "API_SERVER_KEY" "API_SERVER_ENABLED" "API_SERVER_PORT" "API_SERVER_HOST"
200
+ "TELEGRAM_BOT_TOKEN" "TELEGRAM_ALLOWED_USERS" "TELEGRAM_BOT_APIBASE" "TELEGRAM_PROXY"
201
  "GATEWAY_ALLOW_ALL_USERS"
202
  "AUTH_TOKEN" "TZ"
203
  )