diff --git a/pom.xml b/pom.xml index 47be3c7..93b14e9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 dev.struchkov.godfather.telegram @@ -54,7 +55,17 @@ dev.struchkov.godfather.telegram - telegram-domain + telegram-domain-main + ${project.version} + + + dev.struchkov.godfather.telegram + telegram-domain-simple + ${project.version} + + + dev.struchkov.godfather.telegram + telegram-domain-quarkus ${project.version} @@ -155,6 +166,16 @@ bot-domain-main ${godfather.core.ver} + + dev.struchkov.godfather + bot-domain-quarkus + ${godfather.core.ver} + + + dev.struchkov.godfather + bot-domain-simple + ${godfather.core.ver} + dev.struchkov.godfather diff --git a/telegram-consumer/telegram-consumer-main/pom.xml b/telegram-consumer/telegram-consumer-main/pom.xml index 3ad3012..de62028 100644 --- a/telegram-consumer/telegram-consumer-main/pom.xml +++ b/telegram-consumer/telegram-consumer-main/pom.xml @@ -13,7 +13,7 @@ dev.struchkov.godfather.telegram - telegram-domain + telegram-domain-main dev.struchkov.godfather.telegram diff --git a/telegram-context/telegram-context-main/pom.xml b/telegram-context/telegram-context-main/pom.xml index e8e8b97..c61facf 100644 --- a/telegram-context/telegram-context-main/pom.xml +++ b/telegram-context/telegram-context-main/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 dev.struchkov.godfather.telegram @@ -18,8 +19,13 @@ dev.struchkov.godfather.telegram - telegram-domain + telegram-domain-main + + dev.struchkov.godfather + bot-context-simple + + org.telegram telegrambots diff --git a/telegram-context/telegram-context-quarkus/pom.xml b/telegram-context/telegram-context-quarkus/pom.xml index 74dbb38..b786453 100644 --- a/telegram-context/telegram-context-quarkus/pom.xml +++ b/telegram-context/telegram-context-quarkus/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 dev.struchkov.godfather.telegram diff --git a/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/TelegramSending.java b/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/TelegramSending.java index d765e15..12149c9 100644 --- a/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/TelegramSending.java +++ b/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/TelegramSending.java @@ -1,8 +1,8 @@ package dev.struchkov.godfather.telegram.quarkus.context.service; -import dev.struchkov.godfather.main.domain.BoxAnswer; -import dev.struchkov.godfather.main.domain.SentBox; import dev.struchkov.godfather.quarkus.context.service.SendingService; +import dev.struchkov.godfather.quarkus.domain.BoxAnswer; +import dev.struchkov.godfather.quarkus.domain.SentBox; import io.smallrye.mutiny.Uni; import org.jetbrains.annotations.NotNull; diff --git a/telegram-context/telegram-context-simple/pom.xml b/telegram-context/telegram-context-simple/pom.xml index f128076..6f2cadf 100644 --- a/telegram-context/telegram-context-simple/pom.xml +++ b/telegram-context/telegram-context-simple/pom.xml @@ -20,10 +20,9 @@ dev.struchkov.godfather.telegram telegram-context-main - - dev.struchkov.godfather - bot-context-simple + dev.struchkov.godfather.telegram + telegram-domain-simple diff --git a/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/TelegramSending.java b/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/TelegramSending.java index 033ecf5..145f2b2 100644 --- a/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/TelegramSending.java +++ b/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/TelegramSending.java @@ -1,8 +1,8 @@ package dev.struchkov.godfather.telegram.simple.context.service; -import dev.struchkov.godfather.main.domain.BoxAnswer; -import dev.struchkov.godfather.main.domain.SentBox; import dev.struchkov.godfather.simple.context.service.SendingService; +import dev.struchkov.godfather.simple.domain.BoxAnswer; +import dev.struchkov.godfather.simple.domain.SentBox; import org.jetbrains.annotations.NotNull; import java.util.Optional; diff --git a/telegram-domain/pom.xml b/telegram-domain/pom.xml index 142e118..8c4b27c 100644 --- a/telegram-domain/pom.xml +++ b/telegram-domain/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 dev.struchkov.godfather.telegram @@ -8,22 +9,11 @@ telegram-domain - - - 17 - 17 - - - - - dev.struchkov.godfather - bot-context-main - - - - org.telegram - telegrambots - - + pom + + telegram-domain-main + telegram-domain-quarkus + telegram-domain-simple + \ No newline at end of file diff --git a/telegram-domain/telegram-domain-main/pom.xml b/telegram-domain/telegram-domain-main/pom.xml new file mode 100644 index 0000000..719a76c --- /dev/null +++ b/telegram-domain/telegram-domain-main/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + dev.struchkov.godfather.telegram + telegram-domain + 0.0.49-SNAPSHOT + + + telegram-domain-main + + + 17 + 17 + UTF-8 + + + + + dev.struchkov.godfather + bot-domain-main + + + + \ No newline at end of file diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPaginationUtil.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPaginationUtil.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPaginationUtil.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPaginationUtil.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/CommandAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/CommandAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/CommandAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/CommandAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ContactAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ContactAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ContactAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ContactAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/DocumentAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/DocumentAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/DocumentAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/DocumentAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/LinkAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/LinkAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/LinkAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/LinkAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/Picture.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/Picture.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/Picture.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/Picture.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/PictureGroupAttachment.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/PictureGroupAttachment.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/PictureGroupAttachment.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/PictureGroupAttachment.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/TelegramAttachmentType.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/TelegramAttachmentType.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/TelegramAttachmentType.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/TelegramAttachmentType.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/config/ProxyConfig.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/config/ProxyConfig.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/config/ProxyConfig.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/config/ProxyConfig.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/config/TelegramConnectConfig.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/config/TelegramConnectConfig.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/config/TelegramConnectConfig.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/config/TelegramConnectConfig.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/event/Subscribe.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/event/Subscribe.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/event/Subscribe.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/event/Subscribe.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/event/Unsubscribe.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/event/Unsubscribe.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/event/Unsubscribe.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/event/Unsubscribe.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/files/ByteContainer.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/files/ByteContainer.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/files/ByteContainer.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/files/ByteContainer.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/files/FileContainer.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/files/FileContainer.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/files/FileContainer.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/files/FileContainer.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/InlineKeyBoard.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/InlineKeyBoard.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/InlineKeyBoard.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/InlineKeyBoard.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/MarkupKeyBoard.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/MarkupKeyBoard.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/MarkupKeyBoard.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/MarkupKeyBoard.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/ContactButton.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/ContactButton.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/ContactButton.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/ContactButton.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/UrlButton.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/UrlButton.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/UrlButton.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/UrlButton.java diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/WebAppButton.java b/telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/WebAppButton.java similarity index 100% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/WebAppButton.java rename to telegram-domain/telegram-domain-main/src/main/java/dev/struchkov/godfather/telegram/domain/keyboard/button/WebAppButton.java diff --git a/telegram-domain/telegram-domain-quarkus/pom.xml b/telegram-domain/telegram-domain-quarkus/pom.xml new file mode 100644 index 0000000..d1506f6 --- /dev/null +++ b/telegram-domain/telegram-domain-quarkus/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + dev.struchkov.godfather.telegram + telegram-domain + 0.0.49-SNAPSHOT + + + telegram-domain-quarkus + + + 17 + 17 + UTF-8 + + + + + dev.struchkov.godfather.telegram + telegram-domain-main + + + + dev.struchkov.godfather + bot-domain-quarkus + + + + \ No newline at end of file diff --git a/telegram-domain/telegram-domain-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/domain/UnitPage.java b/telegram-domain/telegram-domain-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/domain/UnitPage.java new file mode 100644 index 0000000..9f2b8c1 --- /dev/null +++ b/telegram-domain/telegram-domain-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/domain/UnitPage.java @@ -0,0 +1,147 @@ +package dev.struchkov.godfather.telegram.quarkus.domain; + +import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton; +import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine; +import dev.struchkov.godfather.quarkus.domain.BoxAnswer; +import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; +import dev.struchkov.haiti.utils.Inspector; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine; +import static dev.struchkov.godfather.telegram.domain.UnitPaginationUtil.navigableLine; + +public class UnitPage { + + /** + * Дополнительные линии клавиатуры. Выводятся после кнопок навигации. + */ + private final List additionalLines = new ArrayList<>(); + + /** + * Элементы, которые будут выводиться. + */ + private List elements; + + /** + * Номер текущей страницы. + */ + private Integer currentOffset; + + /** + * Общее количество элементов на всех страницах. + */ + private Integer countAllElements; + + /** + * Функция преобразования элементов с линии. + */ + private Function function; + + /** + * Сообщение, которое выводится над результатами + */ + private String message; + + /** + * Флаг, определяющий нужно ли заменить старое сообщение или вывести новое (по умолчанию заменять) + */ + private boolean replace; + + /** + * Флаг, исключающий добавление строки с навигацией + */ + private boolean removeDefaultNavigableLine; + + /** + * Сообщение, которое будет отправлено, если коллекция элементов пустая. + */ + private BoxAnswer emptyElements; + + public static UnitPage builder() { + return new UnitPage<>(); + } + + public UnitPage elements(List elements) { + this.elements = elements; + return this; + } + + public UnitPage countAllElements(Integer countAllElements) { + this.countAllElements = countAllElements; + return this; + } + + public UnitPage currentOffset(Integer currentOffset) { + this.currentOffset = currentOffset; + return this; + } + + public UnitPage additionLine(KeyBoardLine line) { + additionalLines.add(line); + return this; + } + + public UnitPage additionLine(KeyBoardButton button) { + additionalLines.add(simpleLine(button)); + return this; + } + + public UnitPage mapper(Function function) { + this.function = function; + return this; + } + + public UnitPage message(String message) { + this.message = message; + return this; + } + + public UnitPage replace(boolean replace) { + this.replace = replace; + return this; + } + + public UnitPage emptyElements(BoxAnswer boxAnswer) { + this.emptyElements = boxAnswer; + return this; + } + + public UnitPage removeDefaultNavigableLine() { + this.removeDefaultNavigableLine = true; + return this; + } + + public BoxAnswer build() { + Inspector.isNotNull(currentOffset, countAllElements, function); + if (elements.isEmpty()) { + return emptyElements != null ? emptyElements : BoxAnswer.boxAnswer("Данные не найдены."); + } else { + final List lines = elements.stream() + .map(function) + .toList(); + final InlineKeyBoard.Builder builder = InlineKeyBoard.builder(); + + lines.forEach(builder::line); + if (!removeDefaultNavigableLine) { + navigableLine(currentOffset, countAllElements).ifPresent(builder::line); + } + additionalLines.forEach(builder::line); + + final InlineKeyBoard keyBoard = builder.build(); + + final BoxAnswer.Builder boxAnswer = BoxAnswer.builder() + .keyBoard(keyBoard) + .replace(true); + if (message != null) { + boxAnswer.message(message); + } + + boxAnswer.replace(replace); + return boxAnswer.build(); + } + } + +} diff --git a/telegram-domain/telegram-domain-simple/pom.xml b/telegram-domain/telegram-domain-simple/pom.xml new file mode 100644 index 0000000..c1b0334 --- /dev/null +++ b/telegram-domain/telegram-domain-simple/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + dev.struchkov.godfather.telegram + telegram-domain + 0.0.49-SNAPSHOT + + + telegram-domain-simple + + + 17 + 17 + UTF-8 + + + + + dev.struchkov.godfather.telegram + telegram-domain-main + + + + dev.struchkov.godfather + bot-domain-simple + + + + \ No newline at end of file diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPage.java b/telegram-domain/telegram-domain-simple/src/main/java/dev/struchkov/godfather/telegram/simple/domain/UnitPage.java similarity index 97% rename from telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPage.java rename to telegram-domain/telegram-domain-simple/src/main/java/dev/struchkov/godfather/telegram/simple/domain/UnitPage.java index 441b072..519396f 100644 --- a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/UnitPage.java +++ b/telegram-domain/telegram-domain-simple/src/main/java/dev/struchkov/godfather/telegram/simple/domain/UnitPage.java @@ -1,8 +1,8 @@ -package dev.struchkov.godfather.telegram.domain; +package dev.struchkov.godfather.telegram.simple.domain; -import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton; import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine; +import dev.struchkov.godfather.simple.domain.BoxAnswer; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.haiti.utils.Inspector; diff --git a/telegram-sender/telegram-sender-main/pom.xml b/telegram-sender/telegram-sender-main/pom.xml index 0db2d2e..4bde73d 100644 --- a/telegram-sender/telegram-sender-main/pom.xml +++ b/telegram-sender/telegram-sender-main/pom.xml @@ -22,7 +22,7 @@ dev.struchkov.godfather.telegram - telegram-domain + telegram-domain-main 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 adf58ab..42cbeb6 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 @@ -1,9 +1,9 @@ package dev.struchkov.godfather.telegram.quarkus.sender; -import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.SendType; -import dev.struchkov.godfather.main.domain.SentBox; -import dev.struchkov.godfather.quarkus.context.service.PreSendProcessing; +import dev.struchkov.godfather.quarkus.domain.BoxAnswer; +import dev.struchkov.godfather.quarkus.domain.SentBox; +import dev.struchkov.godfather.quarkus.domain.action.PreSendProcessing; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.main.context.TelegramConnect; import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert; 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 0cc7031..8aac2d2 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 @@ -1,12 +1,11 @@ package dev.struchkov.godfather.telegram.simple.sender; -import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.SendType; -import dev.struchkov.godfather.main.domain.SentBox; -import dev.struchkov.godfather.simple.context.service.PreSendProcessing; +import dev.struchkov.godfather.simple.domain.BoxAnswer; +import dev.struchkov.godfather.simple.domain.SentBox; +import dev.struchkov.godfather.simple.domain.action.PreSendProcessing; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.main.context.TelegramConnect; -import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert; import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import org.jetbrains.annotations.NotNull; @@ -26,9 +25,12 @@ import java.util.Optional; import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_NOTIFICATION; import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW; +import static dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert.convertInlineKeyBoard; +import static dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert.convertKeyBoard; import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Inspector.isNotNull; import static java.lang.Boolean.TRUE; +import static java.lang.Integer.parseInt; public class TelegramSender implements TelegramSending { @@ -63,7 +65,7 @@ public class TelegramSender implements TelegramSending { public void deleteMessage(@NotNull String personId, @NotNull String messageId) { final DeleteMessage deleteMessage = new DeleteMessage(); deleteMessage.setChatId(personId); - deleteMessage.setMessageId(Integer.parseInt(messageId)); + deleteMessage.setMessageId(parseInt(messageId)); try { absSender.execute(deleteMessage); } catch (TelegramApiException e) { @@ -115,10 +117,10 @@ public class TelegramSender implements TelegramSending { private Optional replace(@NotNull String telegramId, @NotNull String replaceMessageId, @NotNull BoxAnswer boxAnswer, BoxAnswer preparedAnswer, boolean saveMessageId) { final EditMessageText editMessageText = new EditMessageText(); editMessageText.setChatId(telegramId); - editMessageText.setMessageId(Integer.parseInt(replaceMessageId)); + editMessageText.setMessageId(parseInt(replaceMessageId)); editMessageText.enableMarkdown(true); editMessageText.setText(boxAnswer.getMessage()); - editMessageText.setReplyMarkup(KeyBoardConvert.convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard())); + editMessageText.setReplyMarkup(convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard())); try { absSender.execute(editMessageText); return SentBox.optional(telegramId, replaceMessageId, preparedAnswer, boxAnswer); @@ -138,7 +140,7 @@ public class TelegramSender implements TelegramSending { sendMessage.enableMarkdown(true); sendMessage.setChatId(telegramId); sendMessage.setText(boxAnswer.getMessage()); - sendMessage.setReplyMarkup(KeyBoardConvert.convertKeyBoard(boxAnswer.getKeyBoard())); + sendMessage.setReplyMarkup(convertKeyBoard(boxAnswer.getKeyBoard())); boxAnswer.getPayLoad(DISABLE_WEB_PAGE_PREVIEW).ifPresent(isDisable -> { if (TRUE.equals(isDisable)) sendMessage.disableWebPagePreview();