From caf0a048b7161622cfef2324d424920ad4c99b78 Mon Sep 17 00:00:00 2001
From: Sergey
Date: Mon, 18 May 2026 13:08:56 +0700
Subject: [PATCH] =?UTF-8?q?fix:=20MAX=20API=20chat=5Fid=20=D0=BF=D0=B5?=
=?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D1=91=D1=82=D1=81=D1=8F=20=D0=BA=D0=B0?=
=?UTF-8?q?=D0=BA=20query-=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
monitor.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/monitor.py b/monitor.py
index 02ebe2e..72fe970 100644
--- a/monitor.py
+++ b/monitor.py
@@ -72,18 +72,23 @@ async def send_max(message: str) -> None:
"""Отправляет уведомление в MAX (VK Teams)."""
if not MAX_BOT_TOKEN or not MAX_CHAT_ID:
return
- url = f"{MAX_API_URL}/messages"
+ import re
+ # chat_id и user_id — query-параметры, не тело запроса
+ params = {"chat_id": MAX_CHAT_ID}
headers = {
"Authorization": MAX_BOT_TOKEN,
"Content-Type": "application/json",
}
- # MAX не поддерживает HTML-теги — убираем их
- import re
- clean = re.sub(r"<[^>]+>", "", message)
- payload = {"chat_id": int(MAX_CHAT_ID), "text": clean}
+ # MAX поддерживает HTML — оставляем форматирование
+ payload = {"text": message, "format": "html"}
async with httpx.AsyncClient(timeout=10) as client:
try:
- resp = await client.post(url, headers=headers, json=payload)
+ resp = await client.post(
+ f"{MAX_API_URL}/messages",
+ headers=headers,
+ params=params,
+ json=payload,
+ )
log.info("MAX response %s: %s", resp.status_code, resp.text)
resp.raise_for_status()
log.info("MAX: сообщение отправлено")