fix(bot): показывать в подписи к видео саму ссылку, а не слово «Источник»
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 25s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 25s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
60312b0096
commit
b41f900fed
2 changed files with 11 additions and 3 deletions
6
bot.py
6
bot.py
|
|
@ -94,7 +94,7 @@ TEXTS = {
|
|||
'downloading': "⬇️ Скачиваю видео…\nОбычно это 10–60 секунд.",
|
||||
'still_waiting': "⬇️ Скачиваю видео…\n⏳ Дольше обычного — видео большое или источник медленный. Жду до 5 минут.",
|
||||
'sending': "📤 Отправляю в Telegram…",
|
||||
'caption': "🎬 {title}\n{author}<a href=\"{url}\">Источник</a> · @{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}<a href=\"{url}\">Source</a> · @{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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue