diff --git a/bot-context/bot-context-main/pom.xml b/bot-context/bot-context-main/pom.xml
new file mode 100644
index 0000000..0ea62f6
--- /dev/null
+++ b/bot-context/bot-context-main/pom.xml
@@ -0,0 +1,38 @@
+
+
+
+ godfather-bot
+ dev.struchkov.godfather
+ 0.0.25
+ ../../pom.xml
+
+ 4.0.0
+
+ bot-context-main
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ dev.struchkov.godfather
+ bot-domain-main
+
+
+
+ dev.struchkov.haiti
+ haiti-utils
+
+
+
+ org.jetbrains
+ annotations
+
+
+
+
\ No newline at end of file
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/SimpleKeyBoards.java b/bot-context/bot-context-main/src/main/java/dev/struchkov/godfather/main/context/utils/SimpleKeyBoards.java
similarity index 94%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/utils/SimpleKeyBoards.java
rename to bot-context/bot-context-main/src/main/java/dev/struchkov/godfather/main/context/utils/SimpleKeyBoards.java
index 3aee316..9b0555f 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/SimpleKeyBoards.java
+++ b/bot-context/bot-context-main/src/main/java/dev/struchkov/godfather/main/context/utils/SimpleKeyBoards.java
@@ -1,8 +1,8 @@
-package dev.struchkov.godfather.context.utils;
+package dev.struchkov.godfather.main.context.utils;
-import dev.struchkov.godfather.context.domain.keyboard.button.SimpleButton;
-import dev.struchkov.godfather.context.domain.keyboard.simple.SimpleKeyBoard;
-import dev.struchkov.godfather.context.domain.keyboard.simple.SimpleKeyBoardLine;
+import dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton;
+import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard;
+import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine;
import java.util.Arrays;
import java.util.List;
diff --git a/bot-context/bot-context-quarkus/pom.xml b/bot-context/bot-context-quarkus/pom.xml
new file mode 100644
index 0000000..b3a3c76
--- /dev/null
+++ b/bot-context/bot-context-quarkus/pom.xml
@@ -0,0 +1,32 @@
+
+
+
+ dev.struchkov.godfather
+ bot-context
+ 0.0.25
+
+ 4.0.0
+
+ bot-context-quarkus
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ dev.struchkov.godfather
+ bot-domain-main
+
+
+
+ io.smallrye.reactive
+ smallrye-mutiny-vertx-core
+
+
+
+
\ No newline at end of file
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Accessibility.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Accessibility.java
new file mode 100644
index 0000000..229db8d
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Accessibility.java
@@ -0,0 +1,10 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import io.smallrye.mutiny.Uni;
+
+public interface Accessibility {
+
+ Uni check(Message message);
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/ErrorHandler.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/ErrorHandler.java
new file mode 100644
index 0000000..8a4b986
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/ErrorHandler.java
@@ -0,0 +1,18 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+
+/**
+ * Используется для перехвата исключений, которые возникают при обработке юнитов.
+ */
+public interface ErrorHandler {
+
+ /**
+ * Метод, который должен как-то обработать исключение.
+ *
+ * @param message Сообщение, после которого возникло исключение.
+ * @param e Объект исключения.
+ */
+ void handle(Message message, Throwable e);
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/EventHandler.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/EventHandler.java
new file mode 100644
index 0000000..ac57bdc
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/EventHandler.java
@@ -0,0 +1,12 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.event.Event;
+import io.smallrye.mutiny.Uni;
+
+public interface EventHandler {
+
+ Uni handle(T event);
+
+ String getEventType();
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Modifiable.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Modifiable.java
new file mode 100644
index 0000000..f608f4c
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Modifiable.java
@@ -0,0 +1,18 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Интерфес для изменения запроса пользователя перед тем, как он попадет в подсистему обработки.
+ * Например можно исправить опечатки, перевести сообщение на другой язык и так далее.
+ *
+ * @author upagge [08/07/2019]
+ */
+@FunctionalInterface
+public interface Modifiable {
+
+ Uni change(@NotNull T content);
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/PersonSettingService.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/PersonSettingService.java
new file mode 100644
index 0000000..d979fc4
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/PersonSettingService.java
@@ -0,0 +1,18 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Set;
+
+public interface PersonSettingService {
+
+ Uni> getAllPersonIdDisableMessages(@NotNull Set personIds);
+
+ Uni getStateProcessingByPersonId(@NotNull Long personId);
+
+ Uni disableMessageProcessing(@NotNull Long personId);
+
+ Uni enableMessageProcessing(@NotNull Long personId);
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Pusher.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Pusher.java
new file mode 100644
index 0000000..e219865
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Pusher.java
@@ -0,0 +1,17 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import io.smallrye.mutiny.Uni;
+
+import java.util.Map;
+
+/**
+ * TODO: Добавить описание класса.
+ *
+ * @author upagge [13/07/2019]
+ */
+@FunctionalInterface
+public interface Pusher {
+
+ Uni push(Long personId, Map saveElement);
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Sending.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Sending.java
new file mode 100644
index 0000000..8c28e7d
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/Sending.java
@@ -0,0 +1,29 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.BoxAnswer;
+import dev.struchkov.godfather.main.domain.SendType;
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Интерфейс для отправки ответов пользователю.
+ *
+ * @author upagge [08/07/2019]
+ */
+public interface Sending {
+
+ /**
+ * Отрпавляет ответ пользователю
+ *
+ * @param personId Идентификатор пользователя
+ * @param boxAnswer Объект с данными, которые необходимо отправить
+ */
+ Uni send(@NotNull Long personId, @NotNull BoxAnswer boxAnswer);
+
+ /**
+ * Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью
+ * разных методов.
+ */
+ SendType getType();
+
+}
diff --git a/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/UnitPointerService.java b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/UnitPointerService.java
new file mode 100644
index 0000000..9f652b1
--- /dev/null
+++ b/bot-context/bot-context-quarkus/src/main/java/dev/struchkov/godfather/quarkus/context/service/UnitPointerService.java
@@ -0,0 +1,20 @@
+package dev.struchkov.godfather.quarkus.context.service;
+
+import dev.struchkov.godfather.main.domain.UnitPointer;
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Сервис для взаимодействия с сущностью {@link UnitPointer}.
+ *
+ * @author upagge [07/07/2019]
+ */
+public interface UnitPointerService {
+
+ Uni save(@NotNull UnitPointer unitPointer);
+
+ Uni getUnitNameByPersonId(@NotNull Long personId);
+
+ Uni removeByPersonId(@NotNull Long personId);
+
+}
diff --git a/bot-context/bot-context-simple/pom.xml b/bot-context/bot-context-simple/pom.xml
new file mode 100644
index 0000000..a651bf3
--- /dev/null
+++ b/bot-context/bot-context-simple/pom.xml
@@ -0,0 +1,27 @@
+
+
+
+ dev.struchkov.godfather
+ bot-context
+ 0.0.25
+
+ 4.0.0
+
+ bot-context-simple
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ dev.struchkov.godfather
+ bot-domain-main
+
+
+
+
\ No newline at end of file
diff --git a/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Accessibility.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Accessibility.java
new file mode 100644
index 0000000..6bae13e
--- /dev/null
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Accessibility.java
@@ -0,0 +1,9 @@
+package dev.struchkov.godfather.simple.context.service;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+
+public interface Accessibility {
+
+ boolean check(Message message);
+
+}
diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/service/ErrorHandler.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/ErrorHandler.java
similarity index 82%
rename from bot-core/src/main/java/dev/struchkov/godfather/core/service/ErrorHandler.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/ErrorHandler.java
index 1c20c19..1486a6c 100644
--- a/bot-core/src/main/java/dev/struchkov/godfather/core/service/ErrorHandler.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/ErrorHandler.java
@@ -1,6 +1,6 @@
-package dev.struchkov.godfather.core.service;
+package dev.struchkov.godfather.simple.context.service;
-import dev.struchkov.godfather.context.domain.content.Message;
+import dev.struchkov.godfather.main.domain.content.Message;
/**
* Используется для перехвата исключений, которые возникают при обработке юнитов.
diff --git a/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/EventHandler.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/EventHandler.java
new file mode 100644
index 0000000..be87522
--- /dev/null
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/EventHandler.java
@@ -0,0 +1,11 @@
+package dev.struchkov.godfather.simple.context.service;
+
+import dev.struchkov.godfather.main.domain.event.Event;
+
+public interface EventHandler {
+
+ void handle(T event);
+
+ String getEventType();
+
+}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/Modifiable.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Modifiable.java
similarity index 81%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/service/Modifiable.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Modifiable.java
index dd4231c..020edda 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/Modifiable.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Modifiable.java
@@ -1,6 +1,6 @@
-package dev.struchkov.godfather.context.service;
+package dev.struchkov.godfather.simple.context.service;
-import dev.struchkov.godfather.context.domain.content.Message;
+import dev.struchkov.godfather.main.domain.content.Message;
import org.jetbrains.annotations.NotNull;
/**
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/PersonSettingService.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/PersonSettingService.java
similarity index 87%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/service/PersonSettingService.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/PersonSettingService.java
index 972d0ae..887ce55 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/PersonSettingService.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/PersonSettingService.java
@@ -1,4 +1,4 @@
-package dev.struchkov.godfather.context.service;
+package dev.struchkov.godfather.simple.context.service;
import org.jetbrains.annotations.NotNull;
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/save/Pusher.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Pusher.java
similarity index 80%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/service/save/Pusher.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Pusher.java
index fcc9781..590df81 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/save/Pusher.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Pusher.java
@@ -1,4 +1,4 @@
-package dev.struchkov.godfather.context.service.save;
+package dev.struchkov.godfather.simple.context.service;
import java.util.Map;
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/sender/Sending.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Sending.java
similarity index 83%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/service/sender/Sending.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Sending.java
index 038c933..9113ff1 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/sender/Sending.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/Sending.java
@@ -1,6 +1,7 @@
-package dev.struchkov.godfather.context.service.sender;
+package dev.struchkov.godfather.simple.context.service;
-import dev.struchkov.godfather.context.domain.BoxAnswer;
+import dev.struchkov.godfather.main.domain.BoxAnswer;
+import dev.struchkov.godfather.main.domain.SendType;
import org.jetbrains.annotations.NotNull;
/**
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitPointerService.java b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/UnitPointerService.java
similarity index 79%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitPointerService.java
rename to bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/UnitPointerService.java
index 404429f..d21241e 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitPointerService.java
+++ b/bot-context/bot-context-simple/src/main/java/dev/struchkov/godfather/simple/context/service/UnitPointerService.java
@@ -1,6 +1,6 @@
-package dev.struchkov.godfather.context.service;
+package dev.struchkov.godfather.simple.context.service;
-import dev.struchkov.godfather.context.domain.UnitPointer;
+import dev.struchkov.godfather.main.domain.UnitPointer;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
diff --git a/bot-context/pom.xml b/bot-context/pom.xml
index 5e82316..80608ce 100644
--- a/bot-context/pom.xml
+++ b/bot-context/pom.xml
@@ -10,6 +10,13 @@
bot-context
+ pom
+
+ bot-context-main
+ bot-context-simple
+ bot-context-quarkus
+
+
Bot Context
Доменные сущности, интерфейсы, для библиотеки Godfather
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BasicEntity.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BasicEntity.java
deleted file mode 100644
index f175800..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BasicEntity.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package dev.struchkov.godfather.context.domain;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-
-/**
- * Основная сущность для сокрытия id у других сущностей.
- *
- * @author upagge [28/07/2019]
- */
-@MappedSuperclass
-public class BasicEntity {
-
- @Id
- @GeneratedValue
- protected Long id;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/Clarification.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/Clarification.java
deleted file mode 100644
index 9af7946..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/Clarification.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package dev.struchkov.godfather.context.domain;
-
-public class Clarification {
-
- private BoxAnswer question;
- private String value;
-
- public Clarification(BoxAnswer question, String value) {
- this.question = question;
- this.value = value;
- }
-
- public BoxAnswer getQuestion() {
- return question;
- }
-
- public String getValue() {
- return value;
- }
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/attachment/Attachment.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/attachment/Attachment.java
deleted file mode 100644
index 453c9cb..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/attachment/Attachment.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package dev.struchkov.godfather.context.domain.content.attachment;
-
-import dev.struchkov.godfather.context.domain.BasicEntity;
-
-import javax.persistence.Entity;
-
-/**
- * Абстрактная сущность, для всех вложений к сообщениям от пользователей.
- *
- * @author upagge [08/07/2019]
- */
-@Entity
-public abstract class Attachment extends BasicEntity {
-
- public abstract String getType();
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/exception/TimerSettingException.java b/bot-context/src/main/java/dev/struchkov/godfather/context/exception/TimerSettingException.java
deleted file mode 100644
index ab30bdd..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/exception/TimerSettingException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package dev.struchkov.godfather.context.exception;
-
-/**
- * Ошибка таймера.
- *
- * @author upagge [08/07/2019]
- */
-public class TimerSettingException extends AppBotException {
-
- public TimerSettingException(String message) {
- super(message);
- }
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/Accessibility.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/Accessibility.java
deleted file mode 100644
index f76fc5c..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/Accessibility.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.content.Message;
-
-public interface Accessibility {
-
- boolean check(Message message);
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/ClarificationQuestion.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/ClarificationQuestion.java
deleted file mode 100644
index 18bc266..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/ClarificationQuestion.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.Clarification;
-import dev.struchkov.godfather.context.domain.content.Message;
-
-@FunctionalInterface
-public interface ClarificationQuestion {
-
- Clarification getClarification(C message);
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventHandler.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventHandler.java
deleted file mode 100644
index 5eb9923..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventHandler.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.event.Event;
-
-public interface EventHandler {
-
- void handle(T event);
-
- String getEventType();
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/MailService.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/MailService.java
deleted file mode 100644
index 4fe5f5f..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/MailService.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.content.Mail;
-
-/**
- * Интерфейс для взаимодействия с личными сообщениями.
- *
- * @author upagge [08/07/2019]
- */
-public interface MailService extends MessageService {
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/MessageService.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/MessageService.java
deleted file mode 100644
index 7293f23..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/MessageService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.content.Message;
-import org.jetbrains.annotations.NotNull;
-
-import java.time.LocalDateTime;
-import java.util.List;
-
-/**
- * Интерфейс взаимодйствия с наследниками текстовых сообщений пользователей.
- *
- * @author upagge [08/07/2019]
- */
-public interface MessageService {
-
- void add(@NotNull T event);
-
- /**
- * Получить список сообщений за заданный временной интервал
- *
- * @param dateFrom Начало интервала
- * @param dateTo Конец интервала
- * @return Список сообщений
- */
- List getByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
-
- /**
- * Получить список ПОСЛЕДНИХ сообщений для каждого пользователя за заданных временной интервал
- *
- * @param dateFrom Начало интервала
- * @param dateTo Конец интервала
- * @return Список сообщений
- */
- List getLastEventByCreateDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
-
- List getLastEventByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
-
- /**
- * Возвращает новые сообщения от последнего запроса.
- */
- List getNewMessage();
-
- void deleteAllByAddDateBetween(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
-
- void deleteAllByAddDateBefore(@NotNull LocalDateTime date);
-
- void deleteAllByAddDateAfter(@NotNull LocalDateTime date);
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitContextFactory.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitContextFactory.java
deleted file mode 100644
index d33aba7..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/UnitContextFactory.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package dev.struchkov.godfather.context.service;
-
-import dev.struchkov.godfather.context.domain.content.Message;
-import dev.struchkov.godfather.context.domain.unit.AnswerText;
-
-public interface UnitContextFactory {
-
- AnswerText.Builder createAnswerText();
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/save/PreservableData.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/save/PreservableData.java
deleted file mode 100644
index ec210d7..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/save/PreservableData.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package dev.struchkov.godfather.context.service.save;
-
-import dev.struchkov.godfather.context.domain.content.Message;
-
-@FunctionalInterface
-public interface PreservableData {
-
- D getData(M content);
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/usercode/CheckData.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/usercode/CheckData.java
deleted file mode 100644
index f153164..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/usercode/CheckData.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package dev.struchkov.godfather.context.service.usercode;
-
-import dev.struchkov.godfather.context.domain.content.Message;
-
-@FunctionalInterface
-public interface CheckData {
-
- boolean checked(C content);
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/MessageUtils.java b/bot-context/src/main/java/dev/struchkov/godfather/context/utils/MessageUtils.java
deleted file mode 100644
index 1e00301..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/MessageUtils.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package dev.struchkov.godfather.context.utils;
-
-import dev.struchkov.godfather.context.domain.content.EmptyMessage;
-import dev.struchkov.godfather.context.domain.content.Message;
-
-/**
- * Класс для хранения объекта заглушки для {@link Message}.
- *
- * @author upagge [08/07/2019]
- */
-public class MessageUtils {
-
- public static final EmptyMessage EMPTY_MESSAGE = new EmptyMessage();
-
- private MessageUtils() {
- throw new IllegalStateException(Messages.UTILITY_CLASS);
- }
-
-}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/Messages.java b/bot-context/src/main/java/dev/struchkov/godfather/context/utils/Messages.java
deleted file mode 100644
index 4e9d7ab..0000000
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/Messages.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package dev.struchkov.godfather.context.utils;
-
-/**
- * Класс утилита, содержащий сообщения об ошибках, и сообщения логирования.
- *
- * @author upagge [15/08/2019]
- */
-public class Messages {
-
- public static final String UTILITY_CLASS = "Класс утилита";
-
- private Messages() {
- throw new IllegalStateException(UTILITY_CLASS);
- }
-
-}
diff --git a/bot-core/bot-core-main/pom.xml b/bot-core/bot-core-main/pom.xml
new file mode 100644
index 0000000..23cae53
--- /dev/null
+++ b/bot-core/bot-core-main/pom.xml
@@ -0,0 +1,27 @@
+
+
+
+ dev.struchkov.godfather
+ bot-core
+ 0.0.25
+
+ 4.0.0
+
+ bot-core-main
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ dev.struchkov.godfather
+ bot-domain-main
+
+
+
+
\ No newline at end of file
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/TypeUnit.java b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/TypeUnit.java
similarity index 77%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/domain/TypeUnit.java
rename to bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/TypeUnit.java
index bfd9f39..367728b 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/TypeUnit.java
+++ b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/TypeUnit.java
@@ -1,4 +1,4 @@
-package dev.struchkov.godfather.context.domain;
+package dev.struchkov.godfather.main.core.unit;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
@@ -13,10 +13,8 @@ public class TypeUnit {
public static final String SAVE = "SAVE";
public static final String TIMER = "TIMER";
public static final String CHECK = "CHECK";
- public static final String VALIDITY = "VALIDITY";
public static final String BACK_CMD = "BACK_CMD";
- public static final String TELEPORT_CMD = "TELEPORT_CMD";
public static final String REPLACE_CMD = "REPLACE_CMD";
private TypeUnit() {
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/UnitActiveType.java b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/UnitActiveType.java
similarity index 78%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/UnitActiveType.java
rename to bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/UnitActiveType.java
index 569317f..76a70c9 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/UnitActiveType.java
+++ b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/unit/UnitActiveType.java
@@ -1,4 +1,4 @@
-package dev.struchkov.godfather.context.domain.unit;
+package dev.struchkov.godfather.main.core.unit;
/**
* Тип активации Unit-а. Определяет порядок обработки Unit.
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/InsertWords.java b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/InsertWords.java
similarity index 96%
rename from bot-context/src/main/java/dev/struchkov/godfather/context/utils/InsertWords.java
rename to bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/InsertWords.java
index fa120ae..6a0b49f 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/utils/InsertWords.java
+++ b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/InsertWords.java
@@ -1,4 +1,4 @@
-package dev.struchkov.godfather.context.utils;
+package dev.struchkov.godfather.main.core.utils;
import org.jetbrains.annotations.NotNull;
diff --git a/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/MessageUtils.java b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/MessageUtils.java
new file mode 100644
index 0000000..b25457c
--- /dev/null
+++ b/bot-core/bot-core-main/src/main/java/dev/struchkov/godfather/main/core/utils/MessageUtils.java
@@ -0,0 +1,21 @@
+package dev.struchkov.godfather.main.core.utils;
+
+import dev.struchkov.godfather.main.domain.content.EmptyMessage;
+import dev.struchkov.godfather.main.domain.content.Message;
+
+import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
+
+/**
+ * Класс для хранения объекта заглушки для {@link Message}.
+ *
+ * @author upagge [08/07/2019]
+ */
+public final class MessageUtils {
+
+ public static final EmptyMessage EMPTY_MESSAGE = new EmptyMessage();
+
+ private MessageUtils() {
+ utilityClass();
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/pom.xml b/bot-core/bot-core-quarkus/pom.xml
new file mode 100644
index 0000000..c13f6bf
--- /dev/null
+++ b/bot-core/bot-core-quarkus/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+ dev.struchkov.godfather
+ bot-core
+ 0.0.25
+
+ 4.0.0
+
+ bot-core-quarkus
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ dev.struchkov.godfather
+ bot-core-main
+
+
+ dev.struchkov.godfather
+ bot-context-quarkus
+
+
+ dev.struchkov.godfather
+ bot-data-quarkus
+
+
+
+ io.smallrye.reactive
+ smallrye-mutiny-vertx-core
+ true
+
+
+
+
\ No newline at end of file
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/GeneralAutoResponder.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/GeneralAutoResponder.java
new file mode 100644
index 0000000..65d2d23
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/GeneralAutoResponder.java
@@ -0,0 +1,221 @@
+package dev.struchkov.godfather.quarkus.core;
+
+import dev.struchkov.autoresponder.Responder;
+import dev.struchkov.godfather.exception.ConfigAppException;
+import dev.struchkov.godfather.main.core.unit.TypeUnit;
+import dev.struchkov.godfather.main.core.unit.UnitActiveType;
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.context.service.ErrorHandler;
+import dev.struchkov.godfather.quarkus.context.service.Modifiable;
+import dev.struchkov.godfather.quarkus.context.service.PersonSettingService;
+import dev.struchkov.godfather.quarkus.context.service.Sending;
+import dev.struchkov.godfather.quarkus.core.action.ActionUnit;
+import dev.struchkov.godfather.quarkus.core.action.AnswerCheckAction;
+import dev.struchkov.godfather.quarkus.core.action.AnswerSaveAction;
+import dev.struchkov.godfather.quarkus.core.action.AnswerTextAction;
+import dev.struchkov.godfather.quarkus.core.action.cmd.ReplaceCmdAction;
+import dev.struchkov.godfather.quarkus.core.service.StorylineService;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import dev.struchkov.haiti.context.exception.NotFoundException;
+import io.smallrye.mutiny.Multi;
+import io.smallrye.mutiny.Uni;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;
+import static dev.struchkov.haiti.utils.Checker.checkNotNull;
+import static dev.struchkov.haiti.utils.Checker.checkNull;
+
+public class GeneralAutoResponder {
+
+ private final PersonSettingService personSettingService;
+ private final StorylineService storyLineService;
+ protected Map actionUnitMap = new HashMap<>();
+ protected List> modifiable;
+ private ErrorHandler errorHandler;
+
+ protected GeneralAutoResponder(
+ Sending sending,
+ PersonSettingService personSettingService,
+ StorylineService storyLineService
+ ) {
+ this.personSettingService = personSettingService;
+ this.storyLineService = storyLineService;
+ init(sending);
+ }
+
+ private void init(Sending sending) {
+ actionUnitMap.put(TypeUnit.CHECK, new AnswerCheckAction<>());
+ actionUnitMap.put(TypeUnit.TEXT, new AnswerTextAction(sending));
+ actionUnitMap.put(TypeUnit.REPLACE_CMD, new ReplaceCmdAction());
+ }
+
+ public void initModifiable(List> modifiable) {
+ this.modifiable = modifiable;
+ }
+
+ public void initActionUnit(String typeUnit, ActionUnit extends MainUnit, M> actionUnit) {
+ if (!actionUnitMap.containsKey(typeUnit)) {
+ actionUnitMap.put(typeUnit, actionUnit);
+ } else {
+ throw new ConfigAppException("Обработка такого типа юнита уже зарегистрирована");
+ }
+ }
+
+ public void initSaveAction(AnswerSaveAction answerSaveAction) {
+ actionUnitMap.put(TypeUnit.SAVE, answerSaveAction);
+ }
+
+ /**
+ * Позволяет установить перехватчик и обработчик исключений, возникающих при обработке юнитов.
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ public void setDefaultUnit(String unitName) {
+ storyLineService.setDefaultUnit(unitName);
+ }
+
+ public Uni processingNewMessage(M newMessage) {
+ if (newMessage != null) {
+ return personSettingService.getStateProcessingByPersonId(newMessage.getPersonId())
+ .onItem().transformToUni(
+ state -> {
+ if (checkNull(state) || state) {
+ return processing(newMessage);
+ }
+ return Uni.createFrom().voidItem();
+ }
+ );
+ }
+ return Uni.createFrom().voidItem();
+ }
+
+ public Uni processingNewMessages(List newMessages) {
+ if (newMessages != null && !newMessages.isEmpty()) {
+ final Set personIds = newMessages.stream()
+ .map(Message::getPersonId)
+ .collect(Collectors.toSet());
+ return personSettingService.getAllPersonIdDisableMessages(personIds)
+ .onItem().transformToMulti(
+ disableIds -> {
+ final List allowedMessages = newMessages.stream()
+ .filter(message -> !disableIds.contains(message.getPersonId()))
+ .toList();
+ return Multi.createFrom().iterable(allowedMessages);
+ }
+ )
+ .onItem().transform(this::processing)
+ .toUni().replaceWithVoid();
+ }
+ return Uni.createFrom().voidItem();
+ }
+
+ private Uni processing(M message) {
+ return Uni.createFrom().item(message)
+ .onItem().transformToUni(
+ mail -> {
+ if (checkNotEmpty(modifiable)) {
+ return Multi.createFrom().iterable(modifiable)
+ .onItem().transformToUni(m -> m.change(mail))
+ .concatenate().toUni().replaceWith(mail);
+ }
+ return Uni.createFrom().item(mail);
+ }
+ ).onItem().transformToUni(
+ mail -> {
+ final Uni>> uniUnits = storyLineService.getNextUnitByPersonId(mail.getPersonId());
+ return Uni.combine().all().unis(uniUnits, Uni.createFrom().item(mail)).asTuple();
+ }
+ ).onItem().transformToUni(
+ t -> {
+ final Set> units = t.getItem1();
+ final M mail = t.getItem2();
+ final Optional> optAnswer = Responder.nextUnit(mail, units).or(storyLineService::getDefaultUnit);
+ if (optAnswer.isPresent()) {
+ final MainUnit answer = optAnswer.get();
+ //TODO [05.08.2022]: нужно ли проверку встраивать в поток?
+// if (checkPermission(answer.getAccessibility(), message)) {
+ return answer(UnitRequest.of(answer, message));
+// }
+ }
+ return Uni.createFrom().voidItem();
+ }
+ );
+ }
+
+// private boolean checkPermission(Optional accessibility, M message) {
+// return accessibility.isEmpty() || accessibility.get().check(message);
+// }
+
+ public Uni answer(UnitRequest unitRequest) {
+ return getAction(unitRequest)
+ .onItem().transformToUni(
+ request -> activeUnitAfter(unitRequest)
+ )
+ .onFailure().invoke(
+ throwable -> {
+ if (errorHandler != null) {
+ errorHandler.handle(unitRequest.getMessage(), throwable);
+ }
+ }
+ )
+ .replaceWithVoid();
+ }
+
+ private Uni> activeUnitAfter(UnitRequest unitRequest) {
+ final Set> nextUnits = unitRequest.getUnit().getNextUnits();
+ if (checkNotNull(nextUnits)) {
+ Optional> first = nextUnits.stream()
+ .filter(unit -> UnitActiveType.AFTER.equals(unit.getActiveType()))
+ .findFirst();
+ if (first.isPresent()) {
+ return Uni.createFrom().voidItem().onItem().transformToUni(
+ v-> getAction(UnitRequest.of(first.get(), unitRequest.getMessage()))
+ )
+ .onItem().transformToUni(
+ uR -> activeUnitAfter(UnitRequest.of(first.get(), unitRequest.getMessage()))
+ );
+ }
+ }
+ return Uni.createFrom().item(unitRequest);
+ }
+
+ private Uni> getAction(UnitRequest unitRequest) {
+ final MainUnit unit = unitRequest.getUnit();
+ final M message = unitRequest.getMessage();
+ final String typeUnit = unit.getType();
+ if (actionUnitMap.containsKey(typeUnit)) {
+ ActionUnit actionUnit = actionUnitMap.get(typeUnit);
+ return actionUnit.action(unitRequest)
+ .onItem().transformToUni(
+ newUnitRequest -> {
+ final Optional> optDefaultUnit = storyLineService.getDefaultUnit();
+ if (!unit.isNotSaveHistory() && (optDefaultUnit.isEmpty() || !optDefaultUnit.get().equals(unit))) {
+ return Uni.combine().all().unis(
+ Uni.createFrom().item(newUnitRequest),
+ storyLineService.save(message.getPersonId(), unit.getName(), message)
+ ).asTuple();
+ }
+ return Uni.combine().all().unis(Uni.createFrom().item(newUnitRequest), Uni.createFrom().voidItem()).asTuple();
+ }
+ ).onItem().transformToUni(
+ t -> {
+ final UnitRequest newUnitRequest = t.getItem1();
+ final MainUnit newUnit = newUnitRequest.getUnit();
+ return !unit.equals(newUnit) ? getAction(newUnitRequest) : Uni.createFrom().item(unitRequest);
+ }
+ );
+ } else {
+ throw new NotFoundException("ActionUnit для типа {0} не зарегистрирован", unit.getType());
+ }
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/Storyline.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/Storyline.java
new file mode 100644
index 0000000..d6ebf95
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/Storyline.java
@@ -0,0 +1,61 @@
+package dev.struchkov.godfather.quarkus.core;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static dev.struchkov.haiti.utils.Checker.checkNull;
+import static dev.struchkov.haiti.utils.Inspector.isNotNull;
+
+public class Storyline {
+
+ private final Set> startingUnits = new HashSet<>();
+ private final Set> globalUnits = new HashSet<>();
+ private final Map> units = new HashMap<>();
+
+ public Storyline(Set> startingUnits, Map> units) {
+ this.startingUnits.addAll(startingUnits);
+ this.units.putAll(units);
+ }
+
+ public void addGlobalUnits(Set> globalUnits) {
+ this.globalUnits.addAll(globalUnits);
+ }
+
+ public Set> getGlobalUnits() {
+ return globalUnits;
+ }
+
+ /**
+ * Получить юнит по названию.
+ *
+ * @param unitName Название юнита.
+ */
+ public Optional> getUnit(String unitName) {
+ isNotNull(unitName);
+ return Optional.ofNullable(units.get(unitName));
+ }
+
+ public Set> getStartingUnits() {
+ return startingUnits;
+ }
+
+ //TODO [22.06.2022]: Временное решение ленивой связки юнитов, пока не будет реализован нормальный механизм.
+ public void link(@NotNull String firstName, @NotNull String secondName) {
+ isNotNull(firstName, secondName);
+ final MainUnit firstUnit = units.get(firstName);
+ final MainUnit secondUnit = units.get(secondName);
+ isNotNull(firstUnit, secondUnit);
+ if (checkNull(firstUnit.getNextUnits())) {
+ firstUnit.setNextUnits(new HashSet<>());
+ }
+ firstUnit.getNextUnits().add(secondUnit);
+ }
+
+}
diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineFactory.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/StorylineFactory.java
similarity index 93%
rename from bot-core/src/main/java/dev/struchkov/godfather/core/StorylineFactory.java
rename to bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/StorylineFactory.java
index d2f1cbb..d03e309 100644
--- a/bot-core/src/main/java/dev/struchkov/godfather/core/StorylineFactory.java
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/StorylineFactory.java
@@ -1,10 +1,10 @@
-package dev.struchkov.godfather.core;
+package dev.struchkov.godfather.quarkus.core;
-import dev.struchkov.godfather.context.domain.UnitDefinition;
-import dev.struchkov.godfather.context.domain.annotation.Unit;
-import dev.struchkov.godfather.context.domain.content.Message;
-import dev.struchkov.godfather.context.domain.unit.MainUnit;
-import dev.struchkov.godfather.context.exception.UnitConfigException;
+import dev.struchkov.godfather.exception.UnitConfigException;
+import dev.struchkov.godfather.main.domain.UnitDefinition;
+import dev.struchkov.godfather.main.domain.annotation.Unit;
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
import dev.struchkov.haiti.utils.Inspector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,7 +21,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import static dev.struchkov.godfather.context.exception.UnitConfigException.unitConfigException;
+import static dev.struchkov.godfather.exception.UnitConfigException.unitConfigException;
public class StorylineFactory {
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/ActionUnit.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/ActionUnit.java
new file mode 100644
index 0000000..a1f8a36
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/ActionUnit.java
@@ -0,0 +1,23 @@
+package dev.struchkov.godfather.quarkus.core.action;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import io.smallrye.mutiny.Uni;
+
+/**
+ * Интерфейс для обработки Unit-ов.
+ *
+ * @author upagge [11/07/2019]
+ */
+@FunctionalInterface
+public interface ActionUnit {
+
+ /**
+ * Метод обработки Unit-а.
+ *
+ * @return Новый Unit, который может нуждаться в обработке
+ */
+ Uni> action(UnitRequest unitRequest);
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerCheckAction.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerCheckAction.java
new file mode 100644
index 0000000..d2cb4d6
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerCheckAction.java
@@ -0,0 +1,36 @@
+package dev.struchkov.godfather.quarkus.core.action;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.unit.AnswerCheck;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import io.smallrye.mutiny.Uni;
+
+import java.util.Objects;
+
+import static dev.struchkov.haiti.utils.Checker.checkNotNull;
+
+/**
+ * Обработчик Unit-а {@link AnswerCheck}.
+ *
+ * @author upagge [11/07/2019]
+ */
+public class AnswerCheckAction implements ActionUnit, M> {
+
+ @Override
+ public Uni> action(UnitRequest, M> unitRequest) {
+ final AnswerCheck unit = unitRequest.getUnit();
+ final M message = unitRequest.getMessage();
+
+ return unit.getCheck().checked(message)
+ .onItem().transform(
+ checkValue -> {
+ if (checkNotNull(checkValue) && checkValue) {
+ return UnitRequest.of(Objects.requireNonNullElse(unit.getUnitTrue(), unit), message);
+ } else {
+ return UnitRequest.of(Objects.requireNonNullElse(unit.getUnitFalse(), unit), message);
+ }
+ }
+ );
+ }
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerSaveAction.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerSaveAction.java
new file mode 100644
index 0000000..996c7e3
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerSaveAction.java
@@ -0,0 +1,75 @@
+package dev.struchkov.godfather.quarkus.core.action;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.context.service.Pusher;
+import dev.struchkov.godfather.quarkus.core.unit.AnswerSave;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import dev.struchkov.godfather.quarkus.core.unit.func.CheckSave;
+import dev.struchkov.godfather.quarkus.core.unit.func.PreservableData;
+import dev.struchkov.godfather.quarkus.data.preser.AnswerSavePreservable;
+import io.smallrye.mutiny.Uni;
+
+import static dev.struchkov.haiti.utils.Checker.checkNotNull;
+
+/**
+ * Обработчик Unit-а {@link AnswerSave}.
+ *
+ * @author upagge [11/07/2019]
+ */
+public class AnswerSaveAction implements ActionUnit, M> {
+
+ @Override
+ public Uni> action(UnitRequest, M> unitRequest) {
+ final AnswerSave answerSave = unitRequest.getUnit();
+ final M message = unitRequest.getMessage();
+
+ final AnswerSavePreservable preservable = answerSave.getPreservable();
+ final Long personId = message.getPersonId();
+
+ final CheckSave checkSave = answerSave.getCheckSave();
+ if (checkNotNull(checkSave)) {
+ return Uni.createFrom().voidItem()
+ .onItem().transformToUni(
+ v -> checkSave.check(message)
+ .onItem().transform(
+ unit -> {
+ if (checkNotNull(unit)) {
+ return UnitRequest.of(unit, message);
+ }
+ return UnitRequest.of(answerSave, message);
+ }
+ )
+ );
+ }
+
+ final PreservableData preservableData = answerSave.getPreservableData();
+ final Pusher pusher = answerSave.getPusher();
+
+ return Uni.createFrom().voidItem()
+ .onItem().transformToUni(
+ v -> {
+ if (checkNotNull(preservableData)) {
+ return preservableData.getData(message);
+ }
+ return Uni.createFrom().nullItem();
+ }
+ ).onItem().transformToUni(
+ dataFromSave -> {
+ if (checkNotNull(dataFromSave)) {
+ return preservable.save(personId, answerSave.getKey(), dataFromSave);
+ }
+ return Uni.createFrom().nullItem();
+ }
+ ).onItem().transformToUni(
+ v -> {
+ if (checkNotNull(pusher)) {
+ return preservable.push(personId, pusher);
+ }
+ return Uni.createFrom().nullItem();
+ }
+ ).onItem().transform(
+ v -> UnitRequest.of(answerSave, message)
+ );
+ }
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerTextAction.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerTextAction.java
new file mode 100644
index 0000000..e1a9adc
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/AnswerTextAction.java
@@ -0,0 +1,75 @@
+package dev.struchkov.godfather.quarkus.core.action;
+
+import dev.struchkov.godfather.main.core.utils.InsertWords;
+import dev.struchkov.godfather.main.domain.BoxAnswer;
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.context.service.Sending;
+import dev.struchkov.godfather.quarkus.core.unit.AnswerText;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import dev.struchkov.godfather.quarkus.core.utils.Sender;
+import io.smallrye.mutiny.Uni;
+
+import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;
+import static dev.struchkov.haiti.utils.Checker.checkNotNull;
+
+/**
+ * Обработчик Unit-а {@link AnswerText}.
+ *
+ * @author upagge [11/07/2019]
+ */
+public class AnswerTextAction implements ActionUnit, Message> {
+
+ private final Sending sending;
+
+ public AnswerTextAction(Sending sending) {
+ this.sending = sending;
+ }
+
+ @Override
+ public Uni> action(UnitRequest, Message> unitRequest) {
+ final AnswerText unit = unitRequest.getUnit();
+ final Message message = unitRequest.getMessage();
+
+ return unit.getAnswer().processing(message)
+ .onItem().transformToUni(
+ boxAnswer -> {
+ if (checkNotNull(boxAnswer)) {
+ return replaceMarkers(unit, message, boxAnswer);
+ }
+ return Uni.createFrom().nullItem();
+ }
+ ).onItem().transformToUni(
+ boxAnswer -> {
+ if (checkNotNull(boxAnswer)) {
+ final Sending answerTextSending = unit.getSending();
+ if (answerTextSending != null) {
+ return Sender.sends(message, boxAnswer, answerTextSending);
+ } else {
+ return Sender.sends(message, boxAnswer, this.sending);
+ }
+ }
+ return Uni.createFrom().nullItem();
+ }
+ ).onItem().transform(
+ v -> UnitRequest.of(unit, message)
+ );
+ }
+
+ private Uni replaceMarkers(AnswerText answerText, Message message, BoxAnswer boxAnswer) {
+ if (answerText.getInsert() != null) {
+ return answerText.getInsert().insert(message.getPersonId())
+ .onItem().transformToUni(
+ words -> {
+ if (checkNotEmpty(words)) {
+ final String newMessage = InsertWords.insert(boxAnswer.getMessage(), words);
+ boxAnswer.setMessage(newMessage);
+ }
+ return Uni.createFrom().item(boxAnswer);
+ }
+ );
+ }
+ return Uni.createFrom().item(boxAnswer);
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/ReplaceCmdAction.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/ReplaceCmdAction.java
new file mode 100644
index 0000000..c29dfb0
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/ReplaceCmdAction.java
@@ -0,0 +1,19 @@
+package dev.struchkov.godfather.quarkus.core.action.cmd;
+
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.action.ActionUnit;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import dev.struchkov.godfather.quarkus.core.unit.cmd.ReplaceCmd;
+import io.smallrye.mutiny.Uni;
+
+public class ReplaceCmdAction implements ActionUnit, Message> {
+
+ @Override
+ public Uni> action(UnitRequest, Message> unitRequest) {
+ final ReplaceCmd unit = unitRequest.getUnit();
+ final Message message = unitRequest.getMessage();
+ return Uni.createFrom().item(UnitRequest.of(unit.getThisUnit(), message));
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/RollBackCmdAction.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/RollBackCmdAction.java
new file mode 100644
index 0000000..e20f218
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/action/cmd/RollBackCmdAction.java
@@ -0,0 +1,45 @@
+package dev.struchkov.godfather.quarkus.core.action.cmd;
+
+import dev.struchkov.godfather.main.domain.StorylineHistory;
+import dev.struchkov.godfather.main.domain.content.Message;
+import dev.struchkov.godfather.quarkus.core.action.ActionUnit;
+import dev.struchkov.godfather.quarkus.core.service.StorylineService;
+import dev.struchkov.godfather.quarkus.core.unit.MainUnit;
+import dev.struchkov.godfather.quarkus.core.unit.UnitRequest;
+import dev.struchkov.godfather.quarkus.core.unit.cmd.RollBackCmd;
+import io.smallrye.mutiny.Uni;
+
+import static dev.struchkov.godfather.exception.RollBackException.rollBackException;
+
+public class RollBackCmdAction implements ActionUnit, M> {
+
+ private final StorylineService storyLineService;
+
+ public RollBackCmdAction(StorylineService storyLineService) {
+ this.storyLineService = storyLineService;
+ }
+
+ @Override
+ public Uni> action(UnitRequest, M> unitRequest) {
+ final RollBackCmd unit = unitRequest.getUnit();
+ final M message = unitRequest.getMessage();
+
+ final int countToBack = unit.getCountBack();
+ final String rollbackUnitName = unit.getRollbackUnitName();
+
+ final Uni uniHistory = (rollbackUnitName != null)
+ ? storyLineService.replaceUserToBack(message.getPersonId(), rollbackUnitName).onItem().ifNull().failWith(rollBackException("Юнит для возвращения не был найден"))
+ : storyLineService.replaceUserToBack(message.getPersonId(), countToBack).onItem().ifNull().failWith(rollBackException("Юнит для возвращения не был найден"));
+
+ return uniHistory
+ .onItem().transform(
+ history -> {
+ final String unitName = history.getUnitName();
+ final MainUnit nextUnit = storyLineService.getUnitByName(unitName).orElse(unit);
+ final M oldMessage = (M) history.getMessage();
+ return UnitRequest.of(nextUnit, oldMessage);
+ }
+ );
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/provider/StoryLineHandler.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/provider/StoryLineHandler.java
new file mode 100644
index 0000000..691629a
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/provider/StoryLineHandler.java
@@ -0,0 +1,26 @@
+package dev.struchkov.godfather.quarkus.core.provider;
+
+import dev.struchkov.godfather.main.domain.content.Mail;
+import dev.struchkov.godfather.quarkus.context.service.EventHandler;
+import dev.struchkov.godfather.quarkus.core.GeneralAutoResponder;
+import io.smallrye.mutiny.Uni;
+
+public class StoryLineHandler implements EventHandler {
+
+ private final GeneralAutoResponder generalAutoResponder;
+
+ public StoryLineHandler(GeneralAutoResponder generalAutoResponder) {
+ this.generalAutoResponder = generalAutoResponder;
+ }
+
+ @Override
+ public Uni handle(Mail message) {
+ return generalAutoResponder.processingNewMessage(message);
+ }
+
+ @Override
+ public String getEventType() {
+ return Mail.TYPE;
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/PersonSettingServiceImpl.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/PersonSettingServiceImpl.java
new file mode 100644
index 0000000..3ca3572
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/PersonSettingServiceImpl.java
@@ -0,0 +1,42 @@
+package dev.struchkov.godfather.quarkus.core.service;
+
+import dev.struchkov.godfather.quarkus.context.service.PersonSettingService;
+import dev.struchkov.godfather.quarkus.data.repository.PersonSettingRepository;
+import dev.struchkov.haiti.utils.Inspector;
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Set;
+
+public class PersonSettingServiceImpl implements PersonSettingService {
+
+ private final PersonSettingRepository personSettingRepository;
+
+ public PersonSettingServiceImpl(PersonSettingRepository personSettingRepository) {
+ this.personSettingRepository = personSettingRepository;
+ }
+
+ @Override
+ public Uni> getAllPersonIdDisableMessages(@NotNull Set personIds) {
+ Inspector.isNotNull(personIds);
+ return personSettingRepository.findAllByAllowedProcessing(personIds);
+ }
+
+ @Override
+ public Uni getStateProcessingByPersonId(@NotNull Long personId) {
+ return personSettingRepository.findStateByPersonId(personId);
+ }
+
+ @Override
+ public Uni disableMessageProcessing(@NotNull Long personId) {
+ Inspector.isNotNull(personId);
+ return personSettingRepository.disableMessageProcessing(personId);
+ }
+
+ @Override
+ public Uni enableMessageProcessing(@NotNull Long personId) {
+ Inspector.isNotNull(personId);
+ return personSettingRepository.enableMessageProcessing(personId);
+ }
+
+}
diff --git a/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/StorylineContextMapImpl.java b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/StorylineContextMapImpl.java
new file mode 100644
index 0000000..54585f8
--- /dev/null
+++ b/bot-core/bot-core-quarkus/src/main/java/dev/struchkov/godfather/quarkus/core/service/StorylineContextMapImpl.java
@@ -0,0 +1,59 @@
+package dev.struchkov.godfather.quarkus.core.service;
+
+import dev.struchkov.godfather.main.domain.ContextKey;
+import dev.struchkov.godfather.quarkus.data.StorylineContext;
+import io.smallrye.mutiny.Uni;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static dev.struchkov.haiti.context.exception.NotFoundException.notFoundException;
+import static dev.struchkov.haiti.utils.Inspector.isNotNull;
+
+public class StorylineContextMapImpl implements StorylineContext {
+
+ private final Map> map = new HashMap<>();
+
+ public Uni save(@NotNull Long personId, @NotNull ContextKey> key, Object objectForSave) {
+ isNotNull(personId, key);
+ map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave);
+ return Uni.createFrom().voidItem();
+ }
+
+ public Uni getByKey(@NotNull Long personId, @NotNull ContextKey key) {
+ isNotNull(personId, key);
+ if (map.containsKey(personId)) {
+ final Map storage = map.get(personId);
+ final T object = (T) storage.get(key.getValue());
+ if (object != null && object.getClass().equals(key.getType())) {
+ return Uni.createFrom().item(object);
+ }
+ }
+ return Uni.createFrom().nullItem();
+ }
+
+ @Override
+ public Uni getByKeyOrThrow(@NotNull Long personId, @NotNull ContextKey key) {
+ return getByKey(personId, key)
+ .onItem().ifNull().failWith(notFoundException("Не найдено значение ключа {0}, для пользователя {1}", key.getValue(), personId));
+ }
+
+ public Uni