From 810ed84fcfe4ca063bd3faeb67beae0e027e19e0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 18 Jul 2016 16:28:32 +0300 Subject: juick-api: telegram bot troubleshooting --- juick-api/src/main/java/com/juick/api/TelegramBotHook.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'juick-api/src/main/java') 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 chats = getChats(); String username = message.from().username(); if (username == null) { -- cgit v1.2.3