фикс сжатия изображения (бот говно ебанное)
This commit is contained in:
+16
-2
@@ -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));
|
||||||
|
// 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)), {
|
await bot.api.sendDocument(item.ownerChatId, new InputFile(buffer, fileName(item)), {
|
||||||
caption,
|
caption,
|
||||||
reply_markup: kb,
|
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'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user