aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-18 16:28:32 +0300
committerGravatar Vitaly Takmazov2016-07-18 16:28:32 +0300
commit810ed84fcfe4ca063bd3faeb67beae0e027e19e0 (patch)
treed747e9ad5d131bd5402128b41aa6ae430721512f /juick-api/src/main/java
parentb175518ef8239854981136dcf38a7a09f6aa434f (diff)
juick-api: telegram bot troubleshooting
Diffstat (limited to 'juick-api/src/main/java')
-rw-r--r--juick-api/src/main/java/com/juick/api/TelegramBotHook.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
index 29b32af2..682001f6 100644
--- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
+++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
@@ -10,6 +10,7 @@ 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.Update;
import com.pengrad.telegrambot.model.request.InlineKeyboardButton;
import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup;
import com.pengrad.telegrambot.request.SendMessage;
@@ -149,9 +150,16 @@ public class TelegramBotHook {
public void doPost(HttpServletRequest request) throws IOException {
try (BufferedReader reader = request.getReader()) {
- Message message = BotUtils.parseUpdate(reader).message();
+ Update update = BotUtils.parseUpdate(reader);
+ Message message = update.message();
+ if (update.message() == null) {
+ logger.log(Level.SEVERE, "error parsing telegram update: " + update.toString());
+ return;
+ }
+ logger.info(String.format("got telegram msg %s", message.toString()));
User user_from = UserQueries.getUserByUID(jdbc, getUser(message.chat().id())).orElse(new User());
- logger.info(String.format("got telegram msg %s from juick user %d", message.toString(), user_from.getUID()));
+ logger.info(String.format("Found juick user %d", user_from.getUID()));
+
List<Long> chats = getChats();
String username = message.from().username();
if (username == null) {