фикс сжатия изображения (бот говно ебанное)

This commit is contained in:
2026-08-10 01:02:27 +03:00
parent eed828ec58
commit 8c0b3e45db
+20 -6
View File
@@ -158,10 +158,24 @@ export async function notifyCapture(bot, item) {
if (item.mediaPath) { if (item.mediaPath) {
try { try {
const buffer = decrypt(await readMedia(item.mediaPath)); const buffer = decrypt(await readMedia(item.mediaPath));
await bot.api.sendDocument(item.ownerChatId, new InputFile(buffer, fileName(item)), { // logger.warn(buffer)
caption, logger.warn(fileName(item))
reply_markup: kb, 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; return;
} catch (err) { } catch (err) {
logger.warn('bot: медиа для уведомления не отдалось, шлю текстом', err.message); logger.warn('bot: медиа для уведомления не отдалось, шлю текстом', err.message);
@@ -179,8 +193,8 @@ export async function notifyCapture(bot, item) {
/** Подпись к уведомлению: кто, тип медиа и текст — в пределах лимита подписи. */ /** Подпись к уведомлению: кто, тип медиа и текст — в пределах лимита подписи. */
function notifyCaption(item) { function notifyCaption(item) {
const mediaKind = item.media_kind ?? item.mediaKind; const mediaKind = item.media_kind ?? item.mediaKind;
const lines = [`🗑 Удалённое сообщение от ${item.sender || 'неизвестно'}`]; const lines = [`🗑 Поймано удалённое сообщение от ${item.sender || 'неизвестно'}`];
if (mediaKind) lines.push(`[${mediaKind}]`); // if (mediaKind) lines.push(`[${mediaKind}]`);
if (item.text) lines.push('', item.text); if (item.text) lines.push('', item.text);
return clampCaption(lines.join('\n')); return clampCaption(lines.join('\n'));
} }