fix: bot sent caption without content from cache

This commit is contained in:
vchikalkin 2026-01-14 18:00:32 +03:00
parent 816eca4da5
commit f48230cbeb

View File

@ -37,22 +37,24 @@ feature.on('message:text', logHandle('download-message'), async (context) => {
return context.reply(context.t('err-invalid-url'));
}
// Проверка кеша
const cachedFileId = await redis.get(url);
let contentMessageId: number | undefined;
if (cachedFileId) {
const cachedMessage = await context.replyWithVideo(cachedFileId);
// Проверка кеша
const cachedVideoId = await redis.get(url);
if (cachedVideoId) {
const cachedMessage = await context.replyWithVideo(cachedVideoId);
contentMessageId = cachedMessage.message_id;
}
const cachedCaption = await redis.get(`caption:${url}`);
if (cachedCaption) {
const { entities, text } = formatCaption(cachedCaption);
return context.reply(text, {
entities,
reply_parameters: contentMessageId ? { message_id: contentMessageId } : undefined,
});
if (contentMessageId) {
const cachedCaption = await redis.get(`caption:${url}`);
if (cachedCaption) {
const { entities, text } = formatCaption(cachedCaption);
return context.reply(text, {
entities,
reply_parameters: contentMessageId ? { message_id: contentMessageId } : undefined,
});
}
}
// Загрузка данных с сервисов