From ff2d302db522e04cae7c12c390b1deb25df9b8ec Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 21 Dec 2022 19:28:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B8=D0=B4=D0=B5=D0=BD=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20ButtonClickAttachment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/consumer/CallbackQueryConvert.java | 5 +++-- .../domain/attachment/ButtonClickAttachment.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java b/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java index 302ed79..1884a02 100644 --- a/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java +++ b/telegram-consumer/telegram-consumer-main/src/main/java/dev/struchkov/godfather/telegram/main/consumer/CallbackQueryConvert.java @@ -20,7 +20,7 @@ public class CallbackQueryConvert { final Mail mail = new Mail(); mail.setCreateDate(LocalDateTime.now()); mail.setText(callbackData); - mail.addAttachment(convertToButtonClick(callbackData)); + mail.addAttachment(convertToButtonClick(callbackData, callbackQuery.getMessage().getMessageId())); final Long chatId = callbackQuery.getMessage().getChatId(); mail.setPersonId(chatId != null ? chatId.toString() : null); @@ -31,9 +31,10 @@ public class CallbackQueryConvert { return mail; } - private static ButtonClickAttachment convertToButtonClick(String callbackData) { + private static ButtonClickAttachment convertToButtonClick(String callbackData, Integer messageId) { final ButtonClickAttachment buttonClickAttachment = new ButtonClickAttachment(); buttonClickAttachment.setRawCallBackData(callbackData); + buttonClickAttachment.setMessageId(messageId); if (callbackData.charAt(0) == '[' && callbackData.charAt(callbackData.length() - 1) == ']') { final String[] args = callbackData.substring(1, callbackData.length() - 1).split(";"); for (String arg : args) { diff --git a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java b/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java index c7d3eac..bf8f6a7 100644 --- a/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java +++ b/telegram-domain/src/main/java/dev/struchkov/godfather/telegram/domain/attachment/ButtonClickAttachment.java @@ -12,6 +12,10 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull; public class ButtonClickAttachment extends Attachment { + /** + * Идентификатор сообщения, под которым пользователь нажал кнопку. + */ + private Integer messageId; private String rawCallBackData; private final Map args = new HashMap<>(); @@ -42,6 +46,18 @@ public class ButtonClickAttachment extends Attachment { return args.values(); } + public Integer getMessageId() { + return messageId; + } + + public void setMessageId(Integer messageId) { + this.messageId = messageId; + } + + public Map getArgs() { + return args; + } + @Override public String getType() { return TelegramAttachmentType.BUTTON_CLICK.name();