Fix: convert \n to real newlines in all Telegram bot messages

Made-with: Cursor
This commit is contained in:
anten-ka
2026-03-05 18:05:09 +03:00
parent 60a4715603
commit 0aef390214

View File

@@ -532,12 +532,11 @@ monitor_alert() {
if [ -n "${BOT_TOKEN:-}" ] && [ -n "${BOT_CHAT_ID:-}" ]; then
local text
if [ "$ping_ms" = "TIMEOUT" ]; then
text="⚠️ <b>ALERT</b>: ${ip}%0APing: TIMEOUT (порог: ${threshold}ms)"
text="⚠️ <b>ALERT</b>: ${ip}\nPing: TIMEOUT (порог: ${threshold}ms)"
else
text="⚠️ <b>ALERT</b>: ${ip}%0APing: ${ping_ms}ms (порог: ${threshold}ms)"
text="⚠️ <b>ALERT</b>: ${ip}\nPing: ${ping_ms}ms (порог: ${threshold}ms)"
fi
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
-d "chat_id=${BOT_CHAT_ID}&text=${text}&parse_mode=HTML" > /dev/null 2>&1
tg_send "$BOT_CHAT_ID" "$text" "" > /dev/null 2>&1
fi
}
@@ -703,7 +702,8 @@ tg_api() {
}
tg_send() {
local chat_id="$1" text="$2" keyboard="${3:-}"
local chat_id="$1" text keyboard="${3:-}"
text=$(printf '%b' "$2")
local payload
if [ -n "$keyboard" ]; then
payload=$(jq -n --arg c "$chat_id" --arg t "$text" --argjson k "$keyboard" \
@@ -716,7 +716,8 @@ tg_send() {
}
tg_edit() {
local chat_id="$1" msg_id="$2" text="$3" keyboard="${4:-}"
local chat_id="$1" msg_id="$2" text keyboard="${4:-}"
text=$(printf '%b' "$3")
local payload
if [ -n "$keyboard" ]; then
payload=$(jq -n --arg c "$chat_id" --argjson m "$msg_id" --arg t "$text" --argjson k "$keyboard" \