Добавил создание команд при старте

This commit is contained in:
Struchkov Mark 2023-03-05 18:57:24 +03:00
parent 93a0ad49f5
commit e6b77e0164
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6

View File

@ -1,12 +1,12 @@
package dev.struchkov.bot.gitlab.telegram.service; package dev.struchkov.bot.gitlab.telegram.service;
import dev.struchkov.bot.gitlab.context.service.AppSettingService; 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.context.utils.Icons;
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.simple.domain.BoxAnswer; import dev.struchkov.godfather.simple.domain.BoxAnswer;
import dev.struchkov.godfather.simple.domain.SentBox; 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.TelegramSending;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramService; import dev.struchkov.godfather.telegram.simple.context.service.TelegramService;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
@ -17,6 +17,7 @@ import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -29,8 +30,8 @@ import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
/** /**
* @author upagge 19.01.2021 * @author upagge 19.01.2021
*/ */
@Component
@Slf4j @Slf4j
@Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class StartNotify { public class StartNotify {
@ -39,8 +40,6 @@ public class StartNotify {
private final TelegramSending sending; private final TelegramSending sending;
private final TelegramService telegramService; private final TelegramService telegramService;
private final NotifyService notifyService;
private final AppProperty appProperty; private final AppProperty appProperty;
private final AppSettingService settingService; private final AppSettingService settingService;
private final PersonProperty personProperty; private final PersonProperty personProperty;
@ -66,7 +65,6 @@ public class StartNotify {
.payload(DISABLE_WEB_PAGE_PREVIEW, true) .payload(DISABLE_WEB_PAGE_PREVIEW, true)
.build(); .build();
sending.send(boxAnswer); sending.send(boxAnswer);
sendNotice(); sendNotice();
} }
registrationForStatistic(); registrationForStatistic();
@ -102,7 +100,7 @@ public class StartNotify {
final BoxAnswer notice = BoxAnswer.builder() final BoxAnswer notice = BoxAnswer.builder()
.message(noticeMessage) .message(noticeMessage)
.recipientPersonId(personProperty.getTelegramId()) .recipientPersonId(personProperty.getTelegramId())
// .payload(DISABLE_WEB_PAGE_PREVIEW, true) .payload(DISABLE_WEB_PAGE_PREVIEW, true)
.build(); .build();
final Optional<SentBox> optSentBox = sending.send(notice); final Optional<SentBox> optSentBox = sending.send(notice);
if (optSentBox.isPresent()) { if (optSentBox.isPresent()) {
@ -117,17 +115,12 @@ public class StartNotify {
} }
} }
// @PostConstruct @PostConstruct
// public void demo() { public void createCommands() {
// notifyService.send( final ClientBotCommand clientBotCommand = new ClientBotCommand();
// DiscussionNewNotify.builder() clientBotCommand.setDescription("Open general menu");
// .authorName("Ivan Ivanov") clientBotCommand.setKey("start");
// .threadId("1") telegramService.addCommand(List.of(clientBotCommand));
// .discussionMessage("Кажется здесь можно сделать лучше.") }
// .mergeRequestName("Merge Request Name")
// .url("https://ya.ru")
// .build()
// );
// }
} }