Fix image downloading

This commit is contained in:
2022-04-01 21:48:15 +03:00
parent 69ca54b055
commit ef43c5c454

View File

@@ -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;