aboutsummaryrefslogtreecommitdiff
path: root/juick-api
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api')
-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 29b32af29..682001f6f 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) {