From 9fa6d425eddb558e219f3656e9e62b751039b1f5 Mon Sep 17 00:00:00 2001 From: Kurbanov Bulat Date: Fri, 4 Feb 2022 12:09:28 +0300 Subject: [PATCH] Fix annotations --- src/bots/factory/bots/approved/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bots/factory/bots/approved/index.ts b/src/bots/factory/bots/approved/index.ts index 5e27ab0..84aa7d2 100644 --- a/src/bots/factory/bots/approved/index.ts +++ b/src/bots/factory/bots/approved/index.ts @@ -142,14 +142,16 @@ export async function createApprovedBot(token: string, state: BotState): Promise const annotation = await BookLibrary.getBookAnnotation(parseInt(bookId)); - const data = getTextPaginationData(`${CallbackData.BOOK_ANNOTATION_PREFIX}${bookId}`, annotation.text, 0); - if (annotation.file) { const imageData = await downloadImage(annotation.file); if (imageData) await ctx.telegram.sendPhoto(ctx.message.chat.id, {source: imageData}); } + if (!annotation.text) return; + + const data = getTextPaginationData(`${CallbackData.BOOK_ANNOTATION_PREFIX}${bookId}`, annotation.text, 0); + try { await ctx.reply(data.current, { parse_mode: "HTML", @@ -201,14 +203,16 @@ export async function createApprovedBot(token: string, state: BotState): Promise const annotation = await BookLibrary.getAuthorAnnotation(parseInt(authorId)); - const data = getTextPaginationData(`${CallbackData.AUTHOR_ANNOTATION_PREFIX}${authorId}`, annotation.text, 0); - if (annotation.file) { const imageData = await downloadImage(annotation.file); - + if (imageData) await ctx.telegram.sendPhoto(ctx.message.chat.id, {source: imageData}); } - + + if (!annotation.text) return; + + const data = getTextPaginationData(`${CallbackData.AUTHOR_ANNOTATION_PREFIX}${authorId}`, annotation.text, 0); + try { await ctx.reply(data.current, { parse_mode: "HTML",