From d7b8c7307b09a0dad102c37863bd03d551b5c8a9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 13 May 2016 14:47:14 +0300 Subject: url as button --- src/main/java/com/juick/api/TelegramBotHook.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java index 880be5e2..cf0979cd 100644 --- a/src/main/java/com/juick/api/TelegramBotHook.java +++ b/src/main/java/com/juick/api/TelegramBotHook.java @@ -7,6 +7,8 @@ import com.pengrad.telegrambot.Callback; import com.pengrad.telegrambot.TelegramBot; import com.pengrad.telegrambot.TelegramBotAdapter; import com.pengrad.telegrambot.model.Message; +import com.pengrad.telegrambot.model.request.InlineKeyboardButton; +import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.request.SendMessage; import com.pengrad.telegrambot.response.SendResponse; import org.json.JSONObject; @@ -15,7 +17,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import javax.servlet.http.HttpServletRequest; import java.io.BufferedReader; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.logging.Level; @@ -62,11 +63,15 @@ public class TelegramBotHook { if (jmsg.getAttachmentURL() != null) { sb.append(jmsg.getAttachmentURL()); } - sb.append("https://juick.com/").append(jmsg.getMID()); String msg = sb.toString(); List chats = getChats(); chats.stream().forEach(c -> { - bot.execute(new SendMessage(c, msg), new Callback() { + bot.execute(new SendMessage(c, msg).replyMarkup( + new InlineKeyboardMarkup( + new InlineKeyboardButton[] { + new InlineKeyboardButton("See on Juick").url("https://juick.com/" + jmsg.getMID()) + } + )), new Callback() { @Override public void onResponse(SendMessage request, SendResponse response) { logger.info("got response: " + response.message().toString()); -- cgit v1.2.3