fix: prevent 'caption is too long' error in logo mode

Telegram limits photo captions to 1024 characters. When menu_text or
rules_text exceeds 900 chars (with promo hints, random messages etc),
bot.send_photo fails with TelegramBadRequest.

Added len() check before each of 3 send_photo calls in
required_sub_channel_check — falls back to send_message when text
is too long, consistent with _answer_with_photo in message_patch.py.
This commit is contained in:
Fringg
2026-02-18 18:26:26 +03:00
parent d651a6c02f
commit 6e28a1a22b

View File

@@ -1989,7 +1989,7 @@ async def required_sub_channel_check(
custom_buttons=custom_buttons,
)
if settings.ENABLE_LOGO_MODE:
if settings.ENABLE_LOGO_MODE and len(menu_text) <= 900:
_result = await bot.send_photo(
chat_id=query.from_user.id,
photo=get_logo_media(),
@@ -2082,7 +2082,7 @@ async def required_sub_channel_check(
custom_buttons=custom_buttons,
)
if settings.ENABLE_LOGO_MODE:
if settings.ENABLE_LOGO_MODE and len(menu_text) <= 900:
_result = await bot.send_photo(
chat_id=query.from_user.id,
photo=get_logo_media(),
@@ -2112,7 +2112,7 @@ async def required_sub_channel_check(
else:
rules_text = await get_rules(language)
if settings.ENABLE_LOGO_MODE:
if settings.ENABLE_LOGO_MODE and len(rules_text) <= 900:
_result = await bot.send_photo(
chat_id=query.from_user.id,
photo=get_logo_media(),