Добавил новые модули domain
This commit is contained in:
parent
a103f20dd0
commit
a05eb8a403
25
pom.xml
25
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>
|
||||||
@ -54,7 +55,17 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>telegram-domain</artifactId>
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain-simple</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain-quarkus</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -155,6 +166,16 @@
|
|||||||
<artifactId>bot-domain-main</artifactId>
|
<artifactId>bot-domain-main</artifactId>
|
||||||
<version>${godfather.core.ver}</version>
|
<version>${godfather.core.ver}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-domain-quarkus</artifactId>
|
||||||
|
<version>${godfather.core.ver}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-domain-simple</artifactId>
|
||||||
|
<version>${godfather.core.ver}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>telegram-domain</artifactId>
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<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>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
@ -18,8 +19,13 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>telegram-domain</artifactId>
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-context-simple</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
|
@ -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>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package dev.struchkov.godfather.telegram.quarkus.context.service;
|
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.context.service.SendingService;
|
||||||
|
import dev.struchkov.godfather.quarkus.domain.BoxAnswer;
|
||||||
|
import dev.struchkov.godfather.quarkus.domain.SentBox;
|
||||||
import io.smallrye.mutiny.Uni;
|
import io.smallrye.mutiny.Uni;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -20,10 +20,9 @@
|
|||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>telegram-context-main</artifactId>
|
<artifactId>telegram-context-main</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>bot-context-simple</artifactId>
|
<artifactId>telegram-domain-simple</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package dev.struchkov.godfather.telegram.simple.context.service;
|
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.context.service.SendingService;
|
||||||
|
import dev.struchkov.godfather.simple.domain.BoxAnswer;
|
||||||
|
import dev.struchkov.godfather.simple.domain.SentBox;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -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>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
@ -8,22 +9,11 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>telegram-domain</artifactId>
|
<artifactId>telegram-domain</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
<properties>
|
<modules>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<module>telegram-domain-main</module>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<module>telegram-domain-quarkus</module>
|
||||||
</properties>
|
<module>telegram-domain-simple</module>
|
||||||
|
</modules>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
|
||||||
<artifactId>bot-context-main</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.telegram</groupId>
|
|
||||||
<artifactId>telegrambots</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
27
telegram-domain/telegram-domain-main/pom.xml
Normal file
27
telegram-domain/telegram-domain-main/pom.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain</artifactId>
|
||||||
|
<version>0.0.49-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-domain-main</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
32
telegram-domain/telegram-domain-quarkus/pom.xml
Normal file
32
telegram-domain/telegram-domain-quarkus/pom.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain</artifactId>
|
||||||
|
<version>0.0.49-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>telegram-domain-quarkus</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-domain-quarkus</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -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<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Дополнительные линии клавиатуры. Выводятся после кнопок навигации.
|
||||||
|
*/
|
||||||
|
private final List<KeyBoardLine> additionalLines = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Элементы, которые будут выводиться.
|
||||||
|
*/
|
||||||
|
private List<T> elements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Номер текущей страницы.
|
||||||
|
*/
|
||||||
|
private Integer currentOffset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Общее количество элементов на всех страницах.
|
||||||
|
*/
|
||||||
|
private Integer countAllElements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Функция преобразования элементов с линии.
|
||||||
|
*/
|
||||||
|
private Function<T, KeyBoardLine> function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сообщение, которое выводится над результатами
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Флаг, определяющий нужно ли заменить старое сообщение или вывести новое (по умолчанию заменять)
|
||||||
|
*/
|
||||||
|
private boolean replace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Флаг, исключающий добавление строки с навигацией
|
||||||
|
*/
|
||||||
|
private boolean removeDefaultNavigableLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сообщение, которое будет отправлено, если коллекция элементов пустая.
|
||||||
|
*/
|
||||||
|
private BoxAnswer emptyElements;
|
||||||
|
|
||||||
|
public static <T> UnitPage<T> builder() {
|
||||||
|
return new UnitPage<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> elements(List<T> elements) {
|
||||||
|
this.elements = elements;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> countAllElements(Integer countAllElements) {
|
||||||
|
this.countAllElements = countAllElements;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> currentOffset(Integer currentOffset) {
|
||||||
|
this.currentOffset = currentOffset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> additionLine(KeyBoardLine line) {
|
||||||
|
additionalLines.add(line);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> additionLine(KeyBoardButton button) {
|
||||||
|
additionalLines.add(simpleLine(button));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> mapper(Function<T, KeyBoardLine> function) {
|
||||||
|
this.function = function;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> replace(boolean replace) {
|
||||||
|
this.replace = replace;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> emptyElements(BoxAnswer boxAnswer) {
|
||||||
|
this.emptyElements = boxAnswer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitPage<T> 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<KeyBoardLine> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
telegram-domain/telegram-domain-simple/pom.xml
Normal file
32
telegram-domain/telegram-domain-simple/pom.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain</artifactId>
|
||||||
|
<version>0.0.49-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>telegram-domain-simple</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
|
<artifactId>bot-domain-simple</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -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.KeyBoardButton;
|
||||||
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;
|
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.godfather.telegram.domain.keyboard.InlineKeyBoard;
|
||||||
import dev.struchkov.haiti.utils.Inspector;
|
import dev.struchkov.haiti.utils.Inspector;
|
||||||
|
|
@ -22,7 +22,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather.telegram</groupId>
|
<groupId>dev.struchkov.godfather.telegram</groupId>
|
||||||
<artifactId>telegram-domain</artifactId>
|
<artifactId>telegram-domain-main</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package dev.struchkov.godfather.telegram.quarkus.sender;
|
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.SendType;
|
||||||
import dev.struchkov.godfather.main.domain.SentBox;
|
import dev.struchkov.godfather.quarkus.domain.BoxAnswer;
|
||||||
import dev.struchkov.godfather.quarkus.context.service.PreSendProcessing;
|
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.domain.keyboard.InlineKeyBoard;
|
||||||
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
||||||
import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert;
|
import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package dev.struchkov.godfather.telegram.simple.sender;
|
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.SendType;
|
||||||
import dev.struchkov.godfather.main.domain.SentBox;
|
import dev.struchkov.godfather.simple.domain.BoxAnswer;
|
||||||
import dev.struchkov.godfather.simple.context.service.PreSendProcessing;
|
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.domain.keyboard.InlineKeyBoard;
|
||||||
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
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.repository.SenderRepository;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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_NOTIFICATION;
|
||||||
import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW;
|
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.Checker.checkNotNull;
|
||||||
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||||
import static java.lang.Boolean.TRUE;
|
import static java.lang.Boolean.TRUE;
|
||||||
|
import static java.lang.Integer.parseInt;
|
||||||
|
|
||||||
public class TelegramSender implements TelegramSending {
|
public class TelegramSender implements TelegramSending {
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ public class TelegramSender implements TelegramSending {
|
|||||||
public void deleteMessage(@NotNull String personId, @NotNull String messageId) {
|
public void deleteMessage(@NotNull String personId, @NotNull String messageId) {
|
||||||
final DeleteMessage deleteMessage = new DeleteMessage();
|
final DeleteMessage deleteMessage = new DeleteMessage();
|
||||||
deleteMessage.setChatId(personId);
|
deleteMessage.setChatId(personId);
|
||||||
deleteMessage.setMessageId(Integer.parseInt(messageId));
|
deleteMessage.setMessageId(parseInt(messageId));
|
||||||
try {
|
try {
|
||||||
absSender.execute(deleteMessage);
|
absSender.execute(deleteMessage);
|
||||||
} catch (TelegramApiException e) {
|
} catch (TelegramApiException e) {
|
||||||
@ -115,10 +117,10 @@ public class TelegramSender implements TelegramSending {
|
|||||||
private Optional<SentBox> replace(@NotNull String telegramId, @NotNull String replaceMessageId, @NotNull BoxAnswer boxAnswer, BoxAnswer preparedAnswer, boolean saveMessageId) {
|
private Optional<SentBox> replace(@NotNull String telegramId, @NotNull String replaceMessageId, @NotNull BoxAnswer boxAnswer, BoxAnswer preparedAnswer, boolean saveMessageId) {
|
||||||
final EditMessageText editMessageText = new EditMessageText();
|
final EditMessageText editMessageText = new EditMessageText();
|
||||||
editMessageText.setChatId(telegramId);
|
editMessageText.setChatId(telegramId);
|
||||||
editMessageText.setMessageId(Integer.parseInt(replaceMessageId));
|
editMessageText.setMessageId(parseInt(replaceMessageId));
|
||||||
editMessageText.enableMarkdown(true);
|
editMessageText.enableMarkdown(true);
|
||||||
editMessageText.setText(boxAnswer.getMessage());
|
editMessageText.setText(boxAnswer.getMessage());
|
||||||
editMessageText.setReplyMarkup(KeyBoardConvert.convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard()));
|
editMessageText.setReplyMarkup(convertInlineKeyBoard((InlineKeyBoard) boxAnswer.getKeyBoard()));
|
||||||
try {
|
try {
|
||||||
absSender.execute(editMessageText);
|
absSender.execute(editMessageText);
|
||||||
return SentBox.optional(telegramId, replaceMessageId, preparedAnswer, boxAnswer);
|
return SentBox.optional(telegramId, replaceMessageId, preparedAnswer, boxAnswer);
|
||||||
@ -138,7 +140,7 @@ public class TelegramSender implements TelegramSending {
|
|||||||
sendMessage.enableMarkdown(true);
|
sendMessage.enableMarkdown(true);
|
||||||
sendMessage.setChatId(telegramId);
|
sendMessage.setChatId(telegramId);
|
||||||
sendMessage.setText(boxAnswer.getMessage());
|
sendMessage.setText(boxAnswer.getMessage());
|
||||||
sendMessage.setReplyMarkup(KeyBoardConvert.convertKeyBoard(boxAnswer.getKeyBoard()));
|
sendMessage.setReplyMarkup(convertKeyBoard(boxAnswer.getKeyBoard()));
|
||||||
|
|
||||||
boxAnswer.getPayLoad(DISABLE_WEB_PAGE_PREVIEW).ifPresent(isDisable -> {
|
boxAnswer.getPayLoad(DISABLE_WEB_PAGE_PREVIEW).ifPresent(isDisable -> {
|
||||||
if (TRUE.equals(isDisable)) sendMessage.disableWebPagePreview();
|
if (TRUE.equals(isDisable)) sendMessage.disableWebPagePreview();
|
||||||
|
Loading…
Reference in New Issue
Block a user