I use this API : https://github.com/pengrad/java-telegram-bot-api to work with Telegram Bot . Created a bot, set him /setinline and /setinlinegeo . When a user writes in any chat of NameBot, then everything works well, but if the user writes to the bot in private, the bot starts to cycle through all messages. Here is the code:
int lastUpdateId = 0; while (true) { GetUpdatesResponse updatesResponse = bot.execute(new GetUpdates().limit(lastUpdateId).offset(1).timeout(0)); System.out.println(lastUpdateId); List<Update> updates = updatesResponse.updates(); if (updates.size() > 0) { lastUpdateId++; for (Update update : updates) { try { lastUpdateId = update.updateId(); Message message = update.message(); InlineQuery inlineQuery = update.inlineQuery(); if (inlineQuery != null) { Location location = inlineQuery.location(); String id = update.inlineQuery().id(); InlineQueryResultLocation r1 = new InlineQueryResultLocation(id, location.latitude(), location.longitude(), "Ваша локация"); // bot.execute(new AnswerInlineQuery(update.inlineQuery().id(), r1)); } if (message != null && message.chat() != null) { Long id = message.chat().id(); System.out.println(message); // bot.execute(new SendMessage(id,"текст")); } System.out.println(lastUpdateId); // показать что выбирает в цикле } catch (Exception e) { e.printStackTrace(); } } } } Maximum update_id = 898228320, but constantly chooses in the cycle (898228315.898228318.898228319.898228320) and again for the new ... Ie The new GetUpdates().limit(lastUpdateId).offset(1).timeout(0) method new GetUpdates().limit(lastUpdateId).offset(1).timeout(0) should return 1 message that is larger than lastUpdateId, but returns 4 messages for some reason, even if you initially restrict int lastUpdateId = 898228321; ... (
