directly using the bot api but now I wanted to use java-telegram-bot-api, I know setting the webhook but how do I receive incoming updates using this library? What I do Before using library is create simple socket server and listen for incoming updates and then process the json response. So Is there a method in this library to create the webhook listener( like port) or it's me who is supposed to process the update and convert to an Update object. I tried to read the ReadMe and what are this stringRequest and reader in this line of code
Update update = BotUtils.parseUpdate(stringRequest); // from String
Update update = BotUtils.parseUpdate(reader); // or from java.io.Reader
I used to code using mainly just plain java and wanted to use libraries and follow standard practice and design patterns.
Based on the fact that you're given that method, it's you who are supposed to receive updates
OK Thank you. I needed to confirm this.
There isn't really a standard practice. You can use the library for setting up a webhook but all the library does is spin up an embedded Webserver. If you already have a way to receive and parse the updates just call the onUpdatesReceived method of your bot
Sorry wrong lib. I don't know if that library has any way of registering a webhook. But it's not really complex enough to warrant a library implementation
I use this library and never tried webhooks with it yet. But I guess you need your own backend for that. Just add spring + rest to your project (I can't believe I tell somebody to add spring to a bot project but still)
Adding spring for a single http endpoint is blowing up pigeons with a 500lb bomb. There are plenty of minimalist http Server libs for java
Well at least he would get a chance to practice ioc 😁
Обсуждают сегодня