diff --git a/pom.xml b/pom.xml
index 5446aa5..b441444 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,7 @@
UTF-8
UTF-8
- 0.0.42
+ 0.0.43
2.2
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 8638a0d..b3c7761 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
@@ -3,6 +3,7 @@ package dev.struchkov.bot.gitlab.telegram.service;
import dev.struchkov.bot.gitlab.context.domain.PersonInformation;
import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
import dev.struchkov.bot.gitlab.context.service.MessageSendService;
+import dev.struchkov.godfather.main.domain.BoxAnswer;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -25,7 +26,9 @@ public class MessageSendTelegramService implements MessageSendService {
@Override
public void send(@NonNull Notify notify) {
- sending.send(personInformation.getTelegramId(), boxAnswer(notify.generateMessage()));
+ final BoxAnswer boxAnswer = boxAnswer(notify.generateMessage());
+ boxAnswer.setRecipientIfNull(personInformation.getTelegramId());
+ sending.send(boxAnswer);
}
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java
index 875d5ea..a89b4be 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java
@@ -6,8 +6,8 @@ import dev.struchkov.bot.gitlab.context.service.AppSettingService;
import dev.struchkov.bot.gitlab.context.service.DiscussionService;
import dev.struchkov.bot.gitlab.context.service.NoteService;
import dev.struchkov.bot.gitlab.context.service.NotifyService;
+import dev.struchkov.bot.gitlab.context.utils.Smile;
import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser;
-import dev.struchkov.bot.gitlab.telegram.utils.UnitName;
import dev.struchkov.godfather.main.core.unit.UnitActiveType;
import dev.struchkov.godfather.main.domain.BoxAnswer;
import dev.struchkov.godfather.main.domain.annotation.Unit;
@@ -27,7 +27,9 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.ACCESS_ERROR;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.ANSWER_NOTE;
+import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.AUTHORIZATION;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.CHECK_FIRST_START;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.CHECK_MENU_OR_ANSWER;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.CHECK_PARSER_PRIVATE_PROJECT;
@@ -64,13 +66,29 @@ public class UnitConfig {
private final ProjectParser projectParser;
- @Unit(value = UnitName.AUTHORIZATION, main = true)
+ @Unit(value = AUTHORIZATION, main = true)
public AnswerCheck auth(
- @Unit(CHECK_FIRST_START) MainUnit checkFirstStart
+ @Unit(CHECK_FIRST_START) MainUnit checkFirstStart,
+ @Unit(ACCESS_ERROR) MainUnit accessError
) {
return AnswerCheck.builder()
.check(mail -> personInformation.getTelegramId().equals(mail.getPersonId()))
.unitTrue(checkFirstStart)
+ .unitFalse(accessError)
+ .build();
+ }
+
+ @Unit(value = ACCESS_ERROR)
+ public AnswerText accessError() {
+ return AnswerText.builder()
+ .answer(message -> {
+ final String messageText = new StringBuilder("\uD83D\uDEA8 *Попытка несанкционированного доступа к боту*")
+ .append(Smile.HR.getValue())
+ .append("\uD83E\uDDB9\u200D♂️: ").append(message.getPersonId()).append("\n")
+ .append("\uD83D\uDCAC: ").append(message.getText())
+ .toString();
+ return BoxAnswer.builder().recipientPersonId(personInformation.getTelegramId()).message(messageText).build();
+ })
.build();
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java
index 4ee9588..797e1b8 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java
@@ -21,6 +21,7 @@ public final class UnitName {
public static final String PARSE_OWNER_PROJECT = "parseOwnerProject";
public static final String END_SETTING = "endSetting";
public static final String AUTHORIZATION = "AUTHORIZATION";
+ public static final String ACCESS_ERROR = "ACCESS_ERROR";
private UnitName() {
utilityClass();