diff options
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/TelegramBotManager.java')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TelegramBotManager.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java index 7e6d0b17..33e71fee 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java @@ -25,6 +25,7 @@ import com.pengrad.telegrambot.Callback; import com.pengrad.telegrambot.TelegramBot; import com.pengrad.telegrambot.model.request.InlineKeyboardButton; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; +import com.pengrad.telegrambot.model.request.ParseMode; import com.pengrad.telegrambot.request.SendMessage; import com.pengrad.telegrambot.request.SetWebhook; import com.pengrad.telegrambot.response.SendResponse; @@ -70,6 +71,8 @@ public class TelegramBotManager extends TextWebSocketHandler { private WebSocketSession session; + public static final String MSG_LINK = "🔗"; + @PostConstruct public void init() { if (StringUtils.isBlank(telegramToken)) { @@ -115,7 +118,7 @@ public class TelegramBotManager extends TextWebSocketHandler { String msgUrl = formatUrl(jmsg); if (jmsg.getRid() == 0) { - String msg = formatPost(jmsg); + String msg = String.format("[%s](%s) %s", MSG_LINK, msgUrl, formatPost(jmsg)); List<Long> users = telegramService.getTelegramIdentifiers(subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())); List<Long> chats = telegramService.getChats(); @@ -127,7 +130,7 @@ public class TelegramBotManager extends TextWebSocketHandler { } else { // get quote com.juick.Message msg = messagesService.getReply(jmsg.getMid(), jmsg.getRid()); - String fmsg = formatPost(msg); + String fmsg = String.format("[%s](%s) %s", MSG_LINK, msgUrl, formatPost(msg)); telegramService.getTelegramIdentifiers( subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid()) ).forEach(c -> telegramNotify(c, fmsg, msgUrl)); @@ -136,14 +139,7 @@ public class TelegramBotManager extends TextWebSocketHandler { public void telegramNotify(Long c, String msg, String msgUrl) { SendMessage telegramMessage = new SendMessage(c, msg); - if (msgUrl != null) { - telegramMessage.replyMarkup( - new InlineKeyboardMarkup( - new InlineKeyboardButton[]{ - new InlineKeyboardButton("See on Juick").url(msgUrl) - } - )); - } + telegramMessage.parseMode(ParseMode.Markdown); bot.execute(telegramMessage, new Callback<SendMessage, SendResponse>() { @Override public void onResponse(SendMessage request, SendResponse response) { |