diff --git a/pom.xml b/pom.xml index 39e6015..4705896 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ UTF-8 UTF-8 - 0.0.65 + 0.0.66-SNAPSHOT 6.5.0 diff --git a/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/util/UnitTrigger.java b/telegram-core/telegram-core-main/src/main/java/dev/struchkov/godfather/telegram/main/core/util/UnitTrigger.java similarity index 72% rename from telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/util/UnitTrigger.java rename to telegram-core/telegram-core-main/src/main/java/dev/struchkov/godfather/telegram/main/core/util/UnitTrigger.java index 6c3e3ab..58034de 100644 --- a/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/util/UnitTrigger.java +++ b/telegram-core/telegram-core-main/src/main/java/dev/struchkov/godfather/telegram/main/core/util/UnitTrigger.java @@ -1,8 +1,8 @@ -package dev.struchkov.godfather.telegram.simple.core.util; +package dev.struchkov.godfather.telegram.main.core.util; import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; -import dev.struchkov.godfather.telegram.main.core.util.Attachments; +import dev.struchkov.godfather.telegram.domain.attachment.CommandAttachment; import java.util.Arrays; import java.util.Optional; @@ -28,6 +28,18 @@ public class UnitTrigger { }; } + public static Predicate isCommandByType(String commandType) { + return mail -> { + final Optional optCommand = Attachments.findFirstCommand(mail.getAttachments()); + if (optCommand.isPresent()) { + final CommandAttachment command = optCommand.get(); + final String type = command.getCommandType(); + return type.equals(commandType); + } + return false; + }; + } + public static Predicate isButtonClick() { return mail -> Attachments.findFirstButtonClick(mail.getAttachments()).isPresent(); } diff --git a/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/util/UnitTrigger.java b/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/util/UnitTrigger.java deleted file mode 100644 index bd21e4f..0000000 --- a/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/util/UnitTrigger.java +++ /dev/null @@ -1,68 +0,0 @@ -package dev.struchkov.godfather.telegram.quarkus.core.util; - -import dev.struchkov.godfather.main.domain.content.Mail; -import dev.struchkov.godfather.quarkus.domain.unit.func.UniPredicate; -import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; -import dev.struchkov.godfather.telegram.domain.attachment.CommandAttachment; -import dev.struchkov.godfather.telegram.main.core.util.Attachments; - -import java.util.Optional; - -import static dev.struchkov.godfather.quarkus.domain.unit.func.UniPredicate.predicate; -import static dev.struchkov.haiti.utils.Exceptions.utilityClass; - -public class UnitTrigger { - - private UnitTrigger() { - utilityClass(); - } - - public static UniPredicate clickButtonRaw(String rawCallBackData) { - return predicate( - mail -> { - final Optional optButtonClick = Attachments.findFirstButtonClick(mail.getAttachments()); - if (optButtonClick.isPresent()) { - final ButtonClickAttachment buttonClick = optButtonClick.get(); - final String rawData = buttonClick.getRawCallBackData(); - return rawData.equals(rawCallBackData); - } - return false; - } - ); - } - - public static UniPredicate isCommandByType(String commandType) { - return predicate( - mail -> { - final Optional optCommand = Attachments.findFirstCommand(mail.getAttachments()); - if (optCommand.isPresent()) { - final CommandAttachment command = optCommand.get(); - final String type = command.getCommandType(); - return type.equals(commandType); - } - return false; - } - ); - } - - public static UniPredicate isCommand() { - return predicate(mail -> Attachments.findFirstCommand(mail.getAttachments()).isPresent()); - } - - public static UniPredicate isButtonClick() { - return predicate(mail -> Attachments.findFirstButtonClick(mail.getAttachments()).isPresent()); - } - - public static UniPredicate isButtonClickArg(String argType) { - return predicate( - mail -> Attachments.findFirstButtonClick(mail.getAttachments()) - .flatMap(click -> click.getArgByType(argType)) - .isPresent() - ); - } - - public static UniPredicate isLinks() { - return predicate(mail -> Attachments.findFirstLink(mail.getAttachments()).isPresent()); - } - -}