Skip to content

Commit 86519d1

Browse files
committed
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.
1 parent c132621 commit 86519d1

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

mtproxymax.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ secret_rotate() {
15351535

15361536
# Notify via Telegram if enabled
15371537
if [ "$TELEGRAM_ENABLED" = "true" ] && [ -n "$TELEGRAM_BOT_TOKEN" ] && [ -n "$TELEGRAM_CHAT_ID" ]; then
1538-
local msg="🔄 *Secret Rotated*\n\nLabel: \`${label}\`\n\n🔗 New link:\n\`tg://proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}\`"
1538+
local msg="🔄 *Secret Rotated*\n\nLabel: \`${label}\`\n📡 Server: \`${server_ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${full_secret}\`"
15391539
telegram_send_message "$msg" &>/dev/null &
15401540
fi
15411541
}
@@ -2773,35 +2773,31 @@ telegram_notify_proxy_started() {
27732773
server_ip=$(get_public_ip)
27742774
[ -z "$server_ip" ] && return 1
27752775

2776-
# Build message with all enabled secrets
2776+
# Build message with all enabled secrets (split details — no full proxy URLs)
27772777
local msg="📱 *MTProxy Started*\n\n"
2778-
local i
2778+
local i _first_secret=""
27792779
for i in "${!SECRETS_LABELS[@]}"; do
27802780
[ "${SECRETS_ENABLED[$i]}" = "true" ] || continue
27812781
local full_secret
27822782
full_secret=$(build_faketls_secret "${SECRETS_KEYS[$i]}")
2783-
local tg_link="tg://proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}"
2784-
local https_link="https://t.me/proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret}"
2783+
[ -z "$_first_secret" ] && _first_secret="$full_secret"
27852784
msg+="🏷 *${SECRETS_LABELS[$i]}*\n"
2786-
msg+="🔗 \`${tg_link}\`\n"
2787-
msg+="🌐 ${https_link}\n\n"
2785+
msg+="📡 Server: \`${server_ip}\`\n"
2786+
msg+="🔌 Port: \`${PROXY_PORT}\`\n"
2787+
msg+="🔑 Secret: \`${full_secret}\`\n\n"
27882788
done
27892789

27902790
msg+="📊 Port: ${PROXY_PORT} | Domain: ${PROXY_DOMAIN}\n"
2791-
msg+="_Share the QR code below with users who need access._"
2791+
msg+="_Scan the QR code below to connect._"
27922792

27932793
telegram_send_message "$msg"
27942794

27952795
# Send QR for first enabled secret
2796-
for i in "${!SECRETS_LABELS[@]}"; do
2797-
[ "${SECRETS_ENABLED[$i]}" = "true" ] || continue
2798-
local https_link
2799-
https_link=$(get_proxy_link_https "${SECRETS_LABELS[$i]}")
2796+
if [ -n "$_first_secret" ]; then
28002797
local qr_url
2801-
qr_url=$(generate_qr_url "$https_link")
2798+
qr_url=$(generate_qr_url "https://t.me/proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${_first_secret}")
28022799
telegram_send_photo "$qr_url" "📱 *MTProxy QR Code* — Scan in Telegram to connect"
2803-
break
2804-
done
2800+
fi
28052801
}
28062802

28072803
telegram_setup_wizard() {
@@ -2991,6 +2987,14 @@ tg_send_photo() {
29912987
rm -f "$_cfg"
29922988
}
29932989
2990+
# Send QR code image for a proxy secret (no text URL — avoids Telegram bot bans)
2991+
send_proxy_qr() {
2992+
local ip="$1" port="$2" secret="$3" caption="${4:-Scan in Telegram to connect}"
2993+
local hl="https://t.me/proxy?server=${ip}&port=${port}&secret=${secret}"
2994+
local el=$(printf '%s' "$hl" | sed 's/&/%26/g;s/?/%3F/g;s/=/%3D/g;s/:/%3A/g;s|/|%2F|g')
2995+
tg_send_photo "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${el}" "$caption"
2996+
}
2997+
29942998
# Escape Markdown special chars in labels for Telegram
29952999
_esc() { local t="$1"; t="${t//_/\\_}"; t="${t//\*/\\*}"; t="${t//\`/\\\`}"; echo "$t"; }
29963000
@@ -3220,26 +3224,20 @@ _process_cmd() {
32203224
load_tg_settings
32213225
local ip; ip=$(get_cached_ip)
32223226
[ -z "$ip" ] && tg_send "❌ Cannot detect server IP" && return
3223-
local msg="🔗 *Proxy Links*\n\n"
3227+
local msg="🔗 *Proxy Details*\n\n"
3228+
local _first_fs=""
32243229
while IFS='|' read -r label secret created enabled _mc _mi _q _ex; do
32253230
[[ "$label" =~ ^# ]] && continue
32263231
[ -z "$secret" ] && continue
32273232
[ "$enabled" != "true" ] && continue
32283233
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
32293234
local fs="ee${secret}${dh}"
3230-
msg+="🏷 *$(_esc "$label")*\n\`tg://proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}\`\n\n"
3235+
[ -z "$_first_fs" ] && _first_fs="$fs"
3236+
msg+="🏷 *$(_esc "$label")*\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`\n\n"
32313237
done < "$SECRETS_FILE"
32323238
tg_send "$msg"
3233-
# Send QR for first
3234-
while IFS='|' read -r label secret created enabled _mc _mi _q _ex; do
3235-
[[ "$label" =~ ^# ]] && continue; [ -z "$secret" ] && continue; [ "$enabled" != "true" ] && continue
3236-
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
3237-
local fs="ee${secret}${dh}"
3238-
local hl="https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}"
3239-
local el=$(printf '%s' "$hl" | sed 's/&/%26/g;s/?/%3F/g;s/=/%3D/g;s/:/%3A/g;s|/|%2F|g')
3240-
tg_send_photo "https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${el}" "📱 Scan in Telegram"
3241-
break
3242-
done < "$SECRETS_FILE"
3239+
# Send QR for first enabled secret
3240+
[ -n "$_first_fs" ] && send_proxy_qr "$ip" "$PROXY_PORT" "$_first_fs"
32433241
;;
32443242
/mp_add\ *|/mp_add@*\ *)
32453243
local label=$(echo "$text" | awk '{print $2}')
@@ -3252,7 +3250,8 @@ _process_cmd() {
32523250
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
32533251
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
32543252
local fs="ee${ns}${dh}"
3255-
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}"
3253+
tg_send "✅ Secret *$(_esc "$label")* created!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
3254+
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
32563255
else
32573256
tg_send "❌ Failed to add secret '$(_esc "$label")' (may already exist)"
32583257
fi
@@ -3290,7 +3289,8 @@ _process_cmd() {
32903289
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
32913290
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
32923291
local fs="ee${ns}${dh}"
3293-
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n🔗 New link:\n\`tg://proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs}\`"
3292+
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
3293+
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
32943294
else
32953295
tg_send "❌ Secret '$(_esc "$label")' not found"
32963296
fi

0 commit comments

Comments
 (0)