release-0.0.5

This commit is contained in:
Struchkov Mark 2022-05-11 11:56:05 +03:00
parent 08256dadc3
commit 89b2688e52
9 changed files with 30 additions and 23 deletions

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.4</version> <version>0.0.5</version>
</parent> </parent>
<artifactId>bot-context</artifactId> <artifactId>bot-context</artifactId>

View File

@ -24,7 +24,7 @@ public class BoxAnswer {
private boolean replace; private boolean replace;
private BoxAnswer(Builder builder) { private BoxAnswer(Builder builder) {
setMessage(builder.message); message = builder.message;
keyBoard = builder.keyBoard; keyBoard = builder.keyBoard;
replace = builder.replace; replace = builder.replace;
} }
@ -33,7 +33,7 @@ public class BoxAnswer {
return BoxAnswer.builder().message(message).build(); return BoxAnswer.builder().message(message).build();
} }
public static <T extends Message> ProcessingData<T> processing(String messageText) { public static <T extends Message> ProcessingData<T> boxAnswer(String messageText) {
return message -> of(messageText); return message -> of(messageText);
} }

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.4</version> <version>0.0.5</version>
</parent> </parent>
<artifactId>bot-core</artifactId> <artifactId>bot-core</artifactId>

View File

@ -58,6 +58,16 @@ public class AnswerProcessing<M extends Message> extends MainUnit {
private Builder() { private Builder() {
} }
public Builder<M> processingData(ProcessingData<M> val) {
processingData = val;
return this;
}
public Builder<M> sending(Sending val) {
sending = val;
return this;
}
public Builder<M> keyWords(Set<String> val) { public Builder<M> keyWords(Set<String> val) {
keyWords = val; keyWords = val;
return this; return this;

View File

@ -8,9 +8,12 @@ import dev.struchkov.godfather.core.service.save.push.Pusher;
import dev.struchkov.godfather.core.utils.TypeUnit; import dev.struchkov.godfather.core.utils.TypeUnit;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
/** /**
* Обработчик для сохранения ответов пользователя. Так же допускается скрытое сохранение. * Обработчик для сохранения ответов пользователя. Так же допускается скрытое сохранение.
* *
@ -91,12 +94,12 @@ public class AnswerSave<D> extends MainUnit {
} }
public static final class Builder<D> { public static final class Builder<D> {
private Set<String> keyWords; private Set<String> keyWords = new HashSet<>();
private String phrase; private String phrase;
private Pattern pattern; private Pattern pattern;
private Integer matchThreshold; private Integer matchThreshold;
private Integer priority; private Integer priority;
private Set<MainUnit> nextUnits; private Set<MainUnit> nextUnits = new HashSet<>();
private Preservable<D> preservable; private Preservable<D> preservable;
private String key; private String key;
private Pusher<D> pusher; private Pusher<D> pusher;
@ -178,6 +181,9 @@ public class AnswerSave<D> extends MainUnit {
} }
public AnswerSave<D> build() { public AnswerSave<D> build() {
isNotNull(preservable, "Не указан репозиторий для сохранения формы пользователя");
isNotNull(preservableData, "Не указаны данные для сохранения");
isNotNull(key, "Не указан ключ для сохранения");
return new AnswerSave<>(this); return new AnswerSave<>(this);
} }

View File

@ -38,20 +38,13 @@ public class AnswerText<M extends Message> extends MainUnit {
private AnswerText(Builder<M> builder) { private AnswerText(Builder<M> builder) {
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, builder.activeType, TypeUnit.TEXT); 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; boxAnswer = builder.boxAnswer;
insert = builder.insert; insert = builder.insert;
sending = builder.sending; sending = builder.sending;
activeType = builder.activeType;
} }
public static <M extends Message> AnswerText<M> of(String message) { public static <M extends Message> AnswerText<M> of(String message) {
return AnswerText.<M>builder().boxAnswer(BoxAnswer.processing(message)).build(); return AnswerText.<M>builder().boxAnswer(BoxAnswer.boxAnswer(message)).build();
} }
public static <M extends Message> Builder<M> builder() { public static <M extends Message> Builder<M> builder() {
@ -74,7 +67,7 @@ public class AnswerText<M extends Message> extends MainUnit {
private ProcessingData<M> boxAnswer; private ProcessingData<M> boxAnswer;
private Insert insert; private Insert insert;
private Sending sending; private Sending sending;
private Set<String> keyWords; private Set<String> keyWords = new HashSet<>();
private String phrase; private String phrase;
private Pattern pattern; private Pattern pattern;
private Integer matchThreshold; private Integer matchThreshold;

View File

@ -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.service.save.Preservable;
import dev.struchkov.godfather.core.utils.TypeUnit; import dev.struchkov.godfather.core.utils.TypeUnit;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -76,7 +77,7 @@ public class AnswerValidity extends MainUnit {
private Pattern pattern; private Pattern pattern;
private Integer matchThreshold; private Integer matchThreshold;
private Integer priority; private Integer priority;
private Set<MainUnit> nextUnits; private Set<MainUnit> nextUnits = new HashSet<>();
private Builder() { private Builder() {
} }

View File

@ -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.AnswerValidity;
import dev.struchkov.godfather.core.domain.unit.MainUnit; import dev.struchkov.godfather.core.domain.unit.MainUnit;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* Обработчик Unit-а {@link AnswerValidity}. * Обработчик Unit-а {@link AnswerValidity}.

View File

@ -6,7 +6,7 @@
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.4</version> <version>0.0.5</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
@ -15,7 +15,7 @@
</modules> </modules>
<name>GodFather Bot</name> <name>GodFather Bot</name>
<description>Абстрактная бииблиотека для помощи в реализации библиотек ботов для конкретных социальных сетей <description>Абстрактная библиотека для помощи в реализации библиотек ботов для конкретных социальных сетей
</description> </description>
<url>https://github.com/Godfather-Bots/godfather</url> <url>https://github.com/Godfather-Bots/godfather</url>
<licenses> <licenses>
@ -32,12 +32,12 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.ver>0.0.4</godfather.ver> <godfather.ver>0.0.5</godfather.ver>
<godfather.context.ver>${godfather.ver}</godfather.context.ver> <godfather.context.ver>${godfather.ver}</godfather.context.ver>
<godfather.core.ver>${godfather.ver}</godfather.core.ver> <godfather.core.ver>${godfather.ver}</godfather.core.ver>
<autoresponder.ver>2.0.0</autoresponder.ver> <autoresponder.ver>2.0.1</autoresponder.ver>
<haiti.utils>1.0.2</haiti.utils> <haiti.utils>1.0.2</haiti.utils>
<javax.persistence.api.ver>2.2</javax.persistence.api.ver> <javax.persistence.api.ver>2.2</javax.persistence.api.ver>