try send cached video

This commit is contained in:
user 2025-02-05 11:00:07 +03:00
parent e3906c8ce0
commit 0f6c0fe09d
2 changed files with 20 additions and 6 deletions

View File

@ -158,13 +158,13 @@ async def t_inline_query_node_content(query: types.InlineQuery, memory=None, use
) )
elif content_type_declared == 'video': elif content_type_declared == 'video':
content_list.append( content_list.append(
types.InlineQueryResultVideo( types.InlineQueryResultCachedVideo(
id=f"NC_{content.id}", id=f"NC_{content.id}",
video_url=decrypted_content.web_url + '?seconds_limit=30', video_file_id=encrypted_content.meta['telegram_file_cache'],
title=title, title=title,
caption=hashtags_str + user.translated('p_playerContext_preview'), caption=hashtags_str + user.translated('p_playerContext_preview'),
mime_type="video/mp4", # mime_type="video/mp4",
thumbnail_url='https://raw.githubusercontent.com/my-mirror/assets/refs/heads/main/video_icon.png', # thumbnail_url='https://raw.githubusercontent.com/my-mirror/assets/refs/heads/main/video_icon.png',
parse_mode='html', parse_mode='html',
reply_markup=get_inline_keyboard([ reply_markup=get_inline_keyboard([
[{ [{

View File

@ -5,7 +5,7 @@ from app.core._utils.tg_process_template import tg_process_template
from app.core._config import PROJECT_HOST, CLIENT_TELEGRAM_BOT_USERNAME from app.core._config import PROJECT_HOST, CLIENT_TELEGRAM_BOT_USERNAME
from app.core._keyboards import get_inline_keyboard from app.core._keyboards import get_inline_keyboard
from app.core.models.messages import KnownTelegramMessage from app.core.models.messages import KnownTelegramMessage
from aiogram.types import URLInputFile from aiogram.types import URLInputFile, Message
import json import json
@ -150,7 +150,7 @@ class PlayerTemplates:
).all(): ).all():
await self.delete_message(kmsg.message_id) await self.delete_message(kmsg.message_id)
return await tg_process_template( r = await tg_process_template(
self, text, message_id=message_id, **template_kwargs, self, text, message_id=message_id, **template_kwargs,
keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None, keyboard=get_inline_keyboard([*inline_keyboard_array, *extra_buttons]) if inline_keyboard_array else None,
message_type=f'content/{content_type}', message_type=f'content/{content_type}',
@ -158,5 +158,19 @@ class PlayerTemplates:
content_id=content.id if content else None content_id=content.id if content else None
) )
if self.bot_id == 1:
if content_type == 'audio':
content.meta = {
**content.meta,
'telegram_file_cache': r.audio.file_id,
}
elif content_type == 'video':
content.meta = {
**content.meta,
'telegram_file_cache': r.video.file_id,
}
return r