fix(bot): strip html tags for Bale, fallback to direct DB catalogs, align validation strictly with DB schema

This commit is contained in:
2026-09-29 01:49:42 +03:30
parent 17458d8697
commit da68fc683f
6 changed files with 217 additions and 99 deletions
+4 -13
View File
@@ -67,28 +67,19 @@ class BaleClient:
async def send_message(self, chat_id: int, text: str, reply_markup: dict | None = None,
reply_to: int | None = None) -> dict:
payload: dict = {"chat_id": chat_id, "text": text[:4000], "parse_mode": "HTML"}
payload: dict = {"chat_id": chat_id, "text": text[:4000]}
if reply_markup:
payload[REPLY_MARKUP] = reply_markup
if reply_to:
payload["reply_to_message_id"] = reply_to
try:
return await self._call("sendMessage", payload)
except BaleError:
# parse_mode / markup rejection fallback: retry plain, keep the keyboard.
payload.pop("parse_mode", None)
return await self._call("sendMessage", payload)
return await self._call("sendMessage", payload)
async def edit_message_text(self, chat_id: int, message_id: int, text: str,
reply_markup: dict | None = None) -> dict:
payload: dict = {"chat_id": chat_id, "message_id": message_id, "text": text[:4000], "parse_mode": "HTML"}
payload: dict = {"chat_id": chat_id, "message_id": message_id, "text": text[:4000]}
if reply_markup:
payload[REPLY_MARKUP] = reply_markup
try:
return await self._call("editMessageText", payload)
except BaleError:
payload.pop("parse_mode", None)
return await self._call("editMessageText", payload)
return await self._call("editMessageText", payload)
async def delete_message(self, chat_id: int, message_id: int) -> bool:
payload: dict = {"chat_id": chat_id, "message_id": message_id}