diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api/webhooks')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java b/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java index 10fd1ab3..8497cff1 100644 --- a/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java +++ b/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java @@ -18,7 +18,11 @@ package com.juick.server.api.webhooks; import com.juick.server.TelegramBotManager; +import com.pengrad.telegrambot.BotUtils; +import com.pengrad.telegrambot.model.Update; import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestMapping; @@ -36,8 +40,9 @@ import java.nio.charset.StandardCharsets; */ @ApiIgnore @RestController -@ConditionalOnProperty(name = "telegram_token") +@ConditionalOnProperty({"telegram_token", "telegram_debug"}) public class TelegramWebhook { + private static final Logger logger = LoggerFactory.getLogger(TelegramWebhook.class); @Inject private TelegramBotManager telegramBotManager; @@ -45,6 +50,8 @@ public class TelegramWebhook { @ResponseStatus(value = HttpStatus.OK) public void processUpdate(InputStream body) throws Exception { String data = IOUtils.toString(body, StandardCharsets.UTF_8); - telegramBotManager.processUpdate(data); + logger.info("Telegram update: {}", data); + Update update = BotUtils.parseUpdate(data); + telegramBotManager.processUpdate(update); } } |