diff --git a/pom.xml b/pom.xml
index bc96095..6c13369 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,21 +43,22 @@
UTF-8
UTF-8
- 0.0.51
- 2.7.2
- 0.0.11
+ 1.0.0-SNAPSHOT
+
+ 3.0.2
+ 1.1.1
0.0.5
- 3.1.0
+ 3.2.0-M1
- 31.1-jre
+ 33.0.0-jre
- 3.10.1
+ 3.12.1
- 3.0.0-M7
+ 3.0.1
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ErrorHandlerService.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ErrorHandlerService.java
index 8260378..2fa5428 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ErrorHandlerService.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ErrorHandlerService.java
@@ -21,7 +21,7 @@ public class ErrorHandlerService implements ErrorHandler {
private final TelegramSending telegramSending;
@Override
- public void handle(Message message, Exception e) {
+ public void handle(Message message, Throwable e) {
log.error(e.getMessage(), e);
final BoxAnswer boxAnswer = boxAnswer(e.getMessage());
boxAnswer.setRecipientIfNull(personProperty.getTelegramId());
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java
index 1e6d41b..0711799 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/MessageSendTelegramService.java
@@ -44,7 +44,7 @@ public class MessageSendTelegramService implements MessageSendService {
.map(generator -> {
final BoxAnswer answer = generator.generate(notify);
answer.setRecipientIfNull(personInformation.getTelegramId());
- answer.setPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true);
+ answer.addPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true);
return answer;
})
.ifPresent(sending::send);
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/StartNotify.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/StartNotify.java
index fa87892..d4f91a3 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/StartNotify.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/StartNotify.java
@@ -22,8 +22,8 @@ import java.util.Optional;
import java.util.UUID;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
-import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
+import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java
index 9038a22..d616bba 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/notify/ConflictPrNotifyGenerator.java
@@ -9,10 +9,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
-import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
-import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
+import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
+import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@@ -33,7 +33,7 @@ public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator accessError() {
return AnswerText.builder()
- .triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getPersonId()))
+ .triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getFromPersonId()))
.answer(message -> {
final String messageText = new StringBuilder("\uD83D\uDEA8 *Attempted unauthorized access to the bot*")
.append(Icons.HR)
@@ -98,7 +98,7 @@ public class MenuConfig implements UnitConfiguration {
return AnswerText.builder()
.priority(5)
.triggerCheck(mail -> {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) {
final boolean firstStart = settingService.isFirstStart();
return !firstStart;
@@ -112,7 +112,7 @@ public class MenuConfig implements UnitConfiguration {
At the moment, you can only add new repositories. But in future versions, the possibilities will expand.
""";
final InlineKeyBoard generalMenuKeyBoard = inlineKeyBoard(
- simpleLine(simpleButton("Add repository", TEXT_ADD_NEW_PROJECT))
+ keyBoardLine(simpleButton("Add repository", TEXT_ADD_NEW_PROJECT))
// simpleLine(
// simpleButton("My tasks", GET_TASKS),
// simpleButton("Merge Request", GET_ASSIGNEE_MERGE_REQUEST)
@@ -135,7 +135,7 @@ public class MenuConfig implements UnitConfiguration {
) {
return AnswerText.builder()
.triggerCheck(clickButtonRaw(TEXT_ADD_NEW_PROJECT))
- .answer(replaceBoxAnswer("Send me links to repositories you want to track"))
+ .answer(() -> replaceBoxAnswer("Send me links to repositories you want to track"))
.next(addNewProject)
.build();
}
@@ -165,7 +165,7 @@ public class MenuConfig implements UnitConfiguration {
public AnswerText settings() {
return AnswerText.builder()
.triggerPhrase(SETTINGS)
- .answer(boxAnswer("This is the settings menu"))
+ .answer(() -> boxAnswer("This is the settings menu"))
.build();
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/AnswerNoteUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/AnswerNoteUnit.java
index ddf9331..a2aefdd 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/AnswerNoteUnit.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/AnswerNoteUnit.java
@@ -10,7 +10,7 @@ import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import dev.struchkov.haiti.utils.Checker;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -25,7 +25,7 @@ import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
@Component
@RequiredArgsConstructor
-public class AnswerNoteUnit implements UnitConfiguration {
+public class AnswerNoteUnit implements PersonUnitConfiguration {
private static final Pattern NOTE_LINK = Pattern.compile("#note_\\d+$");
@@ -46,7 +46,7 @@ public class AnswerNoteUnit implements UnitConfiguration {
final boolean isLink = Attachments.findFirstLink(forwardMail.getAttachments())
.isPresent();
if (isLink) {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean firstStart = settingService.isFirstStart();
return isAccess && !firstStart;
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DeleteMessageUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DeleteMessageUnit.java
index 20c273c..0c3af65 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DeleteMessageUnit.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DeleteMessageUnit.java
@@ -8,7 +8,7 @@ import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -18,7 +18,7 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
@Component
@RequiredArgsConstructor
-public class DeleteMessageUnit implements UnitConfiguration {
+public class DeleteMessageUnit implements PersonUnitConfiguration {
private final TelegramSending telegramSending;
private final PersonInformation personInformation;
@@ -28,7 +28,7 @@ public class DeleteMessageUnit implements UnitConfiguration {
public AnswerText deleteMessage() {
return AnswerText.builder()
.triggerCheck(mail -> {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) {
final boolean isFirstStart = settingService.isFirstStart();
if (!isFirstStart) {
@@ -44,7 +44,7 @@ public class DeleteMessageUnit implements UnitConfiguration {
})
.answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
- telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId());
+ telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId());
})
.build();
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java
index 5e30c68..71fc377 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyMrUnit.java
@@ -7,11 +7,11 @@ import dev.struchkov.bot.gitlab.context.utils.Icons;
import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText;
+import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
-import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -23,14 +23,14 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_N
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_MR;
-import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
-import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
+import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
+import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
@Component
@RequiredArgsConstructor
-public class DisableNotifyMrUnit implements UnitConfiguration {
+public class DisableNotifyMrUnit implements PersonUnitConfiguration {
public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """
*Disabling notifications*
@@ -58,7 +58,7 @@ public class DisableNotifyMrUnit implements UnitConfiguration {
.flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID))
.isPresent();
if (isDisableButtonClick) {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean isFirstStart = settingService.isFirstStart();
return isAccess && !isFirstStart;
}
@@ -67,23 +67,23 @@ public class DisableNotifyMrUnit implements UnitConfiguration {
.answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION)
- .map(Arg::getValue)
+ .map(ButtonArg::getValue)
.map(BUTTON_VALUE_TRUE::equals)
.orElseThrow();
final Long mrId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID)
- .map(Arg::getValue)
+ .map(ButtonArg::getValue)
.map(Long::parseLong)
.orElseThrow();
if (confirmation) {
mergeRequestsService.notification(false, mrId);
- scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId()), 5, TimeUnit.SECONDS);
+ scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS);
return replaceBoxAnswer(SUCCESSFULLY_DISABLED);
} else {
return replaceBoxAnswer(
WARNING_ABOUT_DISABLE_NOTIFY,
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + mrId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"),
simpleButton(Icons.NO, DELETE_MESSAGE)
)
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java
index e55e847..075802d 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/DisableNotifyThreadUnit.java
@@ -7,11 +7,11 @@ import dev.struchkov.bot.gitlab.context.utils.Icons;
import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText;
+import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
-import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -23,14 +23,14 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_N
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_THREAD;
-import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
-import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
+import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
+import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
@Component
@RequiredArgsConstructor
-public class DisableNotifyThreadUnit implements UnitConfiguration {
+public class DisableNotifyThreadUnit implements PersonUnitConfiguration {
public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """
*Disabling notifications*
@@ -54,7 +54,7 @@ public class DisableNotifyThreadUnit implements UnitConfiguration {
.flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID))
.isPresent();
if (isDisableButtonClick) {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean isFirstStart = settingService.isFirstStart();
return isAccess && !isFirstStart;
}
@@ -63,23 +63,23 @@ public class DisableNotifyThreadUnit implements UnitConfiguration {
.answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION)
- .map(Arg::getValue)
+ .map(ButtonArg::getValue)
.map(BUTTON_VALUE_TRUE::equals)
.orElseThrow();
final String discussionId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID)
- .map(Arg::getValue)
+ .map(ButtonArg::getValue)
.map(String::valueOf)
.orElseThrow();
if (confirmation) {
discussionService.notification(false, discussionId);
- scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId()), 5, TimeUnit.SECONDS);
+ scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS);
return replaceBoxAnswer(SUCCESSFULLY_DISABLED);
} else {
return replaceBoxAnswer(
WARNING_ABOUT_DISABLE_NOTIFY,
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID + ":" + discussionId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"),
simpleButton(Icons.NO, DELETE_MESSAGE)
)
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/EnableProjectNotify.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/EnableProjectNotify.java
index 45b723b..269e146 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/EnableProjectNotify.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/command/EnableProjectNotify.java
@@ -9,11 +9,11 @@ import dev.struchkov.bot.gitlab.telegram.utils.UnitName;
import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText;
+import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
-import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -27,7 +27,7 @@ import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
@Component
@RequiredArgsConstructor
-public class EnableProjectNotify implements UnitConfiguration {
+public class EnableProjectNotify implements PersonUnitConfiguration {
private final ProjectService projectService;
private final MergeRequestsService mergeRequestsService;
@@ -42,7 +42,7 @@ public class EnableProjectNotify implements UnitConfiguration {
public AnswerText enableNotifyProject() {
return AnswerText.builder()
.triggerCheck(mail -> {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) {
final boolean isFirstStart = settingService.isFirstStart();
if (!isFirstStart) {
@@ -57,7 +57,7 @@ public class EnableProjectNotify implements UnitConfiguration {
}).answer(
mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
- final Arg arg = buttonClick.getArgByType(BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID).orElseThrow();
+ final ButtonArg arg = buttonClick.getArgByType(BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID).orElseThrow();
final long projectId = Long.parseLong(arg.getValue());
final Set setProjectId = Set.of(projectId);
projectService.processing(true, setProjectId);
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java
index c5f66c2..f153e11 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/flow/InitSettingFlow.java
@@ -13,13 +13,14 @@ import dev.struchkov.bot.gitlab.core.service.parser.PipelineParser;
import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser;
import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail;
+import dev.struchkov.godfather.main.domain.content.Message;
import dev.struchkov.godfather.simple.domain.BoxAnswer;
import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.simple.domain.unit.MainUnit;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
-import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
+import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -42,16 +43,16 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSER_OWNER
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSER_PRIVATE_PROJECT;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING_THREAD_LEVEL;
-import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
-import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.main.domain.unit.UnitActiveType.AFTER;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
+import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
+import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW;
import static dev.struchkov.godfather.telegram.main.core.util.InlineKeyBoards.verticalMenuButton;
-import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.clickButtonRaw;
-import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.isClickButton;
+import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.clickButtonRaw;
+import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.isButtonClick;
import static java.text.MessageFormat.format;
/**
@@ -61,7 +62,7 @@ import static java.text.MessageFormat.format;
*/
@Component
@RequiredArgsConstructor
-public class InitSettingFlow implements UnitConfiguration {
+public class InitSettingFlow implements PersonUnitConfiguration {
private final TelegramSending sending;
@@ -88,7 +89,7 @@ public class InitSettingFlow implements UnitConfiguration {
) {
return AnswerText.builder()
.triggerCheck(mail -> {
- final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId());
+ final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) {
return settingService.isFirstStart();
}
@@ -96,7 +97,7 @@ public class InitSettingFlow implements UnitConfiguration {
})
.answer(
- BoxAnswer.builder().message(
+ () -> BoxAnswer.builder().message(
"""
Hello 👋
@@ -119,8 +120,10 @@ public class InitSettingFlow implements UnitConfiguration {
.payload(DISABLE_WEB_PAGE_PREVIEW, true)
.keyBoard(
inlineKeyBoard(
- simpleButton("\uD83D\uDE80 Start setting", TEXT_PARSER_PRIVATE_PROJECT)
+ keyBoardLine(
+ simpleButton("\uD83D\uDE80 Start setting", TEXT_PARSER_PRIVATE_PROJECT)
// simpleButton("see guide", GUIDE_START)
+ )
)
)
.build()
@@ -145,7 +148,7 @@ public class InitSettingFlow implements UnitConfiguration {
We'll set privacy levels later, don't worry 😌
""",
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton("Yes", "YES"),
simpleButton("No", "NO")
)
@@ -163,7 +166,7 @@ public class InitSettingFlow implements UnitConfiguration {
) {
return AnswerText.builder()
.triggerCheck(clickButtonRaw("NO"))
- .answer(replaceBoxAnswer("\uD83D\uDC4C I won't scan public projects."))
+ .answer(() -> replaceBoxAnswer("\uD83D\uDC4C I won't scan public projects."))
.callBack(
sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS)
)
@@ -210,11 +213,18 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.builder()
.triggerCheck(clickButtonRaw("YES"))
.answer(mail -> {
- final String personId = mail.getPersonId();
+ final String personId = mail.getFromPersonId();
final String messageId = Attachments.findFirstButtonClick(mail.getAttachments())
- .map(ButtonClickAttachment::getMessageId)
+ .map(ButtonClickAttachment::getMessage)
+ .map(Mail::getId)
.orElseThrow();
- sending.replaceMessage(personId, messageId, boxAnswer(step1));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .replaceMessageId(messageId)
+ .recipientPersonId(personId)
+ .message(step1)
+ .build()
+ );
final int oldCountProjects = projectService.getAllIds().size();
@@ -225,18 +235,36 @@ public class InitSettingFlow implements UnitConfiguration {
projectService.processing(true, projectIds);
final int projectCount = projectIds.size() - oldCountProjects;
- sending.replaceMessage(personId, messageId, boxAnswer(format(step2, projectCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .replaceMessageId(messageId)
+ .recipientPersonId(personId)
+ .message(format(step2, projectCount))
+ .build()
+ );
final int oldCountMr = mergeRequestsService.getAllIds().size();
mergeRequestParser.parsingNewMergeRequest();
final int mrCount = mergeRequestsService.getAllIds().size() - oldCountMr;
- sending.replaceMessage(personId, messageId, boxAnswer(format(step3, projectCount, mrCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .replaceMessageId(messageId)
+ .recipientPersonId(personId)
+ .message(format(step3, projectCount, mrCount))
+ .build()
+ );
final int oldCountPipelines = pipelineService.getAllIds().size();
pipelineParser.scanNewPipeline();
final int pipelineCount = pipelineService.getAllIds().size() - oldCountPipelines;
- sending.replaceMessage(personId, messageId, boxAnswer(format(step4, projectCount, mrCount, pipelineCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .replaceMessageId(messageId)
+ .recipientPersonId(personId)
+ .message(format(step4, projectCount, mrCount, pipelineCount))
+ .build()
+ );
final int oldCountThreads = discussionService.getAllIds().size();
discussionParser.scanNewDiscussion();
@@ -258,7 +286,7 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.builder()
.activeType(AFTER)
.answer(
- boxAnswer(
+ () -> boxAnswer(
"""
I only send notifications for repositories that have been put on track. However, I can notify you when new repositories are available. This will allow you to track new repositories you are interested in quickly.
@@ -269,7 +297,7 @@ public class InitSettingFlow implements UnitConfiguration {
Don't worry, I will not scan these repositories and notify you about them in the future.
""",
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton("Yes", "YES"),
simpleButton("No", "NO")
)
@@ -285,11 +313,17 @@ public class InitSettingFlow implements UnitConfiguration {
@Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit textParserPrivateProject
) {
return AnswerText.builder()
- .triggerCheck(isClickButton())
+ .triggerCheck(isButtonClick())
.answer(mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
if ("YES".equals(buttonClick.getRawCallBackData())) {
- sending.replaceMessage(mail.getPersonId(), mail.getId(), boxAnswer("I write down the available projects.\nThis may take a long time ⌛"));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(mail.getFromPersonId())
+ .replaceMessageId(mail.getId())
+ .message("I write down the available projects.\nThis may take a long time ⌛")
+ .build()
+ );
projectParser.parseAllProjectOwner();
settingService.ownerProjectScan(true);
} else {
@@ -316,7 +350,7 @@ public class InitSettingFlow implements UnitConfiguration {
⚠️ If there are a lot of repositories, this might not be a good idea. Only track repositories in which you actively participate. This will reduce the number of requests to the GitLab API.
""",
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton("Yes", "YES"),
simpleButton("No", "NO")
)
@@ -368,11 +402,18 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.builder()
.triggerCheck(clickButtonRaw("YES"))
.answer(mail -> {
- final String personId = mail.getPersonId();
+ final String personId = mail.getFromPersonId();
final String messageId = Attachments.findFirstButtonClick(mail.getAttachments())
- .map(ButtonClickAttachment::getMessageId)
+ .map(ButtonClickAttachment::getMessage)
+ .map(Message::getId)
.orElseThrow();
- sending.replaceMessage(personId, messageId, boxAnswer(step1));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(personId)
+ .replaceMessageId(messageId)
+ .message(step1)
+ .build()
+ );
projectParser.parseAllPrivateProject();
final Set projectIds = projectService.getAllIds();
@@ -381,15 +422,33 @@ public class InitSettingFlow implements UnitConfiguration {
projectService.processing(true, projectIds);
final int projectCount = projectIds.size();
- sending.replaceMessage(personId, messageId, boxAnswer(format(step2, projectCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(personId)
+ .replaceMessageId(messageId)
+ .message(format(step2, projectCount))
+ .build()
+ );
mergeRequestParser.parsingNewMergeRequest();
final int mrCount = mergeRequestsService.getAllIds().size();
- sending.replaceMessage(personId, messageId, boxAnswer(format(step3, projectCount, mrCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(personId)
+ .replaceMessageId(messageId)
+ .message(format(step3, projectCount, mrCount))
+ .build()
+ );
pipelineParser.scanNewPipeline();
final int pipelineCount = pipelineService.getAllIds().size();
- sending.replaceMessage(personId, messageId, boxAnswer(format(step4, projectCount, mrCount, pipelineCount)));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(personId)
+ .replaceMessageId(messageId)
+ .message(format(step4, projectCount, mrCount, pipelineCount))
+ .build()
+ );
discussionParser.scanNewDiscussion();
final int discussionCount = discussionService.getAllIds().size();
@@ -409,7 +468,7 @@ public class InitSettingFlow implements UnitConfiguration {
) {
return AnswerText.builder()
.triggerPhrase("NO")
- .answer(replaceBoxAnswer("\uD83D\uDC4C I won't scan private projects."))
+ .answer(() -> replaceBoxAnswer("\uD83D\uDC4C I won't scan private projects."))
.callBack(
sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS)
)
@@ -424,12 +483,12 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.builder()
.activeType(AFTER)
.answer(
- boxAnswer(
+ () -> boxAnswer(
"""
Do you want to enable automatic notification of new private projects available to you?
""",
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton("Yes", "YES"),
simpleButton("No", "NO")
)
@@ -445,11 +504,17 @@ public class InitSettingFlow implements UnitConfiguration {
@Unit(TEXT_PRIVACY_SETTING) MainUnit textPrivacySetting
) {
return AnswerText.builder()
- .triggerCheck(isClickButton())
+ .triggerCheck(isButtonClick())
.answer(mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
if ("YES".equals(buttonClick.getRawCallBackData())) {
- sending.replaceMessage(mail.getPersonId(), mail.getId(), boxAnswer("I write down the available private projects.\nThis may take a long time ⌛"));
+ sending.send(
+ BoxAnswer.replaceBuilder()
+ .recipientPersonId(mail.getFromPersonId())
+ .replaceMessageId(mail.getId())
+ .message("I write down the available private projects.\nThis may take a long time ⌛")
+ .build()
+ );
projectParser.parseAllPrivateProject();
settingService.privateProjectScan(true);
} else {
@@ -468,13 +533,13 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.builder()
.activeType(AFTER)
.answer(
- replaceBoxAnswer("""
+ () -> replaceBoxAnswer("""
Each company and/or team has its own level of confidentiality. You probably don't want to trust any information to Telegram, because all messages will go through its servers. Also, your telegame account can be hacked.
So now we will set up the privacy of the notifications you receive.
""",
inlineKeyBoard(
- simpleLine(
+ keyBoardLine(
simpleButton("\uD83E\uDD77 start setting up \uD83E\uDD77", "start setting up")
)
)
@@ -490,7 +555,7 @@ public class InitSettingFlow implements UnitConfiguration {
) {
return AnswerText.builder()
.answer(
- replaceBoxAnswer("""
+ () -> replaceBoxAnswer("""
A lot of confidential information can be contained in notifications of posts in a thread.
Choose a privacy level: