Closed neo7BF closed 2 years ago
the Id of the Chat object is an Integer (in telegram api defined as a 52-bit signed integer), which in java terms is type long. (See: https://core.telegram.org/bots/api#chat )
The reason setChatId takes a String is because you can pass in a username of a public channel. (See for example: https://core.telegram.org/bots/api#senddocument )
One could argue that setChatId should be overloaded to take both Longs and Strings, but in my opinion the additional work in the library (since it uses generated getters and setters) outweighs the benifit of not having to write toString()
Ok, thanks for the reply.
Hi, but the return type of getChatId() of class telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/Message.java should be String not Long.
In fact, in the examples here: https://github.com/rubenlagus/TelegramBotsExample/blob/master/src/main/java/org/telegram/updateshandlers/FilesHandlers.java is ever used in the form "... .setChatId(message.getChatId())" as if getChatId() returned a String, instead returns Long Why? Now I am forced to do: "... .setChatId(message.getChatId().toString())"