TelegramLongPollingBot has been removed and LongPollingUpdateConsumer is its replacement.
Migrate Long Polling Bot
For convenience, a default extension of LongPollingUpdateConsumer is added as LongPollingSingleThreadUpdateConsumer.
Instead of extend TelegramLongPollingBot, implement LongPollingSingleThreadUpdateConsumer.
Instead of overriding void onUpdateReceived(Update update), override void consume(Update update).
Remove any call to super constructor.
Remove any other overrides from previous versions.
Migrate Long Polling Bot
Instead of extend TelegramLongPollingBot, implement LongPollingUpdateConsumer.
Instead of overriding void onUpdatesReceived(List<Update> updates), override void consume(List<Update> updates).
Remove any call to super constructor.
Remove any other overrides from previous versions.
Migrating your existing Webhook bots
TelegramWebhookBot has become an interface instead of an abstract class.
Migrate Webhook Bot
Instead of extend TelegramWebhookBot, implement it.
Instead of overriding BotApiMethod onWebhookUpdateReceived(Update update), override BotApiMethod<?> consumeUpdate(Update update).
Implement your own version of void runDeleteWebhook() and void runSetWebhook().
In getBotPath(), make sure your path starts with /.
Migrate your TelegramBotsApi
Long Polling
For long polling bots, you can start the bot application and start registering your bots:
TelegramBotsLongPollingApplication botsApplication = new TelegramBotsLongPollingApplication();
botsApplication.registerBot("TOKEN", new AmazingBot());
You have available multiple constructors and implementations of registerBot to allow further customisation.
Webhook
For webhook bots, you can start the bot application and start registering your bots:
TelegramBotsWebhookApplication webhookApplication = new TelegramBotsWebhookApplication();
botsApplication.registerBot(new AmazingBot());
You have available multiple constructors and implementations of registerBot to allow further customisation.
Sending API requests
A new class TelegramClient will allow you to perform Telegram API requests independent on the updates consumption.
For convenience, an implementation using okHttp is provided as OkHttpTelegramClient.
TelegramClient telegramClient = new OkHttpTelegramClient("TOKEN");
telegramClient.execute(new SendMessage("chatId", "text"));
Classes that have moved packages
1BotApiMethod and PartialBotApiMethod have been moved to package org.telegram.telegrambots.meta.api.methods.botapimethods 2Message and InaccessibleMessage classes have been moved to org.telegram.telegrambots.meta.api.objects.message.Message
New way to provide Telegram URL
You can use class TelegramUrl to provide your custom URL for your Telegram Bots API.
For convenience, use TelegramUrl.DEFAULT_URL to use the default Telegram-hosted bots API.