diff options
author | Vitaly Takmazov | 2023-12-04 03:48:10 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-12-04 03:48:10 +0300 |
commit | fa89377ea880c2fc6f382ba988675fe159ad85fc (patch) | |
tree | 955cdeb6340c089278e510c021b6bba4c76456b1 | |
parent | a0d0c005568bba9db384f4fc5d13f60b27979cdf (diff) |
Use telegram message caption when trying to edit message with image
-rw-r--r-- | src/main/java/com/juick/TelegramBotManager.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/com/juick/TelegramBotManager.java b/src/main/java/com/juick/TelegramBotManager.java index 3335b61a..dec0bd1d 100644 --- a/src/main/java/com/juick/TelegramBotManager.java +++ b/src/main/java/com/juick/TelegramBotManager.java @@ -60,6 +60,7 @@ import java.io.IOException; import java.net.URI; import java.net.URL; import java.util.*; +import java.util.stream.Stream; import static com.juick.util.formatters.PlainTextFormatter.formatPost; import static com.juick.util.formatters.PlainTextFormatter.formatUrl; @@ -147,7 +148,8 @@ public class TelegramBotManager implements NotificationListener { com.juick.model.Message originalMessage = rid == 0 ? messagesService.getMessage(mid).orElseThrow(IllegalStateException::new) : messagesService.getReply(mid, rid); User author = originalMessage.getUser(); - String newMessageText = StringUtils.defaultString(message.text()); + String newMessageText = Stream.of(message.text(), message.caption()).filter(Objects::nonNull) + .findFirst().orElse(StringUtils.EMPTY); if (user_from.equals(author) && canUpdateMessage(originalMessage, newMessageText)) { if (messagesService.updateMessage(mid, rid, newMessageText, false)) { telegramNotify(message.chat().id(), "Message updated", new com.juick.model.Message()); |