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