фикс сжатия изображения (бот говно ебанное)
This commit is contained in:
+20
-6
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user