From e6b77e0164211a8d456aa3e56873f919efc743d2 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 5 Mar 2023 18:57:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D0=B4=20=D0=BF=D1=80=D0=B8=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gitlab/telegram/service/StartNotify.java | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) 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 e8960b6..fa87892 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 @@ -1,12 +1,12 @@ package dev.struchkov.bot.gitlab.telegram.service; import dev.struchkov.bot.gitlab.context.service.AppSettingService; -import dev.struchkov.bot.gitlab.context.service.NotifyService; import dev.struchkov.bot.gitlab.context.utils.Icons; import dev.struchkov.bot.gitlab.core.config.properties.AppProperty; import dev.struchkov.bot.gitlab.core.config.properties.PersonProperty; import dev.struchkov.godfather.simple.domain.BoxAnswer; import dev.struchkov.godfather.simple.domain.SentBox; +import dev.struchkov.godfather.telegram.domain.ClientBotCommand; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramService; import jakarta.annotation.PostConstruct; @@ -17,6 +17,7 @@ import okhttp3.Request; import okhttp3.Response; import org.springframework.stereotype.Component; +import java.util.List; import java.util.Optional; import java.util.UUID; @@ -29,8 +30,8 @@ import static dev.struchkov.haiti.utils.Checker.checkNotBlank; /** * @author upagge 19.01.2021 */ -@Component @Slf4j +@Component @RequiredArgsConstructor public class StartNotify { @@ -39,8 +40,6 @@ public class StartNotify { private final TelegramSending sending; private final TelegramService telegramService; - private final NotifyService notifyService; - private final AppProperty appProperty; private final AppSettingService settingService; private final PersonProperty personProperty; @@ -66,7 +65,6 @@ public class StartNotify { .payload(DISABLE_WEB_PAGE_PREVIEW, true) .build(); sending.send(boxAnswer); - sendNotice(); } registrationForStatistic(); @@ -102,7 +100,7 @@ public class StartNotify { final BoxAnswer notice = BoxAnswer.builder() .message(noticeMessage) .recipientPersonId(personProperty.getTelegramId()) -// .payload(DISABLE_WEB_PAGE_PREVIEW, true) + .payload(DISABLE_WEB_PAGE_PREVIEW, true) .build(); final Optional optSentBox = sending.send(notice); if (optSentBox.isPresent()) { @@ -117,17 +115,12 @@ public class StartNotify { } } - // @PostConstruct -// public void demo() { -// notifyService.send( -// DiscussionNewNotify.builder() -// .authorName("Ivan Ivanov") -// .threadId("1") -// .discussionMessage("Кажется здесь можно сделать лучше.") -// .mergeRequestName("Merge Request Name") -// .url("https://ya.ru") -// .build() -// ); -// } + @PostConstruct + public void createCommands() { + final ClientBotCommand clientBotCommand = new ClientBotCommand(); + clientBotCommand.setDescription("Open general menu"); + clientBotCommand.setKey("start"); + telegramService.addCommand(List.of(clientBotCommand)); + } }