This commit is contained in:
parent
9c2f04c483
commit
8f8b524b0e
3
pom.xml
3
pom.xml
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>telegram-core</artifactId>
|
<artifactId>telegram-core</artifactId>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package dev.struchkov.godfather.telegram.quarkus.core.util;
|
||||||
|
|
||||||
|
import dev.struchkov.godfather.main.domain.content.Mail;
|
||||||
|
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 java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||||
|
|
||||||
|
public class UnitTrigger {
|
||||||
|
|
||||||
|
private UnitTrigger() {
|
||||||
|
utilityClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Predicate<Mail> clickButtonRaw(String rawCallBackData) {
|
||||||
|
return mail -> {
|
||||||
|
final Optional<ButtonClickAttachment> 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 Predicate<Mail> isCommandByType(String commandType) {
|
||||||
|
return mail -> {
|
||||||
|
final Optional<CommandAttachment> 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<Mail> isCommand() {
|
||||||
|
return mail -> Attachments.findFirstCommand(mail.getAttachments()).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Predicate<Mail> isClickButton() {
|
||||||
|
return mail -> Attachments.findFirstButtonClick(mail.getAttachments()).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Predicate<Mail> isLinks() {
|
||||||
|
return mail -> Attachments.findFirstLink(mail.getAttachments()).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,9 +9,9 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||||
|
|
||||||
public class TriggerChecks {
|
public class UnitTrigger {
|
||||||
|
|
||||||
private TriggerChecks() {
|
private UnitTrigger() {
|
||||||
utilityClass();
|
utilityClass();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user