diff --git a/src/bot/panel.js b/src/bot/panel.js index 680d38d..53181f5 100644 --- a/src/bot/panel.js +++ b/src/bot/panel.js @@ -158,10 +158,24 @@ export async function notifyCapture(bot, item) { if (item.mediaPath) { try { const buffer = decrypt(await readMedia(item.mediaPath)); - await bot.api.sendDocument(item.ownerChatId, new InputFile(buffer, fileName(item)), { - caption, - reply_markup: kb, - }); + // logger.warn(buffer) + logger.warn(fileName(item)) + const isPhoto = /\.(jpe?g|png|webp)$/i.test(fileName(item)); + logger.warn(isPhoto) + + if (isPhoto) { + // Отправляем как фото — откроется во встроенной галерее Telegram + await bot.api.sendPhoto(item.ownerChatId, new InputFile(buffer, fileName(item)), { + caption, + reply_markup: kb, + }); + } else { + // Все остальные форматы шлем обычным документом + await bot.api.sendDocument(item.ownerChatId, new InputFile(buffer, fileName(item)), { + caption, + reply_markup: kb, + }); + } return; } catch (err) { logger.warn('bot: медиа для уведомления не отдалось, шлю текстом', err.message); @@ -179,8 +193,8 @@ export async function notifyCapture(bot, item) { /** Подпись к уведомлению: кто, тип медиа и текст — в пределах лимита подписи. */ function notifyCaption(item) { const mediaKind = item.media_kind ?? item.mediaKind; - const lines = [`🗑 Удалённое сообщение от ${item.sender || 'неизвестно'}`]; - if (mediaKind) lines.push(`[${mediaKind}]`); + const lines = [`🗑 Поймано удалённое сообщение от ${item.sender || 'неизвестно'}`]; + // if (mediaKind) lines.push(`[${mediaKind}]`); if (item.text) lines.push('', item.text); return clampCaption(lines.join('\n')); }