aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-05-13 14:47:14 +0300
committerGravatar Vitaly Takmazov2016-05-13 14:47:14 +0300
commitd7b8c7307b09a0dad102c37863bd03d551b5c8a9 (patch)
treed5bba4f97530dcbcb60d1718fa5e3cc9138d5f05 /src/main/java/com/juick/api
parent2a595eb7e7f0c220f38b1501b75d97f7b8a234a3 (diff)
url as button
Diffstat (limited to 'src/main/java/com/juick/api')
-rw-r--r--src/main/java/com/juick/api/TelegramBotHook.java11
1 files changed, 8 insertions, 3 deletions
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<Long> chats = getChats();
chats.stream().forEach(c -> {
- bot.execute(new SendMessage(c, msg), new Callback<SendMessage, SendResponse>() {
+ bot.execute(new SendMessage(c, msg).replyMarkup(
+ new InlineKeyboardMarkup(
+ new InlineKeyboardButton[] {
+ new InlineKeyboardButton("See on Juick").url("https://juick.com/" + jmsg.getMID())
+ }
+ )), new Callback<SendMessage, SendResponse>() {
@Override
public void onResponse(SendMessage request, SendResponse response) {
logger.info("got response: " + response.message().toString());