Compare commits

...

3 Commits

4 changed files with 21 additions and 12 deletions

View File

@ -107,13 +107,13 @@
<dependency> <dependency>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-utils</artifactId> <artifactId>haiti-utils</artifactId>
<version>2.3.4</version> <version>2.5.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-exception</artifactId> <artifactId>haiti-exception</artifactId>
<version>2.3.4</version> <version>2.5.0</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -4,6 +4,7 @@ import dev.struchkov.bot.gitlab.context.service.AppSettingService;
import dev.struchkov.bot.gitlab.core.config.properties.AppProperty; import dev.struchkov.bot.gitlab.core.config.properties.AppProperty;
import dev.struchkov.bot.gitlab.core.config.properties.PersonProperty; import dev.struchkov.bot.gitlab.core.config.properties.PersonProperty;
import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.BoxAnswer;
import dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -27,12 +28,14 @@ public class StartNotify {
final BoxAnswer boxAnswer = BoxAnswer.builder() final BoxAnswer boxAnswer = BoxAnswer.builder()
.recipientPersonId(personProperty.getTelegramId()) .recipientPersonId(personProperty.getTelegramId())
.message( .message(
new StringBuilder() "Hello \uD83D\uDC4B\nI wish you a productive day \uD83C\uDF40" +
.append("Hello. I wish you a productive day :)") "\n-- -- -- -- --\n" +
.append("\n-- -- -- -- --\n") "\uD83E\uDD16 Bot Version " + appProperty.getVersion() +
.append("Version ").append(appProperty.getVersion()).append(" | Developer: [uPagge](https://mark.struchkov.dev)") "\n\uD83D\uDC68\u200D\uD83D\uDCBB Developer: [uPagge](https://mark.struchkov.dev)" +
.toString() "\n\uD83D\uDC1B Issue: [GitHub Issue](https://github.com/uPagge/gitlab-notification/issues)"
).build(); )
.payload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true)
.build();
sending.send(boxAnswer); sending.send(boxAnswer);
} }

View File

@ -4,6 +4,7 @@ import dev.struchkov.bot.gitlab.context.domain.notify.project.NewProjectNotify;
import dev.struchkov.bot.gitlab.context.utils.Icons; import dev.struchkov.bot.gitlab.context.utils.Icons;
import dev.struchkov.bot.gitlab.telegram.utils.Const; import dev.struchkov.bot.gitlab.telegram.utils.Const;
import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.BoxAnswer;
import dev.struchkov.haiti.utils.Checker;
import dev.struchkov.haiti.utils.Strings; import dev.struchkov.haiti.utils.Strings;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,10 +24,10 @@ public class NewProjectNotifyGenerator implements NotifyBoxAnswerGenerator<NewPr
@Override @Override
public BoxAnswer generate(NewProjectNotify notify) { public BoxAnswer generate(NewProjectNotify notify) {
final Optional<String> optDescription = Optional.ofNullable(notify.getProjectDescription()) final Optional<String> optDescription = Optional.ofNullable(notify.getProjectDescription())
.filter(Strings.EMPTY::equals) .filter(Checker::checkNotBlank)
.map(Strings::escapeMarkdown); .map(Strings::escapeMarkdown);
final StringBuilder builder = new StringBuilder(Icons.FUN).append("* New project*") final StringBuilder builder = new StringBuilder(Icons.FUN).append(" *New project*")
.append(Icons.HR) .append(Icons.HR)
.append(escapeMarkdown(notify.getProjectName())) .append(escapeMarkdown(notify.getProjectName()))
.append(Icons.HR); .append(Icons.HR);

View File

@ -18,6 +18,7 @@ import dev.struchkov.godfather.simple.core.unit.AnswerText;
import dev.struchkov.godfather.simple.core.unit.MainUnit; import dev.struchkov.godfather.simple.core.unit.MainUnit;
import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment; import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment;
import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard;
import dev.struchkov.godfather.telegram.main.context.MailPayload;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.haiti.utils.Checker; import dev.struchkov.haiti.utils.Checker;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -69,9 +70,13 @@ public class MenuConfig {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getPersonId())) .triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getPersonId()))
.answer(message -> { .answer(message -> {
final String messageText = new StringBuilder("\uD83D\uDEA8 *Попытка несанкционированного доступа к боту*") final String messageText = new StringBuilder("\uD83D\uDEA8 *Attempted unauthorized access to the bot*")
.append(Icons.HR) .append(Icons.HR)
.append("\uD83E\uDDB9\u200D♂: ").append(message.getPersonId()).append("\n") .append("\uD83E\uDDB9\u200D♂: ").append(
message.getPayLoad(MailPayload.USERNAME)
.map(username -> "@" + username)
.orElseThrow()
).append("\n")
.append("\uD83D\uDCAC: ").append(message.getText()) .append("\uD83D\uDCAC: ").append(message.getText())
.toString(); .toString();
return BoxAnswer.builder().recipientPersonId(personInformation.getTelegramId()).message(messageText).build(); return BoxAnswer.builder().recipientPersonId(personInformation.getTelegramId()).message(messageText).build();