Remove proxy URLs from bot messages to prevent Telegram bans
Send split details (server/port/secret) + QR images instead of tg://proxy and t.me/proxy links that trigger auto-detection.
This commit is contained in:
@@ -1535,7 +1535,7 @@ secret_rotate() {
|
|||||||
|
|
||||||
# Notify via Telegram if enabled
|
# Notify via Telegram if enabled
|
||||||
if [ "$TELEGRAM_ENABLED" = "true" ] && [ -n "$TELEGRAM_BOT_TOKEN" ] && [ -n "$TELEGRAM_CHAT_ID" ]; then
|
if [ "$TELEGRAM_ENABLED" = "true" ] && [ -n "$TELEGRAM_BOT_TOKEN" ] && [ -n "$TELEGRAM_CHAT_ID" ]; then
|
||||||
local msg="🔄 *Secret Rotated*\n\nLabel: \`${label}\`\n\n🔗 New link:\n\`tg://proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}\`"
|
local msg="🔄 *Secret Rotated*\n\nLabel: \`${label}\`\n📡 Server: \`${server_ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${full_secret}\`"
|
||||||
telegram_send_message "$msg" &>/dev/null &
|
telegram_send_message "$msg" &>/dev/null &
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -2773,35 +2773,31 @@ telegram_notify_proxy_started() {
|
|||||||
server_ip=$(get_public_ip)
|
server_ip=$(get_public_ip)
|
||||||
[ -z "$server_ip" ] && return 1
|
[ -z "$server_ip" ] && return 1
|
||||||
|
|
||||||
# Build message with all enabled secrets
|
# Build message with all enabled secrets (split details — no full proxy URLs)
|
||||||
local msg="📱 *MTProxy Started*\n\n"
|
local msg="📱 *MTProxy Started*\n\n"
|
||||||
local i
|
local i _first_secret=""
|
||||||
for i in "${!SECRETS_LABELS[@]}"; do
|
for i in "${!SECRETS_LABELS[@]}"; do
|
||||||
[ "${SECRETS_ENABLED[$i]}" = "true" ] || continue
|
[ "${SECRETS_ENABLED[$i]}" = "true" ] || continue
|
||||||
local full_secret
|
local full_secret
|
||||||
full_secret=$(build_faketls_secret "${SECRETS_KEYS[$i]}")
|
full_secret=$(build_faketls_secret "${SECRETS_KEYS[$i]}")
|
||||||
local tg_link="tg://proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}"
|
[ -z "$_first_secret" ] && _first_secret="$full_secret"
|
||||||
local https_link="https://t.me/proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}"
|
|
||||||
msg+="🏷 *${SECRETS_LABELS[$i]}*\n"
|
msg+="🏷 *${SECRETS_LABELS[$i]}*\n"
|
||||||
msg+="🔗 \`${tg_link}\`\n"
|
msg+="📡 Server: \`${server_ip}\`\n"
|
||||||
msg+="🌐 ${https_link}\n\n"
|
msg+="🔌 Port: \`${PROXY_PORT}\`\n"
|
||||||
|
msg+="🔑 Secret: \`${full_secret}\`\n\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
msg+="📊 Port: ${PROXY_PORT} | Domain: ${PROXY_DOMAIN}\n"
|
msg+="📊 Port: ${PROXY_PORT} | Domain: ${PROXY_DOMAIN}\n"
|
||||||
msg+="_Share the QR code below with users who need access._"
|
msg+="_Scan the QR code below to connect._"
|
||||||
|
|
||||||
telegram_send_message "$msg"
|
telegram_send_message "$msg"
|
||||||
|
|
||||||
# Send QR for first enabled secret
|
# Send QR for first enabled secret
|
||||||
for i in "${!SECRETS_LABELS[@]}"; do
|
if [ -n "$_first_secret" ]; then
|
||||||
[ "${SECRETS_ENABLED[$i]}" = "true" ] || continue
|
|
||||||
local https_link
|
|
||||||
https_link=$(get_proxy_link_https "${SECRETS_LABELS[$i]}")
|
|
||||||
local qr_url
|
local qr_url
|
||||||
qr_url=$(generate_qr_url "$https_link")
|
qr_url=$(generate_qr_url "https://t.me/proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${_first_secret}")
|
||||||
telegram_send_photo "$qr_url" "📱 *MTProxy QR Code* — Scan in Telegram to connect"
|
telegram_send_photo "$qr_url" "📱 *MTProxy QR Code* — Scan in Telegram to connect"
|
||||||
break
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
telegram_setup_wizard() {
|
telegram_setup_wizard() {
|
||||||
@@ -2991,6 +2987,14 @@ tg_send_photo() {
|
|||||||
rm -f "$_cfg"
|
rm -f "$_cfg"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Send QR code image for a proxy secret (no text URL — avoids Telegram bot bans)
|
||||||
|
send_proxy_qr() {
|
||||||
|
local ip="$1" port="$2" secret="$3" caption="${4:-Scan in Telegram to connect}"
|
||||||
|
local hl="https://t.me/proxy?server=${ip}&port=${port}&secret=${secret}"
|
||||||
|
local el=$(printf '%s' "$hl" | sed 's/&/%26/g;s/?/%3F/g;s/=/%3D/g;s/:/%3A/g;s|/|%2F|g')
|
||||||
|
tg_send_photo "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${el}" "$caption"
|
||||||
|
}
|
||||||
|
|
||||||
# Escape Markdown special chars in labels for Telegram
|
# Escape Markdown special chars in labels for Telegram
|
||||||
_esc() { local t="$1"; t="${t//_/\\_}"; t="${t//\*/\\*}"; t="${t//\`/\\\`}"; echo "$t"; }
|
_esc() { local t="$1"; t="${t//_/\\_}"; t="${t//\*/\\*}"; t="${t//\`/\\\`}"; echo "$t"; }
|
||||||
|
|
||||||
@@ -3220,26 +3224,20 @@ _process_cmd() {
|
|||||||
load_tg_settings
|
load_tg_settings
|
||||||
local ip; ip=$(get_cached_ip)
|
local ip; ip=$(get_cached_ip)
|
||||||
[ -z "$ip" ] && tg_send "❌ Cannot detect server IP" && return
|
[ -z "$ip" ] && tg_send "❌ Cannot detect server IP" && return
|
||||||
local msg="🔗 *Proxy Links*\n\n"
|
local msg="🔗 *Proxy Details*\n\n"
|
||||||
|
local _first_fs=""
|
||||||
while IFS='|' read -r label secret created enabled _mc _mi _q _ex; do
|
while IFS='|' read -r label secret created enabled _mc _mi _q _ex; do
|
||||||
[[ "$label" =~ ^# ]] && continue
|
[[ "$label" =~ ^# ]] && continue
|
||||||
[ -z "$secret" ] && continue
|
[ -z "$secret" ] && continue
|
||||||
[ "$enabled" != "true" ] && continue
|
[ "$enabled" != "true" ] && continue
|
||||||
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
||||||
local fs="ee${secret}${dh}"
|
local fs="ee${secret}${dh}"
|
||||||
msg+="🏷 *$(_esc "$label")*\n\`tg://proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}\`\n\n"
|
[ -z "$_first_fs" ] && _first_fs="$fs"
|
||||||
|
msg+="🏷 *$(_esc "$label")*\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`\n\n"
|
||||||
done < "$SECRETS_FILE"
|
done < "$SECRETS_FILE"
|
||||||
tg_send "$msg"
|
tg_send "$msg"
|
||||||
# Send QR for first
|
# Send QR for first enabled secret
|
||||||
while IFS='|' read -r label secret created enabled _mc _mi _q _ex; do
|
[ -n "$_first_fs" ] && send_proxy_qr "$ip" "$PROXY_PORT" "$_first_fs"
|
||||||
[[ "$label" =~ ^# ]] && continue; [ -z "$secret" ] && continue; [ "$enabled" != "true" ] && continue
|
|
||||||
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
|
||||||
local fs="ee${secret}${dh}"
|
|
||||||
local hl="https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}"
|
|
||||||
local el=$(printf '%s' "$hl" | sed 's/&/%26/g;s/?/%3F/g;s/=/%3D/g;s/:/%3A/g;s|/|%2F|g')
|
|
||||||
tg_send_photo "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${el}" "📱 Scan in Telegram"
|
|
||||||
break
|
|
||||||
done < "$SECRETS_FILE"
|
|
||||||
;;
|
;;
|
||||||
/mp_add\ *|/mp_add@*\ *)
|
/mp_add\ *|/mp_add@*\ *)
|
||||||
local label=$(echo "$text" | awk '{print $2}')
|
local label=$(echo "$text" | awk '{print $2}')
|
||||||
@@ -3252,7 +3250,8 @@ _process_cmd() {
|
|||||||
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
|
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
|
||||||
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
||||||
local fs="ee${ns}${dh}"
|
local fs="ee${ns}${dh}"
|
||||||
tg_send "✅ Secret *$(_esc "$label")* created!\n\n🔗 \`tg://proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}\`\n\n🌐 https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}"
|
tg_send "✅ Secret *$(_esc "$label")* created!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
|
||||||
|
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
|
||||||
else
|
else
|
||||||
tg_send "❌ Failed to add secret '$(_esc "$label")' (may already exist)"
|
tg_send "❌ Failed to add secret '$(_esc "$label")' (may already exist)"
|
||||||
fi
|
fi
|
||||||
@@ -3290,7 +3289,8 @@ _process_cmd() {
|
|||||||
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
|
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
|
||||||
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
|
||||||
local fs="ee${ns}${dh}"
|
local fs="ee${ns}${dh}"
|
||||||
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n🔗 New link:\n\`tg://proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}\`"
|
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
|
||||||
|
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
|
||||||
else
|
else
|
||||||
tg_send "❌ Secret '$(_esc "$label")' not found"
|
tg_send "❌ Secret '$(_esc "$label")' not found"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user