aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api/TelegramBotHook.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-05-12 22:27:41 +0300
committerGravatar Vitaly Takmazov2016-05-12 22:27:41 +0300
commitc58e021d8631fd8e1dd1d40546a4aabce27e2cdf (patch)
tree29b9e1cd5ff528f89123a0f8b49b0ebe73a4ce3e /src/main/java/com/juick/api/TelegramBotHook.java
parent70a6b6c49ee6e220942a43ae4328ce9dcd24232b (diff)
parse update
Diffstat (limited to 'src/main/java/com/juick/api/TelegramBotHook.java')
-rw-r--r--src/main/java/com/juick/api/TelegramBotHook.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java
index 6d73fbfb..a502e846 100644
--- a/src/main/java/com/juick/api/TelegramBotHook.java
+++ b/src/main/java/com/juick/api/TelegramBotHook.java
@@ -1,10 +1,14 @@
package com.juick.api;
+import com.pengrad.telegrambot.BotUtils;
import com.pengrad.telegrambot.TelegramBot;
import com.pengrad.telegrambot.TelegramBotAdapter;
+import com.pengrad.telegrambot.model.Update;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
import java.util.logging.Logger;
/**
@@ -23,7 +27,11 @@ public class TelegramBotHook {
bot.setWebhook("https://api.juick.com/tlgmbtwbhk");
}
- public void doPost(HttpServletRequest request, HttpServletResponse response) {
- logger.info("got telegram msg: " + request);
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ try (BufferedReader reader = request.getReader()) {
+ Update update = BotUtils.parseUpdate(reader);
+ logger.info("got telegram msg: " + update.message().toString());
+ }
}
}