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 { isNormalText } from "./utils";
|
||||||
import { getTextPaginationData } from './keyboard';
|
import { getTextPaginationData } from './keyboard';
|
||||||
import Sentry from '@/sentry';
|
import Sentry from '@/sentry';
|
||||||
|
import { downloadImage } from "./services/downloader";
|
||||||
|
|
||||||
|
|
||||||
export function getAnnotationHandler<T extends BookAnnotation | AuthorAnnnotation>(
|
export function getAnnotationHandler<T extends BookAnnotation | AuthorAnnnotation>(
|
||||||
@@ -25,11 +26,15 @@ export function getAnnotationHandler<T extends BookAnnotation | AuthorAnnnotatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (annotation.file) {
|
if (annotation.file) {
|
||||||
try {
|
const imageData = await downloadImage(annotation.file);
|
||||||
await ctx.telegram.sendPhoto(ctx.message.chat.id, annotation.file);
|
|
||||||
} catch (e) {
|
if (imageData !== null) {
|
||||||
console.log(e);
|
try {
|
||||||
Sentry.captureException(e);
|
await ctx.telegram.sendPhoto(ctx.message.chat.id, { source: imageData });
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
Sentry.captureException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user