Skip to content

Commit 5078b0d

Browse files
committed
Fix Telegram bot: grep invalid option on chat ID, fix Markdown escaping (#58)
1 parent 6d47a9f commit 5078b0d

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

mtproxymax.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,6 @@ escape_md() {
423423
text="${text//\*/\\*}"
424424
text="${text//_/\\_}"
425425
text="${text//\`/\\\`}"
426-
text="${text//\[/\\[}"
427-
text="${text//\]/\\]}"
428426
echo "$text"
429427
}
430428

@@ -3525,7 +3523,7 @@ except: pass
35253523

35263524
# Fallback: grep
35273525
if [ -z "$chat_id" ]; then
3528-
chat_id=$(echo "$response" | grep -oE '"chat"\s*:\s*\{[^}]*"id"\s*:\s*(-?[0-9]+)' | head -1 | grep -oE '-?[0-9]+$')
3526+
chat_id=$(echo "$response" | grep -oE '"chat"\s*:\s*\{[^}]*"id"\s*:\s*(-?[0-9]+)' | head -1 | grep -oE -- '-?[0-9]+$')
35293527
fi
35303528

35313529
if [ -n "$chat_id" ]; then
@@ -3974,7 +3972,7 @@ except: pass
39743972
fi
39753973
local _text _cid
39763974
_text=$(echo "$updates" | grep -oE '"text"\s*:\s*"[^"]*"' | tail -1 | sed 's/.*"text"\s*:\s*"//;s/"$//')
3977-
_cid=$(echo "$updates" | grep -oE '"chat"\s*:\s*\{[^}]*"id"\s*:\s*-?[0-9]+' | tail -1 | grep -oE '-?[0-9]+$')
3975+
_cid=$(echo "$updates" | grep -oE '"chat"\s*:\s*\{[^}]*"id"\s*:\s*-?[0-9]+' | tail -1 | grep -oE -- '-?[0-9]+$')
39783976
[ -n "$_text" ] && [ -n "$_cid" ] && [ "$_cid" = "$TELEGRAM_CHAT_ID" ] && {
39793977
_new_offset=${_new_offset:-0}
39803978
_process_cmd "$_new_offset" "$_cid" "$_text"

0 commit comments

Comments
 (0)