При разбивке большого сообщения на несколько добавил клавиатуру в последнее сообщение

This commit is contained in:
Struchkov Mark 2023-05-10 00:14:27 +03:00
parent 824a95a305
commit 23e01a3145
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6

View File

@ -320,19 +320,21 @@ public class TelegramSender implements TelegramSending {
while (message.length() > maxMessageLength) {
String subMessage = message.substring(0, maxMessageLength);
message = message.substring(maxMessageLength);
split.add(createNewTextAnswer(boxAnswer, subMessage));
split.add(createNewTextAnswer(boxAnswer, subMessage, false));
}
split.add(createNewTextAnswer(boxAnswer, message));
split.add(createNewTextAnswer(boxAnswer, message, true));
return Multi.createFrom().iterable(split);
}
private SendMessage createNewTextAnswer(BoxAnswer boxAnswer, String subMessage) {
private SendMessage createNewTextAnswer(BoxAnswer boxAnswer, String subMessage, boolean lastMessage) {
final SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(boxAnswer.getRecipientPersonId());
sendMessage.setText(subMessage);
sendMessage.setReplyMarkup(convertKeyBoard(boxAnswer.getKeyBoard()));
if (lastMessage) {
sendMessage.setReplyMarkup(convertKeyBoard(boxAnswer.getKeyBoard()));
}
boxAnswer.getPayLoad(ENABLE_MARKDOWN).ifPresent(sendMessage::enableMarkdown);
boxAnswer.getPayLoad(ENABLE_HTML).ifPresent(sendMessage::enableHtml);