Compare commits
2 Commits
d1c1783c63
...
b49b7d2829
Author | SHA1 | Date | |
---|---|---|---|
b49b7d2829 | |||
022fb152f7 |
@ -92,7 +92,7 @@ public class ProjectParser {
|
|||||||
.header(ACCEPT)
|
.header(ACCEPT)
|
||||||
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())
|
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())
|
||||||
.execute(ProjectJson.class)
|
.execute(ProjectJson.class)
|
||||||
.orElseThrow(convertException("Ошибка получения репозитория."));
|
.orElseThrow(convertException("Error adding a repository"));
|
||||||
if (!projectService.existsById(projectJson.getId())) {
|
if (!projectService.existsById(projectJson.getId())) {
|
||||||
createNewPersons(List.of(projectJson));
|
createNewPersons(List.of(projectJson));
|
||||||
final Project newProject = conversionService.convert(projectJson, Project.class);
|
final Project newProject = conversionService.convert(projectJson, Project.class);
|
||||||
|
@ -10,6 +10,7 @@ import dev.struchkov.bot.gitlab.telegram.unit.command.EnableProjectNotify;
|
|||||||
import dev.struchkov.bot.gitlab.telegram.unit.flow.InitSettingFlow;
|
import dev.struchkov.bot.gitlab.telegram.unit.flow.InitSettingFlow;
|
||||||
import dev.struchkov.godfather.main.core.unit.TypeUnit;
|
import dev.struchkov.godfather.main.core.unit.TypeUnit;
|
||||||
import dev.struchkov.godfather.main.domain.content.Mail;
|
import dev.struchkov.godfather.main.domain.content.Mail;
|
||||||
|
import dev.struchkov.godfather.simple.context.service.ErrorHandler;
|
||||||
import dev.struchkov.godfather.simple.context.service.EventHandler;
|
import dev.struchkov.godfather.simple.context.service.EventHandler;
|
||||||
import dev.struchkov.godfather.simple.context.service.PersonSettingService;
|
import dev.struchkov.godfather.simple.context.service.PersonSettingService;
|
||||||
import dev.struchkov.godfather.simple.context.service.UnitPointerService;
|
import dev.struchkov.godfather.simple.context.service.UnitPointerService;
|
||||||
@ -99,6 +100,7 @@ public class TelegramBotConfig {
|
|||||||
@Qualifier("messageExecutorService") ExecutorService executorService,
|
@Qualifier("messageExecutorService") ExecutorService executorService,
|
||||||
TelegramSending sending,
|
TelegramSending sending,
|
||||||
PersonSettingService personSettingService,
|
PersonSettingService personSettingService,
|
||||||
|
ErrorHandler errorHandler,
|
||||||
|
|
||||||
StorylineService<Mail> storylineService
|
StorylineService<Mail> storylineService
|
||||||
) {
|
) {
|
||||||
@ -107,6 +109,7 @@ public class TelegramBotConfig {
|
|||||||
);
|
);
|
||||||
autoresponder.initActionUnit(TypeUnit.BACK_CMD, new RollBackCmdAction<>(storylineService));
|
autoresponder.initActionUnit(TypeUnit.BACK_CMD, new RollBackCmdAction<>(storylineService));
|
||||||
autoresponder.setExecutorService(executorService);
|
autoresponder.setExecutorService(executorService);
|
||||||
|
autoresponder.setErrorHandler(errorHandler);
|
||||||
return autoresponder;
|
return autoresponder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package dev.struchkov.bot.gitlab.telegram.service;
|
||||||
|
|
||||||
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
|
import dev.struchkov.godfather.main.domain.content.Message;
|
||||||
|
import dev.struchkov.godfather.simple.context.service.ErrorHandler;
|
||||||
|
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ErrorHandlerService implements ErrorHandler {
|
||||||
|
|
||||||
|
private final TelegramSending telegramSending;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Message message, Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
final BoxAnswer boxAnswer = boxAnswer(e.getMessage());
|
||||||
|
boxAnswer.setRecipientIfNull(message.getPersonId());
|
||||||
|
telegramSending.send(boxAnswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,6 +10,9 @@ import jakarta.annotation.PostConstruct;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
|
||||||
|
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author upagge 19.01.2021
|
* @author upagge 19.01.2021
|
||||||
*/
|
*/
|
||||||
@ -34,6 +37,11 @@ public class StartNotify {
|
|||||||
"\n\uD83D\uDC68\u200D\uD83D\uDCBB️ Developer: [uPagge](https://mark.struchkov.dev)" +
|
"\n\uD83D\uDC68\u200D\uD83D\uDCBB️ Developer: [uPagge](https://mark.struchkov.dev)" +
|
||||||
"\n\uD83D\uDC1B Issue: [GitHub Issue](https://github.com/uPagge/gitlab-notification/issues)"
|
"\n\uD83D\uDC1B Issue: [GitHub Issue](https://github.com/uPagge/gitlab-notification/issues)"
|
||||||
)
|
)
|
||||||
|
.keyBoard(
|
||||||
|
inlineKeyBoard(
|
||||||
|
simpleButton("Open General Menu", "/start")
|
||||||
|
)
|
||||||
|
)
|
||||||
.payload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true)
|
.payload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class MenuConfig {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unit(value = GENERAL_MENU, main = true)
|
@Unit(value = GENERAL_MENU, main = true, global = true)
|
||||||
public AnswerText<Mail> menu(
|
public AnswerText<Mail> menu(
|
||||||
@Unit(SETTINGS) MainUnit<Mail> settings,
|
@Unit(SETTINGS) MainUnit<Mail> settings,
|
||||||
@Unit(TEXT_ADD_NEW_PROJECT) MainUnit<Mail> textAddNewProject,
|
@Unit(TEXT_ADD_NEW_PROJECT) MainUnit<Mail> textAddNewProject,
|
||||||
@ -102,9 +102,13 @@ public class MenuConfig {
|
|||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.answer(mail -> {
|
.answer(mail -> {
|
||||||
final String messageText = "This is the bot menu, select a new item";
|
final String messageText = """
|
||||||
|
This is the bot menu, select a item.
|
||||||
|
-- -- -- -- --
|
||||||
|
At the moment, you can only add new repositories. But in future versions, the possibilities will expand.
|
||||||
|
""";
|
||||||
final InlineKeyBoard generalMenuKeyBoard = inlineKeyBoard(
|
final InlineKeyBoard generalMenuKeyBoard = inlineKeyBoard(
|
||||||
simpleLine(simpleButton("Add project", TEXT_ADD_NEW_PROJECT))
|
simpleLine(simpleButton("Add repository", TEXT_ADD_NEW_PROJECT))
|
||||||
// simpleLine(
|
// simpleLine(
|
||||||
// simpleButton("My tasks", GET_TASKS),
|
// simpleButton("My tasks", GET_TASKS),
|
||||||
// simpleButton("Merge Request", GET_ASSIGNEE_MERGE_REQUEST)
|
// simpleButton("Merge Request", GET_ASSIGNEE_MERGE_REQUEST)
|
||||||
|
Loading…
Reference in New Issue
Block a user