From 767aec7729a326ff1ccc225d8623a24dd1e698d5 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 5 Apr 2018 22:17:57 +0300 Subject: server: markdown command reply * also fixes new messages with one tag and attachment --- .../src/main/java/com/juick/server/TelegramBotManager.java | 8 ++++++-- juick-server/src/main/java/com/juick/server/api/Post.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server') diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java index 4b2e5278..17ad4630 100644 --- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java +++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java @@ -186,7 +186,9 @@ public class TelegramBotManager implements NotificationListener { prefix = String.format("#%d/%d ", mid, rid); } CommandResult result = commandsManager.processCommand(user_from, null,prefix + text, attachment); - telegramNotify(message.from().id().longValue(), result.getText(), StringUtils.EMPTY); + String messageTxt = StringUtils.isNotEmpty(result.getMarkdown()) ? result.getMarkdown() + : "Unknown error or unsupported command"; + telegramNotify(message.from().id().longValue(), messageTxt, StringUtils.EMPTY); } else { logger.warn("invalid path: {}", path); } @@ -203,7 +205,9 @@ public class TelegramBotManager implements NotificationListener { } } else { CommandResult result = commandsManager.processCommand(user_from, null, text, attachment); - telegramNotify(message.from().id().longValue(), result.getText(), StringUtils.EMPTY); + String messageTxt = StringUtils.isNotEmpty(result.getMarkdown()) ? result.getMarkdown() + : "Unknown error or unsupported command"; + telegramNotify(message.from().id().longValue(), messageTxt, StringUtils.EMPTY); } } } diff --git a/juick-server/src/main/java/com/juick/server/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java index e949dad7..eddd1dd6 100644 --- a/juick-server/src/main/java/com/juick/server/api/Post.java +++ b/juick-server/src/main/java/com/juick/server/api/Post.java @@ -163,7 +163,7 @@ public class Post { } } - return commandsManager.processCommand(visitor, null, body, attachmentFName).getNewMessage(); + return commandsManager.processCommand(visitor, null, body, attachmentFName).getNewMessage().get(); } Session session = Session.getDefaultInstance(new Properties()); -- cgit v1.2.3