From 317fd066c97189128a4590cff2544263eb8ca1c8 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Mon, 27 Mar 2023 20:43:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20TelegramSender?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../godfather/telegram/quarkus/sender/TelegramSender.java | 6 +++++- .../godfather/telegram/simple/sender/TelegramSender.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java index 20f24c2..4316d2c 100644 --- a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java @@ -170,10 +170,14 @@ public class TelegramSender implements TelegramSending { final EditMessageText editMessageText = new EditMessageText(); editMessageText.setChatId(telegramId); editMessageText.setMessageId(Integer.parseInt(lastMessageId)); - editMessageText.enableMarkdown(true); editMessageText.setText(boxAnswer.getMessage()); editMessageText.setReplyMarkup(convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard())); + boxAnswer.getPayLoad(ENABLE_MARKDOWN).ifPresent(editMessageText::enableMarkdown); + boxAnswer.getPayLoad(DISABLE_WEB_PAGE_PREVIEW).ifPresent(isDisable -> { + if (TRUE.equals(isDisable)) editMessageText.disableWebPagePreview(); + }); + return Uni.createFrom().completionStage(executeAsync(editMessageText)) .onItem().ifNotNull().transformToUni(t -> Uni.createFrom().optional(SentBox.optional(telegramId, lastMessageId, boxAnswer, boxAnswer))) .onFailure(TelegramApiRequestException.class).recoverWithUni( diff --git a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java index 068e1bb..26d5a5a 100644 --- a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java @@ -96,9 +96,14 @@ public class TelegramSender implements TelegramSending { public void replaceInlineMessage(String inlineMessageId, BoxAnswer boxAnswer) { final EditMessageText editMessageText = new EditMessageText(); editMessageText.setInlineMessageId(inlineMessageId); - editMessageText.enableMarkdown(true); editMessageText.setText(boxAnswer.getMessage()); editMessageText.setReplyMarkup(convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard())); + + boxAnswer.getPayLoad(ENABLE_MARKDOWN).ifPresent(editMessageText::enableMarkdown); + boxAnswer.getPayLoad(DISABLE_WEB_PAGE_PREVIEW).ifPresent(isDisable -> { + if (TRUE.equals(isDisable)) editMessageText.disableWebPagePreview(); + }); + try { absSender.execute(editMessageText); } catch (TelegramApiRequestException e) {