I have been programming bots without using any library but

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.

7 ответов

9 просмотров

Based on the fact that you're given that method, it's you who are supposed to receive updates

J- Автор вопроса

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)

s0m31 🇷🇺
I use this library and never tried webhooks with i...

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

Chase helluva noodlebirb
Adding spring for a single http endpoint is blowin...

Well at least he would get a chance to practice ioc 😁

Похожие вопросы

Обсуждают сегодня

А можно не обсуждать тут V?
Darkanronpa Goodbye Despair
18
Вот зачем писать о том, чего ты не знаешь? Стохастический это и есть вероятностный. И в этом и проблема, что один и тот алгоритм на одних и тех же данных выдает разный результ...
Aleksandr Druzhinin
37
Какая бы группа загнулась? Этот канал о Ди. Хотите поговорить о го/зиге/расте - добро пожаловать на каналы этих языков. Тут про Ди не говорят практически. Загнулась бы группа ...
Aleksandr Druzhinin
10
Кстате вопрос. Насколько я помню, был пост. Что в D nogc имеет накладные расходы. При работе с GC. Правда, нет? Разобраться толком времени не хватило.
Vi
3
Уолтер в коммунити zig-а суету наводит: https://news.ycombinator.com/item?id=41015588 С одной стороны, конешн, пиарится, с другой стороны, коркоманде и тому же Kelley, который...
Constantin F.
26
Warning Failed to apply the selected architecture x86_64-pc-windows-msvc. Got ["x86"]. Error Unsupported architecture: x86_64-pc-windows-msvc кто-нибудь знает, что с ldc2? вот...
quantumde1 Зубенко
3
@wintttr gdc, ldc2, dmd?
quantumde1 Зубенко
6
Этот V кто делает?
☭Тупо Лучше Император
3
Я кстате только в играх пока ,действительно вижу проблему от GC. А у вас какие задачи раз GC не нужен?
Vi
2
появился нормальный вывод зависимостей файла в стиле makefile?
Макс Воробьев
4
Карта сайта