From 89b2688e52f4bfde3c41c665a23cda42e195cc68 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 11 May 2022 11:56:05 +0300 Subject: [PATCH] release-0.0.5 --- bot-context/pom.xml | 2 +- .../struchkov/godfather/context/domain/BoxAnswer.java | 4 ++-- bot-core/pom.xml | 2 +- .../godfather/core/domain/unit/AnswerProcessing.java | 10 ++++++++++ .../godfather/core/domain/unit/AnswerSave.java | 10 ++++++++-- .../godfather/core/domain/unit/AnswerText.java | 11 ++--------- .../godfather/core/domain/unit/AnswerValidity.java | 3 ++- .../core/service/action/AnswerValidityAction.java | 3 --- pom.xml | 8 ++++---- 9 files changed, 30 insertions(+), 23 deletions(-) diff --git a/bot-context/pom.xml b/bot-context/pom.xml index 8a06388..c53c835 100644 --- a/bot-context/pom.xml +++ b/bot-context/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.4 + 0.0.5 bot-context diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BoxAnswer.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BoxAnswer.java index d859fbb..cf9a970 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BoxAnswer.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/BoxAnswer.java @@ -24,7 +24,7 @@ public class BoxAnswer { private boolean replace; private BoxAnswer(Builder builder) { - setMessage(builder.message); + message = builder.message; keyBoard = builder.keyBoard; replace = builder.replace; } @@ -33,7 +33,7 @@ public class BoxAnswer { return BoxAnswer.builder().message(message).build(); } - public static ProcessingData processing(String messageText) { + public static ProcessingData boxAnswer(String messageText) { return message -> of(messageText); } diff --git a/bot-core/pom.xml b/bot-core/pom.xml index fd9a331..6f20ead 100644 --- a/bot-core/pom.xml +++ b/bot-core/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.4 + 0.0.5 bot-core diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerProcessing.java b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerProcessing.java index dffc576..62f600f 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerProcessing.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerProcessing.java @@ -58,6 +58,16 @@ public class AnswerProcessing extends MainUnit { private Builder() { } + public Builder processingData(ProcessingData val) { + processingData = val; + return this; + } + + public Builder sending(Sending val) { + sending = val; + return this; + } + public Builder keyWords(Set val) { keyWords = val; return this; diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerSave.java b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerSave.java index 65bdb38..0fb1e86 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerSave.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerSave.java @@ -8,9 +8,12 @@ import dev.struchkov.godfather.core.service.save.push.Pusher; import dev.struchkov.godfather.core.utils.TypeUnit; import java.util.Collection; +import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; +import static dev.struchkov.haiti.utils.Inspector.isNotNull; + /** * Обработчик для сохранения ответов пользователя. Так же допускается скрытое сохранение. * @@ -91,12 +94,12 @@ public class AnswerSave extends MainUnit { } public static final class Builder { - private Set keyWords; + private Set keyWords = new HashSet<>(); private String phrase; private Pattern pattern; private Integer matchThreshold; private Integer priority; - private Set nextUnits; + private Set nextUnits = new HashSet<>(); private Preservable preservable; private String key; private Pusher pusher; @@ -178,6 +181,9 @@ public class AnswerSave extends MainUnit { } public AnswerSave build() { + isNotNull(preservable, "Не указан репозиторий для сохранения формы пользователя"); + isNotNull(preservableData, "Не указаны данные для сохранения"); + isNotNull(key, "Не указан ключ для сохранения"); return new AnswerSave<>(this); } diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerText.java b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerText.java index 37769b9..e31220c 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerText.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerText.java @@ -38,20 +38,13 @@ public class AnswerText extends MainUnit { private AnswerText(Builder builder) { super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, builder.activeType, TypeUnit.TEXT); - keyWords = builder.keyWords; - phrase = builder.phrase; - pattern = builder.pattern; - matchThreshold = builder.matchThreshold; - priority = builder.priority; - nextUnits = builder.nextUnits; boxAnswer = builder.boxAnswer; insert = builder.insert; sending = builder.sending; - activeType = builder.activeType; } public static AnswerText of(String message) { - return AnswerText.builder().boxAnswer(BoxAnswer.processing(message)).build(); + return AnswerText.builder().boxAnswer(BoxAnswer.boxAnswer(message)).build(); } public static Builder builder() { @@ -74,7 +67,7 @@ public class AnswerText extends MainUnit { private ProcessingData boxAnswer; private Insert insert; private Sending sending; - private Set keyWords; + private Set keyWords = new HashSet<>(); private String phrase; private Pattern pattern; private Integer matchThreshold; diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerValidity.java b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerValidity.java index 2453c06..a828a65 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerValidity.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/domain/unit/AnswerValidity.java @@ -5,6 +5,7 @@ import dev.struchkov.godfather.core.service.save.LocalPreservable; import dev.struchkov.godfather.core.service.save.Preservable; import dev.struchkov.godfather.core.utils.TypeUnit; +import java.util.HashSet; import java.util.Set; import java.util.regex.Pattern; @@ -76,7 +77,7 @@ public class AnswerValidity extends MainUnit { private Pattern pattern; private Integer matchThreshold; private Integer priority; - private Set nextUnits; + private Set nextUnits = new HashSet<>(); private Builder() { } diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/service/action/AnswerValidityAction.java b/bot-core/src/main/java/dev/struchkov/godfather/core/service/action/AnswerValidityAction.java index 1a88003..702957d 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/service/action/AnswerValidityAction.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/service/action/AnswerValidityAction.java @@ -6,10 +6,7 @@ import dev.struchkov.godfather.core.domain.unit.AnswerText; import dev.struchkov.godfather.core.domain.unit.AnswerValidity; import dev.struchkov.godfather.core.domain.unit.MainUnit; -import java.util.Collections; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Обработчик Unit-а {@link AnswerValidity}. diff --git a/pom.xml b/pom.xml index 8160820..45f9e1c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.4 + 0.0.5 pom @@ -15,7 +15,7 @@ GodFather Bot - Абстрактная бииблиотека для помощи в реализации библиотек ботов для конкретных социальных сетей + Абстрактная библиотека для помощи в реализации библиотек ботов для конкретных социальных сетей https://github.com/Godfather-Bots/godfather @@ -32,12 +32,12 @@ UTF-8 UTF-8 - 0.0.4 + 0.0.5 ${godfather.ver} ${godfather.ver} - 2.0.0 + 2.0.1 1.0.2 2.2