How To Update
If there are any changes required to update to a new version, they'll be listed here.
To version 7.6.0
If you are using a custom TelegramClient, you'll need to implement the new methods for
SendPaidMedia
To version 7.3.0
Class
org.telegram.telegrambots.meta.api.objects.Chat
has been split (as per API guidelines) intoorg.telegram.telegrambots.meta.api.objects.chat.Chat
andorg.telegram.telegrambots.meta.api.objects.chat.ChatFullInfo
, old class is still available but unused.
To version 7.2.1
Instead of using
TelegramOkHttpClientFactory.ProxyOkHttpClientCreator
use eitherTelegramOkHttpClientFactory.HttpProxyOkHttpClientCreator
orTelegramOkHttpClientFactory.SocksProxyOkHttpClientCreator
To version 7.2.0
When using
CreateNewStickerSet
, instead of providing a common format usingsetStickerFormat
, provide eachInputSticker
with its own format. MethodssetStickerFormat
andgetStickerFormat
are kept only for backward compatibility and work only when all stickers have the same format.SetStickerSetThumbnail
andInputSticker
contain aformat
field mandatory.ChatMemberUpdated
andMemberStatus
have been moved to packageorg.telegram.telegrambots.meta.api.objects.chatmember
. Old classes are maintained for backward compatibility.UsersShared
contains an array ofusers
. OldgetUserIds
is maintained for backward compatibility.
To version 7.0.0
This is a huge update, so the proper documentation is a WIP here
To version 6.9.7.0
CallbackQuery
methodgetMessage
now return an instance ofMaybeInaccessibleMessage
. Check type to identify if it is aMessage
or aInaccessibleMessage
.Message
methodgetPinnedMessage
now return an instance ofMaybeInaccessibleMessage
. Check type to identify if it is aMessage
or aInaccessibleMessage
.
To version 6.8.0
Api methods with thumbnails have changed the field, use getThumbnail()/setThumbnail() instead of getThumb()/setThumb()
In
AddStickerToSet
,CreateNewStickerSet
,UploadStickerFile
, etc., use fieldsticker
instead of the deprecated fields.ChatMember
has more details permissions, use those instead of the legacy general ones.All classes with mandatory fields will lose the default no-arg constructor in the future.
In
AnswerInlineQuery
, start using thebutton
field instead of deprecated parameters.
To version 6.1.0
As per API guidelines, FileSize can now have 64 bits size, hence they are now using Long datatype instead of Integer.
Methods accept chatId as Long or String.
To version 5.3.0
As per API guidelines, ChatMember method has been divided in different classed. Where used in your code, replace old import with new one (GetChatAdministrators.java, GetChatMember.java, ChatMemberUpdated.java):
import org.telegram.telegrambots.meta.api.objects.ChatMember;
to
import org.telegram.telegrambots.meta.api.objects.chatmember.ChatMember;
ChatMember is an interface now, you'll need to cast it to the corresponding implementation when using it.
GetChatMembersCount
renamed toGetChatMemberCount
, old version will still work until next major version.KickChatMember
renamed toBanChatMember
, old version will still work until next major version.
To version 5.1.0
All users IDs fields are now Long type as per API guidelines.
To version 5.0.0
ApiContextInitializer.init(); has been removed and is not required anymore, instead:
TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class); // When using webhook, create your own version of DefaultWebhook with all your parameters set. TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class, defaultWebhookInstance);For location related class, change from Float to Double type, i.e:
Double latitude = location.getLatitude()Instead of chain set method, use builder pattern:
// Before new SendMessage() .setChatId("@test") .setText("Hithere") .setReplyToMessageId(12) .setParseMode(ParseMode.HTML) .setReplyMarkup(new ForceReplyKeyboard()) // After SendMessage .builder() .chatId("@test") .text("Hithere") .replyToMessageId(12) .parseMode(ParseMode.HTML) .replyMarkup(new ForceReplyKeyboard()) .build();Method doesn't accept chatId as Long anymore, only as a String. Use Long.toString(...) when needed I.e:
Long chatIdLong = message.getChatId(); SendMessage .builder() .chatId(Long.toString(chatIdLong)) .text("Hithere") .build();When registering a Webhook bot, provide the SetWebhook method object:
TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class, defaultWebhookInstance); telegramApi.registerBot(myWebhookBot, mySetWebhook);When using Spring with a webhook bot, make your bot inherit form SpringWebhookBot instead of WebhookBot and provide your SetWebhook method in the constructor:
// Extend correct class public class TestSpringWebhookBot extends SpringWebhookBot { public TestSpringWebhookBot(SetWebhook setWebhook) { super(setWebhook); } public TestSpringWebhookBot(DefaultBotOptions options, SetWebhook setWebhook) { super(options, setWebhook); } @Override public String getBotUsername() { return null; } @Override public String getBotToken() { return null; } @Override public BotApiMethod onWebhookUpdateReceived(Update update) { return null; } @Override public String getBotPath() { return null; } } // Create your SetWebhook method @Bean public SetWebhook setWebhookInstance() { return SetWebhook.builder()....build(); } // Create it as @Bean public TestSpringWebhookBot testSpringWebhookBot(SetWebhook setWebhookInstance) { return new TestSpringWebhookBot(setWebhookInstance); }Use InputFile to set files to upload instead of different setters, i.e:
// With a file SendDocument .builder() .chatId("123456") .document(new InputFile(new File("Filename.pdf"))) .build() // With a Stream SendDocument .builder() .chatId("123456") .document(new InputFile("FileName", new FileInputStream("Filename.pdf"))) .build()
To version 4.4.0.2
Logging framework has been replaced by slf4j, so now you'll need to manage your own implementation.
To version 4.0.0
Replace removed method from AbsSender with
execute
requests.Everything under "Telegrambots-meta" has been moved to package
org.telegram.telegrambots.meta
.close
method has been removed fromBotSession
, usestop
instead.All methods that are intended to upload files are using now
InputMedia
andInputFile
.
To version 2.4.3
Replace
BotOptions
byDefaultBotOptions
.At the beginning of your program (before creating your
TelegramBotsApi
orBot
instance, add the following line:ApiContextInitializer.init();In
SentCallback
, update parameter types ofonResult
andonError
. Inside those two method, you don't need to deserialize anything now, it comes already done.Deprecated (will be removed in next version):
org.telegram.telegrambots.bots.BotOptions
. Useorg.telegram.telegrambots.bots.DefaultBotOptions
instead.getPersonal
fromAnswerInlineQuery
. UseisPersonal
instead.FILEBASEURL
fromFile
. UsegetFileUrl
instead.
To version 2.4.4
Replace
ReplyKeyboardHide
byReplyKeyboardRemove
and its fieldhideKeyboard
byremoveKeyboard
(remember getter and setters)Replace usage of
edit_message
bydisable_edit_message
(see this post)Removed deprecated stuff from version 2.4.3
To version 2.4.4.3
Replace
BotSession.close()
byBotSession.stop()
.
To version 2.4.4.4
All calls to
editMessageText
,editMessageCaption
oreditMessageReplyMarkup
inAbsSender
return value is changed toSerializable
In
editMessageTextAsync
,editMessageCaptionAsync
oreditMessageReplyMarkupAsync
inAbsSender
, second parameter should becomeSentCallback<Serializable>
due to new return type.
To version 3.0
In
Message
object, fieldnew_chat_member
was replaced bynew_chat_members
that is now an array of users.
To version 3.0.2
If you were using
TelegramLongPollingCommandBot
, add the new extensions dependency to your maven and fix import statements in your project.If you were using
TelegramLongPollingCommandBot
, make sure you start using constructors with username and prevent overridinggetUsername
method.
To version 3.2
Replace usage of all deprecated methods from AbsSender with methods
execute
orexecuteAsync
.If you are extending AbsSender class, implement new added methods.