diff --git a/bot-context/pom.xml b/bot-context/pom.xml
index 0cc1745..8d7da4f 100644
--- a/bot-context/pom.xml
+++ b/bot-context/pom.xml
@@ -6,7 +6,7 @@
dev.struchkov.godfather
godfather-bot
- 0.0.17
+ 0.0.18
bot-context
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitRequest.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitRequest.java
index 2773e4a..35ec569 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitRequest.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/UnitRequest.java
@@ -19,7 +19,7 @@ public class UnitRequest {
this.message = message;
}
- public static UnitRequest of(U mainUnit, M message) {
+ public static , M extends Message> UnitRequest of(U mainUnit, M message) {
return new UnitRequest<>(mainUnit, message);
}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java
index 011efe6..3e9d336 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java
@@ -1,5 +1,6 @@
package dev.struchkov.godfather.context.domain.content;
+import dev.struchkov.autoresponder.entity.DeliverableText;
import dev.struchkov.godfather.context.domain.BasicEntity;
import javax.persistence.Column;
@@ -16,7 +17,7 @@ import java.util.Objects;
* @author upagge [08/07/2019]
*/
@MappedSuperclass
-public abstract class Message extends BasicEntity {
+public abstract class Message extends BasicEntity implements DeliverableText {
/**
* Тип сообщения.
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerCheck.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerCheck.java
index 7ea377a..6f3ac3a 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerCheck.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerCheck.java
@@ -6,7 +6,6 @@ import dev.struchkov.godfather.context.domain.content.Message;
import dev.struchkov.godfather.context.service.Accessibility;
import dev.struchkov.godfather.context.service.usercode.CheckData;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
@@ -22,7 +21,7 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
*
* @author upagge [08/07/2019]
*/
-public class AnswerCheck extends MainUnit {
+public class AnswerCheck extends MainUnit {
/**
* Unit для true.
@@ -37,15 +36,15 @@ public class AnswerCheck extends MainUnit {
/**
* Условие проверки.
*/
- private final CheckData check;
+ private final CheckData check;
- private AnswerCheck(Builder builder) {
+ private AnswerCheck(Builder builder) {
super(
builder.name,
- builder.keyWords,
- builder.phrases,
+ builder.triggerWords,
+ builder.triggerPhrases,
builder.triggerCheck,
- builder.pattern,
+ builder.triggerPatterns,
builder.matchThreshold,
builder.priority,
new HashSet<>(),
@@ -59,8 +58,8 @@ public class AnswerCheck extends MainUnit {
check = builder.check;
}
- public static Builder builder() {
- return new Builder();
+ public static Builder builder() {
+ return new Builder<>();
}
public MainUnit getUnitTrue() {
@@ -71,117 +70,144 @@ public class AnswerCheck extends MainUnit {
return unitFalse;
}
- public CheckData getCheck() {
+ public CheckData getCheck() {
return check;
}
- public static final class Builder {
+ public static final class Builder {
private String name;
- private final Set keyWords = new HashSet<>();
- private final Set phrases = new HashSet<>();
- private Predicate triggerCheck;
- private Pattern pattern;
+
+ private Set triggerWords;
+ private Set triggerPhrases;
+ private Predicate triggerCheck;
+ private Set triggerPatterns;
private Integer matchThreshold;
+
private Integer priority;
- private MainUnit unitTrue;
- private MainUnit unitFalse;
- private CheckData check;
private UnitActiveType activeType;
+
private Accessibility accessibility;
private boolean notSaveHistory;
+ private MainUnit unitTrue;
+ private MainUnit unitFalse;
+ private CheckData check;
+
private Builder() {
}
- public Builder name(String name) {
+ public Builder name(String name) {
this.name = name;
return this;
}
- public Builder keyWords(Set val) {
- keyWords.addAll(val);
+ public Builder triggerWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val);
return this;
}
- public Builder keyWord(KeyWord val) {
- keyWords.add(val);
+ public Builder triggerWord(KeyWord val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(val);
return this;
}
- public Builder stringKeyWords(Set val) {
- keyWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
+ public Builder triggerStringWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
return this;
}
- public Builder keyWord(String val) {
- keyWords.add(KeyWord.of(val));
+ public Builder triggerWord(String val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(KeyWord.of(val));
return this;
}
- public Builder phrase(String val) {
- phrases.add(val);
+ public Builder triggerPhrase(String... val) {
+ if (triggerPhrases == null) {
+ triggerPhrases = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPhrases.add(val[0]);
+ } else {
+ triggerPhrases.addAll(Set.of(val));
+ }
+ triggerPhrases.addAll(Set.of(val));
return this;
}
- public Builder phrases(Collection val) {
- phrases.addAll(val);
+ public Builder triggerPattern(Pattern... val) {
+ if (triggerPatterns == null) {
+ triggerPatterns = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPatterns.add(val[0]);
+ } else {
+ triggerPatterns.addAll(Set.of(val));
+ }
+ triggerPatterns.addAll(Set.of(val));
return this;
}
- public Builder pattern(Pattern val) {
- pattern = val;
- return this;
- }
-
- private Builder triggerCheck(Predicate trigger) {
+ private Builder triggerCheck(Predicate trigger) {
triggerCheck = trigger;
return this;
}
- public Builder matchThreshold(Integer val) {
+ public Builder matchThreshold(Integer val) {
matchThreshold = val;
return this;
}
- public Builder priority(Integer val) {
+ public Builder priority(Integer val) {
priority = val;
return this;
}
- public Builder unitTrue(MainUnit unitTrue) {
+ public Builder unitTrue(MainUnit unitTrue) {
this.unitTrue = unitTrue;
return this;
}
- public Builder unitFalse(MainUnit unitFalse) {
+ public Builder unitFalse(MainUnit unitFalse) {
this.unitFalse = unitFalse;
return this;
}
- public Builder check(CheckData check) {
+ public Builder check(CheckData check) {
this.check = check;
return this;
}
- public Builder accessibility(Accessibility val) {
+ public Builder accessibility(Accessibility val) {
accessibility = val;
return this;
}
- public Builder activeType(UnitActiveType val) {
+ public Builder activeType(UnitActiveType val) {
activeType = val;
return this;
}
- public Builder notSaveHistory() {
+ public Builder notSaveHistory() {
notSaveHistory = true;
return this;
}
- public AnswerCheck build() {
+ public AnswerCheck build() {
isNotNull(check, unitConfigException("Необходимо установить параметр проверки."));
isAnyNotNull(unitConfigException("Необходимо задать хотя бы один unit результата проверки."));
- return new AnswerCheck(this);
+ return new AnswerCheck<>(this);
}
}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerSave.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerSave.java
index 83b776b..f4a2851 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerSave.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerSave.java
@@ -24,7 +24,7 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
*
* @author upagge [08/07/2019]
*/
-public class AnswerSave extends MainUnit {
+public class AnswerSave extends MainUnit {
/**
* Объект отвечающий за сохранение - репозиторий.
@@ -44,22 +44,22 @@ public class AnswerSave extends MainUnit {
/**
* Данные для скрытого сохранения.
*/
- private final PreservableData preservableData;
+ private final PreservableData preservableData;
/**
* Скрытое сохранение.
*/
private final boolean hidden;
- private final CheckSave super Message> checkSave;
+ private final CheckSave checkSave;
- private AnswerSave(Builder builder) {
+ private AnswerSave(Builder builder) {
super(
builder.name,
- builder.keyWords,
- builder.phrases,
+ builder.triggerWords,
+ builder.triggerPhrases,
builder.triggerCheck,
- builder.pattern,
+ builder.triggerPatterns,
builder.matchThreshold,
builder.priority,
builder.nextUnits,
@@ -77,11 +77,11 @@ public class AnswerSave extends MainUnit {
checkSave = builder.checkSave;
}
- public static Builder builder() {
+ public static Builder builder() {
return new Builder<>();
}
- private void maintenanceNextUnit(Collection units) {
+ private void maintenanceNextUnit(Collection> units) {
if (units != null) {
units.forEach(mainUnit -> mainUnit.setActiveType(UnitActiveType.AFTER));
}
@@ -99,7 +99,7 @@ public class AnswerSave extends MainUnit {
return pusher;
}
- public PreservableData getPreservableData() {
+ public PreservableData getPreservableData() {
return preservableData;
}
@@ -107,137 +107,162 @@ public class AnswerSave extends MainUnit {
return hidden;
}
- public CheckSave super Message> getCheckSave() {
+ public CheckSave getCheckSave() {
return checkSave;
}
- public static final class Builder {
+ public static final class Builder {
private String name;
- private final Set keyWords = new HashSet<>();
- private final Set phrases = new HashSet<>();
- private Predicate triggerCheck;
- private Pattern pattern;
+ private Set> nextUnits;
+
+ private Set triggerWords;
+ private Set triggerPhrases;
+ private Set triggerPatterns;
+ private Predicate triggerCheck;
+
private Integer matchThreshold;
private Integer priority;
- private Set nextUnits = new HashSet<>();
+
+ private Accessibility accessibility;
+ private boolean notSaveHistory;
+
private AnswerSavePreservable preservable;
private String key;
private Pusher pusher;
- private PreservableData preservableData;
+ private PreservableData preservableData;
private boolean hidden;
- private CheckSave super Message> checkSave;
- private Accessibility accessibility;
- private boolean notSaveHistory;
+ private CheckSave checkSave;
private Builder() {
}
- public Builder name(String name) {
+ public Builder name(String name) {
this.name = name;
return this;
}
- public Builder keyWords(Set val) {
- keyWords.addAll(val);
+ public Builder triggerWords(Set val) {
+ if (checkNull(triggerWords)) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val);
return this;
}
- public Builder keyWord(KeyWord val) {
- keyWords.add(val);
+ public Builder triggerWord(KeyWord val) {
+ if (checkNull(triggerWords)) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(val);
return this;
}
- public Builder stringKeyWords(Set val) {
- keyWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
+ public Builder triggerStringWords(Set val) {
+ if (checkNull(triggerWords)) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
return this;
}
- public Builder keyWord(String val) {
- keyWords.add(KeyWord.of(val));
+ public Builder triggerWord(String val) {
+ if (checkNull(triggerWords)) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(KeyWord.of(val));
return this;
}
- public Builder phrase(String val) {
- phrases.add(val);
+ public Builder triggerPhrase(String... val) {
+ if (checkNull(triggerPhrases)) {
+ triggerPhrases = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPhrases.add(val[0]);
+ } else {
+ triggerPhrases.addAll(Set.of(val));
+ }
+ triggerPhrases.addAll(Set.of(val));
return this;
}
- public Builder phrases(Collection val) {
- phrases.addAll(val);
+ public Builder triggerPattern(Pattern... val) {
+ if (checkNull(triggerPatterns)) {
+ triggerPatterns = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPatterns.add(val[0]);
+ } else {
+ triggerPatterns.addAll(Set.of(val));
+ }
+ triggerPatterns.addAll(Set.of(val));
return this;
}
- public Builder pattern(Pattern val) {
- pattern = val;
- return this;
- }
-
- public Builder triggerCheck(Predicate trigger) {
+ public Builder triggerCheck(Predicate trigger) {
triggerCheck = trigger;
return this;
}
- public Builder matchThreshold(Integer val) {
+ public Builder matchThreshold(Integer val) {
matchThreshold = val;
return this;
}
- public Builder priority(Integer val) {
+ public Builder priority(Integer val) {
priority = val;
return this;
}
- public Builder nextUnits(Set val) {
- nextUnits = val;
- return this;
- }
-
- public Builder nextUnit(MainUnit val) {
+ public Builder next(MainUnit val) {
+ if (checkNull(nextUnits)) {
+ nextUnits = new HashSet<>();
+ }
nextUnits.add(val);
return this;
}
- public Builder preservable(AnswerSavePreservable val) {
+ public Builder preservable(AnswerSavePreservable val) {
this.preservable = val;
return this;
}
- public Builder key(String val) {
+ public Builder key(String val) {
this.key = val;
return this;
}
- public Builder pusher(Pusher val) {
+ public Builder pusher(Pusher val) {
this.pusher = val;
return this;
}
- public Builder preservableData(PreservableData val) {
+ public Builder preservableData(PreservableData val) {
this.preservableData = val;
return this;
}
- public Builder hidden(boolean val) {
+ public Builder hidden(boolean val) {
this.hidden = val;
return this;
}
- public Builder checkSave(CheckSave super Message> val) {
+ public Builder checkSave(CheckSave val) {
this.checkSave = val;
return this;
}
- public Builder accessibility(Accessibility val) {
+ public Builder accessibility(Accessibility val) {
accessibility = val;
return this;
}
- public Builder notSaveHistory() {
+ public Builder notSaveHistory() {
notSaveHistory = true;
return this;
}
- public AnswerSave build() {
+ public AnswerSave build() {
isNotNull(preservable, "Не указан репозиторий для сохранения формы пользователя");
if (checkNull(pusher)) {
isNotNull(preservableData, "Не указаны данные для сохранения");
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerText.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerText.java
index 2501d27..e9eb7c4 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerText.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerText.java
@@ -10,10 +10,14 @@ import dev.struchkov.godfather.context.service.sender.Sending;
import dev.struchkov.godfather.context.service.usercode.Insert;
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
-import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.function.Predicate;
+import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -24,12 +28,12 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
*
* @author upagge [08/07/2019]
*/
-public class AnswerText extends MainUnit {
+public class AnswerText extends MainUnit {
/**
* Объект, который необходимо отправить пользователю.
*/
- private final ProcessingData boxAnswer;
+ private final ProcessingData answer;
/**
* Информация, которую необходимо вставить вместо маркеров в строку ответа.
@@ -39,15 +43,15 @@ public class AnswerText extends MainUnit {
/**
* Объект нестандартной отправки ответа.
*/
- private final Sending sending;
+ private final Sending sender;
private AnswerText(Builder builder) {
super(
builder.name,
- builder.keyWords,
- builder.phrases,
+ builder.triggerWords,
+ builder.triggerPhrases,
builder.triggerCheck,
- builder.pattern,
+ builder.triggerPatterns,
builder.matchThreshold,
builder.priority,
builder.nextUnits,
@@ -56,25 +60,25 @@ public class AnswerText extends MainUnit {
builder.accessibility,
TypeUnit.TEXT
);
- boxAnswer = builder.boxAnswer;
+ answer = builder.boxAnswer;
insert = builder.insert;
- sending = builder.sending;
+ sender = builder.sending;
}
public static AnswerText of(String message) {
- return AnswerText.builder().boxAnswer(BoxAnswer.boxAnswer(message)).build();
+ return AnswerText.builder().answer(BoxAnswer.boxAnswer(message)).build();
}
public static AnswerText of(BoxAnswer boxAnswer) {
- return AnswerText.builder().boxAnswer(boxAnswer).build();
+ return AnswerText.builder().answer(boxAnswer).build();
}
public static Builder builder() {
return new Builder<>();
}
- public ProcessingData getBoxAnswer() {
- return boxAnswer;
+ public ProcessingData getAnswer() {
+ return answer;
}
public Insert getInsert() {
@@ -82,25 +86,29 @@ public class AnswerText extends MainUnit {
}
public Sending getSending() {
- return sending;
+ return sender;
}
public static final class Builder {
- private final Set keyWords = new HashSet<>();
- private final Set phrases = new HashSet<>();
- private Predicate triggerCheck;
private String name;
- private ProcessingData boxAnswer;
- private Insert insert;
- private Sending sending;
- private Pattern pattern;
+ private Set> nextUnits;
+
+ private Set triggerWords;
+ private Set triggerPhrases;
+ private Predicate triggerCheck;
+ private Set triggerPatterns;
+
private Integer matchThreshold;
private Integer priority;
- private Set nextUnits = new HashSet<>();
+
private UnitActiveType activeType;
private Accessibility accessibility;
private boolean notSaveHistory;
+ private ProcessingData boxAnswer;
+ private Insert insert;
+ private Sending sending;
+
private Builder() {
}
@@ -109,13 +117,26 @@ public class AnswerText extends MainUnit {
return this;
}
- public Builder message(ProcessingData message) {
- this.boxAnswer = message;
+ public Builder processing(Consumer answer) {
+ this.boxAnswer = message -> {
+ answer.accept(message);
+ return Optional.empty();
+ };
return this;
}
- public Builder boxAnswer(BoxAnswer boxAnswer) {
- this.boxAnswer = message -> boxAnswer;
+ public Builder answer(Function answer) {
+ this.boxAnswer = message -> Optional.of(answer.apply(message));
+ return this;
+ }
+
+ public Builder answer(BoxAnswer answer) {
+ this.boxAnswer = message -> Optional.of(answer);
+ return this;
+ }
+
+ public Builder answer(Supplier answer) {
+ this.boxAnswer = message -> Optional.of(answer.get());
return this;
}
@@ -129,46 +150,69 @@ public class AnswerText extends MainUnit {
return this;
}
- public Builder keyWords(Set val) {
- keyWords.addAll(val);
+ public Builder triggerWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val);
return this;
}
- public Builder keyWord(KeyWord val) {
- keyWords.add(val);
+ public Builder triggerWord(KeyWord val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(val);
return this;
}
- public Builder stringKeyWords(Set val) {
- keyWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
+ public Builder triggerStringWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
return this;
}
- public Builder keyWord(String val) {
- keyWords.add(KeyWord.of(val));
+ public Builder triggerWord(String val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(KeyWord.of(val));
return this;
}
- public Builder phrase(String val) {
- phrases.add(val);
+ public Builder triggerPhrase(String... val) {
+ if (triggerPhrases == null) {
+ triggerPhrases = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPhrases.add(val[0]);
+ } else {
+ triggerPhrases.addAll(Set.of(val));
+ }
+ triggerPhrases.addAll(List.of(val));
return this;
}
- public Builder phrases(String... val) {
- phrases.addAll(Arrays.asList(val));
+ public Builder triggerPattern(Pattern... val) {
+ if (triggerPatterns == null) {
+ triggerPatterns = new HashSet<>();
+ }
+ if (val.length == 1) {
+ triggerPatterns.add(val[0]);
+ } else {
+ triggerPatterns.addAll(Set.of(val));
+ }
+ triggerPatterns.addAll(Set.of(val));
return this;
}
- public Builder triggerCheck(Predicate trigger) {
+ public Builder triggerCheck(Predicate trigger) {
triggerCheck = trigger;
return this;
}
- public Builder pattern(Pattern val) {
- pattern = val;
- return this;
- }
-
public Builder matchThreshold(Integer val) {
matchThreshold = val;
return this;
@@ -179,12 +223,10 @@ public class AnswerText extends MainUnit {
return this;
}
- public Builder nextUnits(Set val) {
- nextUnits = val;
- return this;
- }
-
- public Builder nextUnit(MainUnit val) {
+ public Builder next(MainUnit val) {
+ if (nextUnits == null) {
+ nextUnits = new HashSet<>();
+ }
nextUnits.add(val);
return this;
}
diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerTimer.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerTimer.java
index ae9ed31..6016aa4 100644
--- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerTimer.java
+++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/unit/AnswerTimer.java
@@ -6,7 +6,6 @@ import dev.struchkov.godfather.context.domain.content.Message;
import dev.struchkov.godfather.context.service.Accessibility;
import dev.struchkov.godfather.context.service.usercode.CheckData;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
@@ -21,12 +20,12 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
*
* @author upagge [08/07/2019]
*/
-public class AnswerTimer extends MainUnit {
+public class AnswerTimer extends MainUnit {
/**
* Unit обработку которого необходимо отложить.
*/
- private final MainUnit unitAnswer;
+ private final MainUnit unitAnswer;
/**
* Задержка обработки в секундах.
@@ -46,10 +45,10 @@ public class AnswerTimer extends MainUnit {
private AnswerTimer(Builder builder) {
super(
builder.name,
- builder.keyWords,
- builder.phrases,
+ builder.triggerWords,
+ builder.triggerPhrases,
builder.triggerCheck,
- builder.pattern,
+ builder.triggerPatterns,
builder.matchThreshold,
builder.priority,
null,
@@ -68,7 +67,7 @@ public class AnswerTimer extends MainUnit {
return new Builder<>();
}
- public MainUnit getUnitAnswer() {
+ public MainUnit getUnitAnswer() {
return unitAnswer;
}
@@ -86,20 +85,23 @@ public class AnswerTimer extends MainUnit {
public static final class Builder {
private String name;
- private MainUnit unitAnswer;
- private Integer timeDelaySec;
- private Integer timeDeathSec;
- private CheckData checkLoop;
- private final Set keyWords = new HashSet<>();
- private final Set phrases = new HashSet<>();
- private Predicate triggerCheck;
- private Pattern pattern;
+
+ private Set triggerWords;
+ private Set triggerPhrases;
+ private Predicate triggerCheck;
+ private Set triggerPatterns;
private Integer matchThreshold;
+
private Integer priority;
private UnitActiveType activeType = UnitActiveType.AFTER;
private Accessibility accessibility;
private boolean notSaveHistory;
+ private MainUnit unitAnswer;
+ private Integer timeDelaySec;
+ private Integer timeDeathSec;
+ private CheckData checkLoop;
+
private Builder() {
}
@@ -108,7 +110,7 @@ public class AnswerTimer extends MainUnit {
return this;
}
- public Builder unitAnswer(MainUnit val) {
+ public Builder unitAnswer(MainUnit val) {
unitAnswer = val;
return this;
}
@@ -128,42 +130,65 @@ public class AnswerTimer extends MainUnit {
return this;
}
- public Builder keyWords(Set val) {
- keyWords.addAll(val);
+ public Builder triggerWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val);
return this;
}
- public Builder keyWord(KeyWord val) {
- keyWords.add(val);
+ public Builder triggerWord(KeyWord val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.add(val);
return this;
}
- public Builder stringKeyWords(Set val) {
- keyWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
+ public Builder triggerStringWords(Set val) {
+ if (triggerWords == null) {
+ triggerWords = new HashSet<>();
+ }
+ triggerWords.addAll(val.stream().map(KeyWord::of).collect(Collectors.toSet()));
return this;
}
- public Builder keyWord(String val) {
- keyWords.add(KeyWord.of(val));
+ public Builder