mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix image downloading
This commit is contained in:
@@ -4,6 +4,7 @@ import { AuthorAnnnotation, BookAnnotation } from "./services/book_library";
|
||||
import { isNormalText } from "./utils";
|
||||
import { getTextPaginationData } from './keyboard';
|
||||
import Sentry from '@/sentry';
|
||||
import { downloadImage } from "./services/downloader";
|
||||
|
||||
|
||||
export function getAnnotationHandler<T extends BookAnnotation | AuthorAnnnotation>(
|
||||
@@ -25,13 +26,17 @@ export function getAnnotationHandler<T extends BookAnnotation | AuthorAnnnotatio
|
||||
}
|
||||
|
||||
if (annotation.file) {
|
||||
const imageData = await downloadImage(annotation.file);
|
||||
|
||||
if (imageData !== null) {
|
||||
try {
|
||||
await ctx.telegram.sendPhoto(ctx.message.chat.id, annotation.file);
|
||||
await ctx.telegram.sendPhoto(ctx.message.chat.id, { source: imageData });
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
Sentry.captureException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isNormalText(annotation.text)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user