From b41f900feded803bf033a0fbd3d85f7c542b0e08 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Thu, 22 Oct 2026 12:47:33 +0000 Subject: [PATCH] =?UTF-8?q?fix(bot):=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B2=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B8=20=D0=BA=20=D0=B2=D0=B8=D0=B4=D0=B5?= =?UTF-8?q?=D0=BE=20=D1=81=D0=B0=D0=BC=D1=83=20=D1=81=D1=81=D1=8B=D0=BB?= =?UTF-8?q?=D0=BA=D1=83,=20=D0=B0=20=D0=BD=D0=B5=20=D1=81=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=20=C2=AB=D0=98=D1=81=D1=82=D0=BE=D1=87=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- bot.py | 6 +++--- tests/test_bot_pure.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index fc31134..a9c5afe 100644 --- a/bot.py +++ b/bot.py @@ -94,7 +94,7 @@ TEXTS = { 'downloading': "⬇️ Скачиваю видео…\nОбычно это 10–60 секунд.", 'still_waiting': "⬇️ Скачиваю видео…\n⏳ Дольше обычного — видео большое или источник медленный. Жду до 5 минут.", 'sending': "📤 Отправляю в Telegram…", - 'caption': "🎬 {title}\n{author}Источник · @{bot_username}", + 'caption': "🎬 {title}\n{author}🔗 {url}\n@{bot_username}", 'caption_author': "👤 {mention}", 'caption_author_text': "👤 {mention}: {text}", 'video_fallback': "Видео", @@ -126,7 +126,7 @@ TEXTS = { 'downloading': "⬇️ Downloading…\nUsually takes 10–60 seconds.", 'still_waiting': "⬇️ Downloading…\n⏳ Taking longer than usual — large video or slow source. I'll wait up to 5 minutes.", 'sending': "📤 Sending to Telegram…", - 'caption': "🎬 {title}\n{author}Source · @{bot_username}", + 'caption': "🎬 {title}\n{author}🔗 {url}\n@{bot_username}", 'caption_author': "👤 {mention}", 'caption_author_text': "👤 {mention}: {text}", 'video_fallback': "Video", @@ -842,7 +842,7 @@ def build_caption(item: QueueItem, title: str | None) -> str: else: author = get_text(locale, 'caption_author', mention=mention) + "\n" return get_text(locale, 'caption', title=html.escape(_clip(raw_title, title_max)), author=author, - url=html.escape(item.url, quote=True), bot_username=TELEGRAM_BOT_USERNAME) + url=html.escape(item.url, quote=False), bot_username=TELEGRAM_BOT_USERNAME) caption = render(CAPTION_TITLE_MAX, True) if len(html_to_plain(caption)) > CAPTION_VISIBLE_MAX: diff --git a/tests/test_bot_pure.py b/tests/test_bot_pure.py index 2ec3d9c..a8612df 100644 --- a/tests/test_bot_pure.py +++ b/tests/test_bot_pure.py @@ -371,3 +371,11 @@ def test_caption_long_url_keeps_link_tag(): long_url = 'https://www.youtube.com/watch?v=abc&' + 'x=1&' * 250 cap = bot.build_caption(_item('group', text='т' * 300, url=long_url), 'T' * 200) _assert_valid_html(cap) + + +def test_caption_shows_full_url_text(): + """Ссылка на видео видна в подписи целиком, а не спрятана под словом «Источник».""" + url = 'https://www.instagram.com/reel/Cvuh19eNWv_/?igsh=abc&utm_source=x' + for chat_type in ('private', 'supergroup'): + plain = bot.html_to_plain(bot.build_caption(_item(chat_type, url=url), 'T')) + assert url in plain, plain