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; /** * Created by vt on 12/05/16. */ public class TelegramBotHook { private static final Logger logger = Logger.getLogger(TelegramBotHook.class.getName()); private String token; TelegramBot bot; public TelegramBotHook(String token) { this.token = token; bot = TelegramBotAdapter.build(token); bot.setWebhook("https://api.juick.com/tlgmbtwbhk"); } 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()); } } }