From 9efa79963de0a2425fbf787e734c4726fcc29e60 Mon Sep 17 00:00:00 2001 From: HarryZalessky Date: Sat, 6 May 2023 23:21:48 +0300 Subject: [PATCH] =?UTF-8?q?Changed=20API=20from=20bot-centered=20to=20meth?= =?UTF-8?q?od-centered=20=E2=80=A2=20Moved=20execute=20method=20from=20Tel?= =?UTF-8?q?egramBot=20to=20BaseRequest=20=E2=80=A2=20Moved=20DeleteMyComma?= =?UTF-8?q?nds.java=20from=20model=20to=20request=20=E2=80=A2=20Added=20Ba?= =?UTF-8?q?seRequest.api=20member=20for=20execute=20method=20=E2=80=A2=20A?= =?UTF-8?q?dded=20api=20argument=20to=20all=20constructors=20and=20static?= =?UTF-8?q?=20generator=20functions=20and=20passed=20them=20down=20to=20Ba?= =?UTF-8?q?seRequest.=20=E2=80=A2=20Added=20wrapper=20functions=20for=20al?= =?UTF-8?q?l=20requests=20in=20TelegramBot.=20=E2=80=A2=20Fixed=20tests=20?= =?UTF-8?q?to=20use=20new=20API.=20NOTE:=20LogOutCloseTest.java=20is=20inh?= =?UTF-8?q?erently=20broken=20and=20has=20to=20be=20fixed.=20=E2=80=A2=20D?= =?UTF-8?q?eprecated=20the=20entire=20SetStickerSetThumb=20class,=20instea?= =?UTF-8?q?d=20of=20one=20of=20the=20compilers.=20=E2=80=A2=20Fixed=20API?= =?UTF-8?q?=20usage=20in=20sample=20to=20match=20the=20new=20API.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pengrad/telegrambot/TelegramBot.java | 1828 ++++++++++++++++- .../telegrambot/impl/UpdatesHandler.java | 2 +- .../passport/EncryptedPassportElement.java | 2 +- .../passport/SetPassportDataErrors.java | 5 +- .../request/AbstractMultipartRequest.java | 6 +- .../request/AbstractSendRequest.java | 5 +- .../request/AbstractUploadRequest.java | 5 +- .../telegrambot/request/AddStickerToSet.java | 27 +- .../request/AnswerCallbackQuery.java | 5 +- .../request/AnswerInlineQuery.java | 5 +- .../request/AnswerPreCheckoutQuery.java | 9 +- .../request/AnswerShippingQuery.java | 9 +- .../request/AnswerWebAppQuery.java | 5 +- .../request/ApproveChatJoinRequest.java | 5 +- .../telegrambot/request/BanChatMember.java | 5 +- .../request/BanChatSenderChat.java | 5 +- .../telegrambot/request/BaseRequest.java | 15 +- .../pengrad/telegrambot/request/Close.java | 5 +- .../telegrambot/request/CloseForumTopic.java | 13 +- .../request/CloseGeneralForumTopic.java | 10 +- .../telegrambot/request/CopyMessage.java | 5 +- .../request/CreateChatInviteLink.java | 5 +- .../telegrambot/request/CreateForumTopic.java | 13 +- .../request/CreateInvoiceLink.java | 7 +- .../request/CreateNewStickerSet.java | 27 +- .../request/DeclineChatJoinRequest.java | 5 +- .../telegrambot/request/DeleteChatPhoto.java | 5 +- .../request/DeleteChatStickerSet.java | 5 +- .../telegrambot/request/DeleteForumTopic.java | 13 +- .../telegrambot/request/DeleteMessage.java | 5 +- .../{model => request}/DeleteMyCommands.java | 8 +- .../request/DeleteStickerFromSet.java | 5 +- .../telegrambot/request/DeleteStickerSet.java | 5 +- .../telegrambot/request/DeleteWebhook.java | 5 +- .../request/EditChatInviteLink.java | 5 +- .../telegrambot/request/EditForumTopic.java | 25 +- .../request/EditGeneralForumTopic.java | 9 +- .../request/EditMessageCaption.java | 9 +- .../request/EditMessageLiveLocation.java | 9 +- .../telegrambot/request/EditMessageMedia.java | 9 +- .../request/EditMessageReplyMarkup.java | 9 +- .../telegrambot/request/EditMessageText.java | 9 +- .../request/ExportChatInviteLink.java | 5 +- .../telegrambot/request/ForwardMessage.java | 5 +- .../pengrad/telegrambot/request/GetChat.java | 5 +- .../request/GetChatAdministrators.java | 5 +- .../telegrambot/request/GetChatMember.java | 5 +- .../request/GetChatMemberCount.java | 5 +- .../request/GetChatMembersCount.java | 5 +- .../request/GetChatMenuButton.java | 5 +- .../request/GetCustomEmojiStickers.java | 5 +- .../pengrad/telegrambot/request/GetFile.java | 5 +- .../request/GetForumTopicIconStickers.java | 5 +- .../request/GetGameHighScores.java | 9 +- .../pengrad/telegrambot/request/GetMe.java | 5 +- .../telegrambot/request/GetMyCommands.java | 5 +- .../GetMyDefaultAdministratorRights.java | 5 +- .../telegrambot/request/GetMyDescription.java | 5 +- .../telegrambot/request/GetMyName.java | 5 +- .../request/GetMyShortDescription.java | 5 +- .../telegrambot/request/GetStickerSet.java | 5 +- .../telegrambot/request/GetUpdates.java | 5 +- .../request/GetUserProfilePhotos.java | 5 +- .../telegrambot/request/GetWebhookInfo.java | 5 +- .../request/HideGeneralForumTopic.java | 9 +- .../telegrambot/request/KickChatMember.java | 5 +- .../telegrambot/request/LeaveChat.java | 5 +- .../pengrad/telegrambot/request/LogOut.java | 5 +- .../telegrambot/request/PinChatMessage.java | 5 +- .../request/PromoteChatMember.java | 5 +- .../telegrambot/request/ReopenForumTopic.java | 13 +- .../request/ReopenGeneralForumTopic.java | 9 +- .../request/RestrictChatMember.java | 5 +- .../request/RevokeChatInviteLink.java | 5 +- .../telegrambot/request/SendAnimation.java | 13 +- .../telegrambot/request/SendAudio.java | 13 +- .../telegrambot/request/SendChatAction.java | 9 +- .../telegrambot/request/SendContact.java | 6 +- .../pengrad/telegrambot/request/SendDice.java | 6 +- .../telegrambot/request/SendDocument.java | 13 +- .../pengrad/telegrambot/request/SendGame.java | 6 +- .../telegrambot/request/SendInvoice.java | 11 +- .../telegrambot/request/SendLocation.java | 6 +- .../telegrambot/request/SendMediaGroup.java | 5 +- .../telegrambot/request/SendMessage.java | 5 +- .../telegrambot/request/SendPhoto.java | 13 +- .../pengrad/telegrambot/request/SendPoll.java | 5 +- .../telegrambot/request/SendSticker.java | 14 +- .../telegrambot/request/SendVenue.java | 6 +- .../telegrambot/request/SendVideo.java | 13 +- .../telegrambot/request/SendVideoNote.java | 14 +- .../telegrambot/request/SendVoice.java | 13 +- .../SetChatAdministratorCustomTitle.java | 5 +- .../request/SetChatDescription.java | 5 +- .../request/SetChatMenuButton.java | 5 +- .../request/SetChatPermissions.java | 5 +- .../telegrambot/request/SetChatPhoto.java | 9 +- .../request/SetChatStickerSet.java | 5 +- .../telegrambot/request/SetChatTitle.java | 5 +- .../SetCustomEmojiStickerSetThumbnail.java | 5 +- .../telegrambot/request/SetGameScore.java | 9 +- .../telegrambot/request/SetMyCommands.java | 5 +- .../SetMyDefaultAdministratorRights.java | 5 +- .../telegrambot/request/SetMyDescription.java | 5 +- .../telegrambot/request/SetMyName.java | 5 +- .../request/SetMyShortDescription.java | 5 +- .../request/SetStickerEmojiList.java | 5 +- .../request/SetStickerKeywords.java | 5 +- .../request/SetStickerMaskPosition.java | 5 +- .../request/SetStickerPositionInSet.java | 5 +- .../request/SetStickerSetThumb.java | 15 +- .../request/SetStickerSetThumbnail.java | 9 +- .../request/SetStickerSetTitle.java | 5 +- .../telegrambot/request/SetWebhook.java | 5 +- .../request/StopMessageLiveLocation.java | 9 +- .../pengrad/telegrambot/request/StopPoll.java | 5 +- .../telegrambot/request/UnbanChatMember.java | 5 +- .../request/UnbanChatSenderChat.java | 5 +- .../request/UnhideGeneralForumTopic.java | 9 +- .../request/UnpinAllChatMessages.java | 5 +- .../request/UnpinAllForumTopicMessages.java | 13 +- .../telegrambot/request/UnpinChatMessage.java | 5 +- .../request/UploadStickerFile.java | 9 +- .../pengrad/telegrambot/LogOutCloseTest.java | 9 +- .../com/pengrad/telegrambot/PaymentsTest.java | 20 +- .../telegrambot/TelegramBotBuilderTest.java | 2 +- .../pengrad/telegrambot/TelegramBotTest.java | 647 +++--- .../telegrambot/sample/spark/AqivnBot.java | 4 +- .../telegrambot/sample/spark/KursBot.java | 2 +- .../telegrambot/sample/spark/Main.java | 2 +- 130 files changed, 2670 insertions(+), 732 deletions(-) rename library/src/main/java/com/pengrad/telegrambot/{model => request}/DeleteMyCommands.java (81%) diff --git a/library/src/main/java/com/pengrad/telegrambot/TelegramBot.java b/library/src/main/java/com/pengrad/telegrambot/TelegramBot.java index fbecdad8..d2bbcd1b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/TelegramBot.java +++ b/library/src/main/java/com/pengrad/telegrambot/TelegramBot.java @@ -1,13 +1,16 @@ package com.pengrad.telegrambot; import com.google.gson.Gson; + import com.pengrad.telegrambot.impl.FileApi; import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.impl.UpdatesHandler; -import com.pengrad.telegrambot.model.File; -import com.pengrad.telegrambot.request.BaseRequest; -import com.pengrad.telegrambot.request.GetUpdates; -import com.pengrad.telegrambot.response.BaseResponse; +import com.pengrad.telegrambot.model.*; +import com.pengrad.telegrambot.model.request.*; +import com.pengrad.telegrambot.passport.PassportElementError; +import com.pengrad.telegrambot.passport.SetPassportDataErrors; +import com.pengrad.telegrambot.request.*; + import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; @@ -40,14 +43,6 @@ public TelegramBot(String botToken) { this.updatesHandler = builder.updatesHandler; } - public , R extends BaseResponse> R execute(BaseRequest request) { - return api.send(request); - } - - public , R extends BaseResponse> void execute(T request, Callback callback) { - api.send(request, callback); - } - public String getToken() { return token; } @@ -64,8 +59,1813 @@ public byte[] getFileContent(File file) throws IOException { } } + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * @deprecated Use constructor with the InputSticker type (since API v6.6) + * @param userId User identifier of sticker set owner + * @param name Sticker set name + * @param emojis List of 1-20 emoji associated with the sticker + * @param tgsSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. Animated and video stickers can't be uploaded via HTTP URL. + * @return The newly created command + */ + @Deprecated + public AddStickerToSet addAnimatedStickerToSet(Long userId, String name, String emojis, Object tgsSticker) { + return AddStickerToSet.tgsSticker(api, userId, name, emojis, tgsSticker); + } + + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * @deprecated Use constructor with the InputSticker type (since API v6.6) + * @param userId User identifier of sticker set owner + * @param name Sticker set name + * @param emojis List of 1-20 emoji associated with the sticker + * @param pngSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. + * @return The newly created command + */ + @Deprecated + public AddStickerToSet addStaticStickerToSet(Long userId, String name, String emojis, Object pngSticker) { + return AddStickerToSet.tgsSticker(api, userId, name, emojis, pngSticker); + } + + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * @param userId User identifier of sticker set owner + * @param name Sticker set name + * @param sticker A {@link InputSticker InputSticker} object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed. + * @return The newly created command + */ + public AddStickerToSet addStickerToSet(Long userId, String name, InputSticker sticker) { + return new AddStickerToSet(api, userId, name, sticker); + } + + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * @deprecated Use static methods according to sticker set type - {@link #addAnimatedStickerToSet(Long, String, String, Object) for png}, {@link #addStaticStickerToSet(Long, String, String, Object) for tgs} and {@link #addVideoStickerToSet(Long, String, String, Object) for webm} + * @param userId User identifier of sticker set owner + * @param name Sticker set name + * @param pngSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. Animated and video stickers can't be uploaded via HTTP URL. + * @param emojis List of 1-20 emoji associated with the sticker + * @return The newly created command + */ + @Deprecated + public AddStickerToSet addStickerToSet(Long userId, String name, Object pngSticker, String emojis) { + return new AddStickerToSet(api, userId, name, pngSticker, emojis); + } + + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * @deprecated Use constructor with the InputSticker type (since API v6.6) + * @param userId User identifier of sticker set owner + * @param name Sticker set name + * @param emojis List of 1-20 emoji associated with the sticker + * @param webmSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. Animated and video stickers can't be uploaded via HTTP URL. + * @return The newly created command + */ + @Deprecated + public AddStickerToSet addVideoStickerToSet(Long userId, String name, String emojis, Object webmSticker) { + return AddStickerToSet.tgsSticker(api, userId, name, emojis, webmSticker); + } + + /** + * Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + * @param callbackQueryId Unique identifier for the query to be answered + * @return The newly created command + */ + public AnswerCallbackQuery answerCallbackQuery(String callbackQueryId) { + return new AnswerCallbackQuery(api, callbackQueryId); + } + + /** + * Use this method to send answers to an inline query. On success, True is returned. + * No more than 50 results per query are allowed. + * @param inlineQueryId Unique identifier for the answered query + * @param results A list of results for the inline query + * @return The newly created command + */ + public AnswerInlineQuery answerInlineQuery(String inlineQueryId, InlineQueryResult... results) { + return new AnswerInlineQuery(api, inlineQueryId, results); + } + + /** + * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an {@link com.pengrad.telegrambot.model.Update Update} with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * @param preCheckoutQueryId Unique identifier for the query to be answered + * @return The newly created command + */ + public AnswerPreCheckoutQuery answerPreCheckoutQuery(String preCheckoutQueryId) { + return new AnswerPreCheckoutQuery(api, preCheckoutQueryId); + } + + /** + * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an {@link com.pengrad.telegrambot.model.Update Update} with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * @param preCheckoutQueryId Unique identifier for the query to be answered + * @param errorMessage Error message in human-readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. + * @return The newly created command + */ + public AnswerPreCheckoutQuery answerPreCheckoutQuery(String preCheckoutQueryId, String errorMessage) { + return new AnswerPreCheckoutQuery(api, preCheckoutQueryId, errorMessage); + } + + /** + * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an {@link com.pengrad.telegrambot.model.Update Update} with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * @param shippingQueryId Unique identifier for the query to be answered + * @param shippingOptions A list of available shipping options. + * @return The newly created command + */ + public AnswerShippingQuery answerShippingQuery(String shippingQueryId, ShippingOption... shippingOptions) { + return new AnswerShippingQuery(api, shippingQueryId, shippingOptions); + } + + /** + * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an {@link com.pengrad.telegrambot.model.Update Update} with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * @param shippingQueryId Unique identifier for the query to be answered + * @param errorMessage Error message in human-readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable"). Telegram will display this message to the user. + * @return The newly created command + */ + public AnswerShippingQuery answerShippingQuery(String shippingQueryId, String errorMessage) { + return new AnswerShippingQuery(api, shippingQueryId, errorMessage); + } + + /** + * Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a {@link com.pengrad.telegrambot.model.SentWebAppMessage SentWebAppMessage} object is returned. + * @param web_app_query_id Unique identifier for the query to be answered + * @param result An {@link InlineQueryResult InlineQueryResult} object describing the message to be sent + * @return The newly created command + */ + public AnswerWebAppQuery answerWebAppQuery(String web_app_query_id, InlineQueryResult result) { + return new AnswerWebAppQuery(api, web_app_query_id, result); + } + + /** + * Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canInviteUsers can_invite_users} administrator right. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public ApproveChatJoinRequest approveChatJoinRequest(Object chatId, long userId) { + return new ApproveChatJoinRequest(api, chatId, userId); + } + + /** + * Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless {@link UnbanChatMember unbanned} first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public BanChatMember banChatMember(Object chatId, long userId) { + return new BanChatMember(api, chatId, userId); + } + + /** + * Use this method to ban a channel chat in a supergroup or a channel. Until the chat is {@link UnbanChatMember unbanned}, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param sender_chat_id Unique identifier of the target sender chat + * @return The newly created command + */ + public BanChatSenderChat banChatSenderChat(Object chatId, long sender_chat_id) { + return new BanChatSenderChat(api, chatId, sender_chat_id); + } + + /** + * Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. + * @return The newly created command + */ + public Close close() { + return new Close(api); + } + + /** + * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + @Deprecated + public CloseForumTopic closeForumTopic(Integer chatId, Integer messageThreadId) { + return new CloseForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public CloseForumTopic closeForumTopic(Long chatId, Integer messageThreadId) { + return new CloseForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public CloseForumTopic closeForumTopic(String chatId, Integer messageThreadId) { + return new CloseForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public CloseGeneralForumTopic closeGeneralForumTopic(Long chatId) { + return new CloseGeneralForumTopic(api, chatId); + } + + /** + * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public CloseGeneralForumTopic closeGeneralForumTopic(String chatId) { + return new CloseGeneralForumTopic(api, chatId); + } + + /** + * Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. A quiz poll can be copied only if the value of the field {@link com.pengrad.telegrambot.model.Poll#correct_option_id correct_option_id} is known to the bot. The method is analogous to the method {@link ForwardMessage forwardMessage}, but the copied message doesn't have a link to the original message. Returns the {@link MessageId} of the sent message on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channel_username) + * @param messageId Message identifier in the chat specified in from_chat_id + * @return The newly created command + */ + public CopyMessage copyMessage(Object chatId, Object fromChatId, int messageId) { + return new CopyMessage(api, chatId, fromChatId, messageId); + } + + /** + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method {@link #revokeChatInviteLink}. Returns the new invite link as {@link ChatInviteLink} object. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public CreateChatInviteLink createChatInviteLink(Object chatId) { + return new CreateChatInviteLink(api, chatId); + } + + /** + * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns information about the created topic as a {@link ForumTopic} object. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param name Topic name, 1-128 characters + * @return The newly created command + */ + @Deprecated + public CreateForumTopic createForumTopic(Integer chatId, String name) { + return new CreateForumTopic(api, chatId, name); + } + + /** + * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns information about the created topic as a {@link ForumTopic} object. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param name Topic name, 1-128 characters + * @return The newly created command + */ + public CreateForumTopic createForumTopic(Long chatId, String name) { + return new CreateForumTopic(api, chatId, name); + } + + /** + * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns information about the created topic as a {@link ForumTopic} object. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param name Topic name, 1-128 characters + * @return The newly created command + */ + public CreateForumTopic createForumTopic(String chatId, String name) { + return new CreateForumTopic(api, chatId, name); + } + + /** + * Use this method to create a link for an invoice. Returns the created invoice link as String on success. + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param providerToken Payment provider token, obtained via @BotFather + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @return The newly created command + */ + public CreateInvoiceLink createInvoiceLink(String title, String description, String payload, String providerToken, String currency, LabeledPrice... prices) { + return new CreateInvoiceLink(api, title, description, payload, providerToken, currency, prices); + } + + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * @param userId User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_bot_username". bot_username is case-insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param emojis List of 1-20 emoji associated with the sticker + * @param tgsSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. Animated and video stickers can't be uploaded via HTTP URL. + * @return The newly created command + */ + @Deprecated + public CreateNewStickerSet createNewAnimatedStickerSet(Long userId, String name, String title, String emojis, Object tgsSticker) { + return CreateNewStickerSet.tgsSticker(api, userId, name, title, emojis, tgsSticker); + } + + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * @param userId User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_bot_username". bot_username is case-insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param emojis List of 1-20 emoji associated with the sticker + * @param pngSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. + * @return The newly created command + */ + @Deprecated + public CreateNewStickerSet createNewStaticStickerSet(Long userId, String name, String title, String emojis, Object pngSticker) { + return CreateNewStickerSet.pngSticker(api, userId, name, title, emojis, pngSticker); + } + + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * @param userId User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_bot_username". bot_username is case-insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param stickers A list of 1-50 initial stickers to be added to the sticker set + * @param stickerFormat Format of stickers in the set, must be one of “static”, “animated”, “video” + * @return The newly created command + */ + public CreateNewStickerSet createNewStickerSet(Long userId, String name, String title, InputSticker[] stickers, Sticker.Format stickerFormat) { + return new CreateNewStickerSet(api, userId, name, title, stickers, stickerFormat); + } + + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * @param userId User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_bot_username". bot_username is case-insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param pngSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. + * @param emojis List of 1-20 emoji associated with the sticker + * @return The newly created command + */ + @Deprecated + public CreateNewStickerSet createNewStickerSet(Long userId, String name, String title, Object pngSticker, String emojis) { + return new CreateNewStickerSet(api, userId, name, title, pngSticker, emojis); + } + + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * @param userId User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_bot_username". bot_username is case-insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param emojis List of 1-20 emoji associated with the sticker + * @param webmSticker The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, upload a new one using multipart/form-data, or pass “attach://file_attach_name” to upload a new one using multipart/form-data under file_attach_name name. Animated and video stickers can't be uploaded via HTTP URL. + * @return The newly created command + */ + @Deprecated + public CreateNewStickerSet createNewVideoStickerSet(Long userId, String name, String title, String emojis, Object webmSticker) { + return CreateNewStickerSet.webmSticker(api, userId, name, title, emojis, webmSticker); + } + + /** + * Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canInviteUsers can_invite_users} administrator right. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public DeclineChatJoinRequest declineChatJoinRequest(Object chatId, long userId) { + return new DeclineChatJoinRequest(api, chatId, userId); + } + + /** + * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public DeleteChatPhoto deleteChatPhoto(Object chatId) { + return new DeleteChatPhoto(api, chatId); + } + + /** + * Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field {@link Chat#canSetStickerSet() can_set_sticker_set } optionally returned in {@link #getChat} requests to check if the bot can use this method. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public DeleteChatStickerSet deleteChatStickerSet(Object chatId) { + return new DeleteChatStickerSet(api, chatId); + } + + /** + * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canDeleteMessages can_delete_messages} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + @Deprecated + public DeleteForumTopic deleteForumTopic(Integer chatId, Integer messageThreadId) { + return new DeleteForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canDeleteMessages can_delete_messages} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public DeleteForumTopic deleteForumTopic(Long chatId, Integer messageThreadId) { + return new DeleteForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canDeleteMessages can_delete_messages} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public DeleteForumTopic deleteForumTopic(String chatId, Integer messageThreadId) { + return new DeleteForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to delete a message, including service messages, with the following limitations:
+ * - A message can only be deleted if it was sent less than 48 hours ago.
+ * - Service messages about a supergroup, channel, or forum topic creation can't be deleted.
+ * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
+ * - Bots can delete outgoing messages in private chats, groups, and supergroups.
+ * - Bots can delete incoming messages in private chats.
+ * - Bots granted {@link PromoteChatMember#canPostMessages can_post_messages} permissions can delete outgoing messages in channels.
+ * - If the bot is an administrator of a group, it can delete any message there.
+ * - If the bot has {@link PromoteChatMember#canDeleteMessages can_delete_messages} permission in a supergroup or a channel, it can delete any message there.
+ * Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to delete + * @return The newly created command + */ + public DeleteMessage deleteMessage(Object chatId, int messageId) { + return new DeleteMessage(api, chatId, messageId); + } + + /** + * Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. + * @return The newly created command + */ + public DeleteMyCommands deleteMyCommands() { + return new DeleteMyCommands(api); + } + + /** + * Use this method to delete a sticker from a set created by the bot. Returns True on success. + * @param sticker File identifier of the sticker + * @return The newly created command + */ + public DeleteStickerFromSet deleteStickerFromSet(String sticker) { + return new DeleteStickerFromSet(api, sticker); + } + + /** + * Use this method to delete a sticker set that was created by the bot. Returns True on success. + * @param name Sticker set name + * @return The newly created command + */ + public DeleteStickerSet deleteStickerSet(String name) { + return new DeleteStickerSet(api, name); + } + + /** + * Use this method to remove webhook integration if you decide to switch back to {@link #getUpdates}. Returns True on success. + * @return The newly created command + */ + public DeleteWebhook deleteWebhook() { + return new DeleteWebhook(api); + } + + /** + * Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a {@link ChatInviteLink} object. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param inviteLink The invite link to edit + * @return The newly created command + */ + public EditChatInviteLink editChatInviteLink(Object chatId, String inviteLink) { + return new EditChatInviteLink(api, chatId, inviteLink); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + @Deprecated + public EditForumTopic editForumTopic(Integer chatId, Integer messageThreadId) { + return new EditForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public EditForumTopic editForumTopic(Long chatId, Integer messageThreadId) { + return new EditForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public EditForumTopic editForumTopic(String chatId, Integer messageThreadId) { + return new EditForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @param name Topic name, 1-128 characters + * @param iconCustomEmojiId Unique identifier of the custom emoji shown as the topic icon. Use {@link #getForumTopicIconStickers} to get all allowed custom emoji identifiers. + * @return The newly created command + */ + @Deprecated + public EditForumTopic editForumTopic(Integer chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + return new EditForumTopic(api, chatId, messageThreadId, name, iconCustomEmojiId); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @param name Topic name, 1-128 characters + * @param iconCustomEmojiId Unique identifier of the custom emoji shown as the topic icon. Use {@link #getForumTopicIconStickers} to get all allowed custom emoji identifiers. + * @return The newly created command + */ + public EditForumTopic editForumTopic(Long chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + return new EditForumTopic(api, chatId, messageThreadId, name, iconCustomEmojiId); + } + + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @param name Topic name, 1-128 characters + * @param iconCustomEmojiId Unique identifier of the custom emoji shown as the topic icon. Use {@link #getForumTopicIconStickers} to get all allowed custom emoji identifiers. + * @return The newly created command + */ + public EditForumTopic editForumTopic(String chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + return new EditForumTopic(api, chatId, messageThreadId, name, iconCustomEmojiId); + } + + /** + * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param name New topic name, 1-128 characters + * @return The newly created command + */ + public EditGeneralForumTopic editGeneralForumTopic(Long chatId, String name) { + return new EditGeneralForumTopic(api, chatId, name); + } + + /** + * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param name New topic name, 1-128 characters + * @return The newly created command + */ + public EditGeneralForumTopic editGeneralForumTopic(String chatId, String name) { + return new EditGeneralForumTopic(api, chatId, name); + } + + /** + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to edit + * @return The newly created command + */ + public EditMessageCaption editMessageCaption(Object chatId, int messageId) { + return new EditMessageCaption(api, chatId, messageId); + } + + /** + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @return The newly created command + */ + public EditMessageCaption editMessageCaption(String inlineMessageId) { + return new EditMessageCaption(api, inlineMessageId); + } + + /** + * Use this method to edit live location messages. A location can be edited until its {@link Location#livePeriod live_period} expires or editing is explicitly disabled by a call to {@link #stopMessageLiveLocation}. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to edit + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @return The newly created command + */ + public EditMessageLiveLocation editMessageLiveLocation(Object chatId, int messageId, float latitude, float longitude) { + return new EditMessageLiveLocation(api, chatId, messageId, latitude, longitude); + } + + /** + * Use this method to edit live location messages. A location can be edited until its {@link Location#livePeriod live_period} expires or editing is explicitly disabled by a call to {@link #stopMessageLiveLocation}. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @return The newly created command + */ + public EditMessageLiveLocation editMessageLiveLocation(String inlineMessageId, float latitude, float longitude) { + return new EditMessageLiveLocation(api, inlineMessageId, latitude, longitude); + } + + /** + * Use this method to edit {@link InputMediaAnimation animation}, {@link InputMediaAudio audio}, {@link InputMediaDocument document}, {@link InputMediaPhoto photo}, or {@link InputMediaVideo video} messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to edit + * @param media An object for a new media content of the message + * @return The newly created command + */ + public EditMessageMedia editMessageMedia(Object chatId, int messageId, InputMedia media) { + return new EditMessageMedia(api, chatId, messageId, media); + } + + /** + * Use this method to edit {@link InputMediaAnimation animation}, {@link InputMediaAudio audio}, {@link InputMediaDocument document}, {@link InputMediaPhoto photo}, or {@link InputMediaVideo video} messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @param media An object for a new media content of the message + * @return The newly created command + */ + public EditMessageMedia editMessageMedia(String inlineMessageId, InputMedia media) { + return new EditMessageMedia(api, inlineMessageId, media); + } + + /** + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to edit + * @return The newly created command + */ + public EditMessageReplyMarkup editMessageReplyMarkup(Object chatId, int messageId) { + return new EditMessageReplyMarkup(api, chatId, messageId); + } + + /** + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @return The newly created command + */ + public EditMessageReplyMarkup editMessageReplyMarkup(String inlineMessageId) { + return new EditMessageReplyMarkup(api, inlineMessageId); + } + + /** + * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message to edit + * @param text New text of the message, 1-4096 characters after entities parsing + * @return The newly created command + */ + public EditMessageText editMessageText(Object chatId, int messageId, String text) { + return new EditMessageText(api, chatId, messageId, text); + } + + /** + * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @param text New text of the message, 1-4096 characters after entities parsing + * @return The newly created command + */ + public EditMessageText editMessageText(String inlineMessageId, String text) { + return new EditMessageText(api, inlineMessageId, text); + } + + /** + * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public ExportChatInviteLink exportChatInviteLink(Object chatId) { + return new ExportChatInviteLink(api, chatId); + } + + /** + * Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channel_username) + * @param messageId Message identifier in the chat specified in from_chat_id + * @return The newly created command + */ + public ForwardMessage forwardMessage(Object chatId, Object fromChatId, int messageId) { + return new ForwardMessage(api, chatId, fromChatId, messageId); + } + + /** + * Use this method to get up-to-date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a {@link Chat} object on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel_username) + * @return The newly created command + */ + public GetChat getChat(Object chatId) { + return new GetChat(api, chatId); + } + + /** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of {@link ChatMember} objects. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel_username) + * @return The newly created command + */ + public GetChatAdministrators getChatAdministrators(Object chatId) { + return new GetChatAdministrators(api, chatId); + } + + /** + * Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a {@link ChatMember} object on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel|_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public GetChatMember getChatMember(Object chatId, long userId) { + return new GetChatMember(api, chatId, userId); + } + + /** + * Use this method to get the number of members in a chat. Returns int on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel_username) + * @return The newly created command + */ + public GetChatMemberCount getChatMemberCount(Object chatId) { + return new GetChatMemberCount(api, chatId); + } + + /** + * Use this method to get the number of members in a chat. Returns int on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel_username) + * @return The newly created command + */ + @Deprecated + public GetChatMembersCount getChatMembersCount(Object chatId) { + return new GetChatMembersCount(api, chatId); + } + + /** + * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns {@link MenuButton} on success. + * @return The newly created command + */ + public GetChatMenuButton getChatMenuButton() { + return new GetChatMenuButton(api); + } + + /** + * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of {@link Sticker} objects. + * @param customEmojiIds List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. + * @return The newly created command + */ + public GetCustomEmojiStickers getCustomEmojiStickers(String... customEmojiIds) { + return new GetCustomEmojiStickers(api, customEmojiIds); + } + + /** + * Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a {@link File} object is returned. The file can then be downloaded via the link {@code https://api.telegram.org/file/bot{token}/file_path}, where file_path is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling {@code getFile} again. + * @param fileId File identifier to get information about + * @return The newly created command + */ + public GetFile getFile(String fileId) { + return new GetFile(api, fileId); + } + + /** + * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of {@link Sticker} objects. + * @return The newly created command + */ + public GetForumTopicIconStickers getForumTopicIconStickers() { + return new GetForumTopicIconStickers(api); + } + + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. + *

+ * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change. + * @param userId Target user id + * @param inlineMessageId Identifier of the inline message + * @return The newly created command + */ + public GetGameHighScores getGameHighScores(long userId, String inlineMessageId) { + return new GetGameHighScores(api, userId, inlineMessageId); + } + + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. + *

+ * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change. + * @param userId Target user id + * @param chatId Unique identifier for the target chat + * @param messageId Identifier of the sent message + * @return The newly created command + */ + public GetGameHighScores getGameHighScores(long userId, Object chatId, int messageId) { + return new GetGameHighScores(api, userId, chatId, messageId); + } + + /** + * A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a {@link User} object. + * @return The newly created command + */ + public GetMe getMe() { + return new GetMe(api); + } + + /** + * Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of {@link BotCommand} objects. If commands aren't set, an empty list is returned. + * @return The newly created command + */ + public GetMyCommands getMyCommands() { + return new GetMyCommands(api); + } + + /** + * Use this method to get the current default administrator rights of the bot. Returns {@link ChatAdministratorRights} on success. + * @return The newly created command + */ + public GetMyDefaultAdministratorRights getMyDefaultAdministratorRights() { + return new GetMyDefaultAdministratorRights(api); + } + + /** + * Use this method to get the current bot description for the given user language. Returns {@link BotDescription} on success. + * @return The newly created command + */ + public GetMyDescription getMyDescription() { + return new GetMyDescription(api); + } + + /** + * Use this method to get the current bot name for the given user language. Returns {@link BotName} on success. + * @return The newly created command + */ + public GetMyName getMyName() { + return new GetMyName(api); + } + + /** + * Use this method to get the current bot short description for the given user language. Returns {@link BotShortDescription} on success. + * @return The newly created command + */ + public GetMyShortDescription getMyShortDescription() { + return new GetMyShortDescription(api); + } + + /** + * Use this method to get a sticker set. On success, a {@link StickerSet} object is returned. + * @param name Name of the sticker set + * @return The newly created command + */ + public GetStickerSet getStickerSet(String name) { + return new GetStickerSet(api, name); + } + + /** + * Use this method to receive incoming updates using long polling (wiki). Returns an Array of {@link Update} objects. + * @return The newly created command + */ + public GetUpdates getUpdates() { + return new GetUpdates(api); + } + + /** + * Use this method to get a list of profile pictures for a user. Returns a {@link UserProfilePhotos} object. + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public GetUserProfilePhotos getUserProfilePhotos(long userId) { + return new GetUserProfilePhotos(api, userId); + } + + /** + * Use this method to get current webhook status. Requires no parameters. On success, returns a {@link WebhookInfo} object. If the bot is using {@link #getUpdates}, will return an object with the url field empty. + * @return The newly created command + */ + public GetWebhookInfo getWebhookInfo() { + return new GetWebhookInfo(api); + } + + /** + * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public HideGeneralForumTopic hideGeneralForumTopic(Long chatId) { + return new HideGeneralForumTopic(api, chatId); + } + + /** + * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public HideGeneralForumTopic hideGeneralForumTopic(String chatId) { + return new HideGeneralForumTopic(api, chatId); + } + + /** + * Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless {@link UnbanChatMember unbanned} first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @deprecated since BOT API v5.3 you should use {@link #banChatMember} instead. + * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + @Deprecated + public KickChatMember kickChatMember(Object chatId, Long userId) { + return new KickChatMember(api, chatId, userId); + } + + /** + * Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channel_username) + * @return The newly created command + */ + public LeaveChat leaveChat(Object chatId) { + return new LeaveChat(api, chatId); + } + + /** + * Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters. + * @return The newly created command + */ + public LogOut logOut() { + return new LogOut(api); + } + + /** + * Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in a supergroup or {@link PromoteChatMember#canEditMessages can_edit_messages} administrator right in a channel. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of a message to pin + * @return The newly created command + */ + public PinChatMessage pinChatMessage(Object chatId, int messageId) { + return new PinChatMessage(api, chatId, messageId); + } + + /** + * Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public PromoteChatMember promoteChatMember(Object chatId, long userId) { + return new PromoteChatMember(api, chatId, userId); + } + + /** + * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + @Deprecated + public ReopenForumTopic reopenForumTopic(Integer chatId, Integer messageThreadId) { + return new ReopenForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public ReopenForumTopic reopenForumTopic(Long chatId, Integer messageThreadId) { + return new ReopenForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights, unless it is the creator of the topic. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public ReopenForumTopic reopenForumTopic(String chatId, Integer messageThreadId) { + return new ReopenForumTopic(api, chatId, messageThreadId); + } + + /** + * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public ReopenGeneralForumTopic reopenGeneralForumTopic(Long chatId) { + return new ReopenGeneralForumTopic(api, chatId); + } + + /** + * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public ReopenGeneralForumTopic reopenGeneralForumTopic(String chatId) { + return new ReopenGeneralForumTopic(api, chatId); + } + + /** + * Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param userId Unique identifier of the target user + * @param permissions An object for new user permissions + * @return The newly created command + */ + public RestrictChatMember restrictChatMember(Object chatId, long userId, ChatPermissions permissions) { + return new RestrictChatMember(api, chatId, userId, permissions); + } + + /** + * Use this method to revoke an invite_link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as {@link ChatInviteLink} object. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param inviteLink The invite link to edit + * @return The newly created command + */ + public RevokeChatInviteLink revokeChatInviteLink(Object chatId, String inviteLink) { + return new RevokeChatInviteLink(api, chatId, inviteLink); + } + + /** + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent {@link Message} is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get an animation from the Internet. + * @return The newly created command + */ + public SendAnimation sendAnimation(Object chatId, String animation) { + return new SendAnimation(api, chatId, animation); + } + + /** + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent {@link Message} is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param animation Animation to send. Upload a new animation using multipart/form-data. + * @return The newly created command + */ + public SendAnimation sendAnimation(Object chatId, java.io.File animation) { + return new SendAnimation(api, chatId, animation); + } + + /** + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent {@link Message} is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param animation Animation to send. Upload a new animation using multipart/form-data. + * @return The newly created command + */ + public SendAnimation sendAnimation(Object chatId, byte[] animation) { + return new SendAnimation(api, chatId, animation); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent {@link Message} is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + *

+ * For sending voice messages, use the {@link SendVoice} method instead. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get an audio file from the Internet. + * @return The newly created command + */ + public SendAudio sendAudio(Object chatId, String audio) { + return new SendAudio(api, chatId, audio); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent {@link Message} is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + *

+ * For sending voice messages, use the {@link SendVoice} method instead. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param audio Audio file to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendAudio sendAudio(Object chatId, java.io.File audio) { + return new SendAudio(api, chatId, audio); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent {@link Message} is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + *

+ * For sending voice messages, use the {@link SendVoice} method instead. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param audio Audio file to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendAudio sendAudio(Object chatId, byte[] audio) { + return new SendAudio(api, chatId, audio); + } + + /** + * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + *

+ * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for {@link SendMessage text messages}, upload_photo for {@link SendPhoto photos}, record_video or upload_video for {@link SendVideo videos}, record_voice or upload_voice for {@link SendVoice voice notes}, upload_document for {@link SendDocument general files}, choose_sticker for {@link SendSticker stickers}, find_location for {@link SendLocation location data}, record_video_note or upload_video_note for {@link SendVideoNote video notes}. + * @return The newly created command + */ + public SendChatAction sendChatAction(Object chatId, String action) { + return new SendChatAction(api, chatId, action); + } + + /** + * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + *

+ * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for {@link SendMessage text messages}, upload_photo for {@link SendPhoto photos}, record_video or upload_video for {@link SendVideo videos}, record_voice or upload_voice for {@link SendVoice voice notes}, upload_document for {@link SendDocument general files}, choose_sticker for {@link SendSticker stickers}, find_location for {@link SendLocation location data}, record_video_note or upload_video_note for {@link SendVideoNote video notes}. + * @return The newly created command + */ + public SendChatAction sendChatAction(Object chatId, ChatAction action) { + return new SendChatAction(api, chatId, action); + } + + /** + * Use this method to send phone contacts. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param phoneNumber Contact's phone number + * @param firstName Contact's first name + * @return The newly created command + */ + public SendContact sendContact(Object chatId, String phoneNumber, String firstName) { + return new SendContact(api, chatId, phoneNumber, firstName); + } + + /** + * Use this method to send an animated emoji that will display a random value. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public SendDice sendDice(Object chatId) { + return new SendDice(api, chatId); + } + + /** + * Use this method to send general files. On success, the sent {@link Message} is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a file from the Internet. + * @return The newly created command + */ + public SendDocument sendDocument(Object chatId, String document) { + return new SendDocument(api, chatId, document); + } + + /** + * Use this method to send general files. On success, the sent {@link Message} is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param document File to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendDocument sendDocument(Object chatId, java.io.File document) { + return new SendDocument(api, chatId, document); + } + + /** + * Use this method to send general files. On success, the sent {@link Message} is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param document File to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendDocument sendDocument(Object chatId, byte[] document) { + return new SendDocument(api, chatId, document); + } + + /** + * Use this method to send a game. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat + * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather. + * @return The newly created command + */ + public SendGame sendGame(Object chatId, String gameShortName) { + return new SendGame(api, chatId, gameShortName); + } + + /** + * Use this method to send invoices. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param providerToken Payment provider token, obtained via @BotFather + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @return The newly created command + */ + public SendInvoice sendInvoice(Long chatId, String title, String description, String payload, String providerToken, String currency, LabeledPrice... prices) { + return new SendInvoice(api, chatId, title, description, payload, providerToken, currency, prices); + } + + /** + * Use this method to send invoices. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param providerToken Payment provider token, obtained via @BotFather + * @param startParameter Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @return The newly created command + */ + public SendInvoice sendInvoice(Long chatId, String title, String description, String payload, String providerToken, String startParameter, String currency, LabeledPrice... prices) { + return new SendInvoice(api, chatId, title, description, payload, providerToken, startParameter, currency, prices); + } + + /** + * Use this method to send point on the map. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param latitude Latitude of the location + * @param longitude Longitude of the location + * @return The newly created command + */ + public SendLocation sendLocation(Object chatId, float latitude, float longitude) { + return new SendLocation(api, chatId, latitude, longitude); + } + + /** + * Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of {@link Message Messages} that were sent is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param media An array describing messages to be sent, must include 2-10 items + * @return The newly created command + */ + public SendMediaGroup sendMediaGroup(Object chatId, InputMedia... media) { + return new SendMediaGroup(api, chatId, media); + } + + /** + * Use this method to send text messages. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @return The newly created command + */ + public SendMessage sendMessage(Object chatId, String text) { + return new SendMessage(api, chatId, text); + } + + /** + * Use this method to send photos. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a photo from the Internet. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @return The newly created command + */ + public SendPhoto sendPhoto(Object chatId, String photo) { + return new SendPhoto(api, chatId, photo); + } + + /** + * Use this method to send photos. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param photo Photo to send. Upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @return The newly created command + */ + public SendPhoto sendPhoto(Object chatId, java.io.File photo) { + return new SendPhoto(api, chatId, photo); + } + + /** + * Use this method to send photos. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param photo Photo to send. Upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @return The newly created command + */ + public SendPhoto sendPhoto(Object chatId, byte[] photo) { + return new SendPhoto(api, chatId, photo); + } + + /** + * Use this method to send a native poll. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param question Poll question, 1-300 characters + * @param options A list of answer options, 2-10 strings 1-100 characters each + * @return The newly created command + */ + public SendPoll sendPoll(Object chatId, String question, String... options) { + return new SendPoll(api, chatId, question, options); + } + + /** + * Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet. Video stickers can only be sent by a file_id. Animated stickers can't be sent via an HTTP URL. + * @return The newly created command + */ + public SendSticker sendSticker(Object chatId, String sticker) { + return new SendSticker(api, chatId, sticker); + } + + /** + * Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param sticker Sticker to send. Upload a new .WEBP or .TGS sticker using multipart/form-data. Video stickers can only be sent by a file_id. Animated stickers can't be sent via an HTTP URL. + * @return The newly created command + */ + public SendSticker sendSticker(Object chatId, java.io.File sticker) { + return new SendSticker(api, chatId, sticker); + } + + /** + * Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param sticker Sticker to send. Upload a new .WEBP or .TGS sticker using multipart/form-data. Video stickers can only be sent by a file_id. Animated stickers can't be sent via an HTTP URL. + * @return The newly created command + */ + public SendSticker sendSticker(Object chatId, byte[] sticker) { + return new SendSticker(api, chatId, sticker); + } + + /** + * Use this method to send information about a venue. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param latitude Latitude of the venue + * @param longitude Longitude of the venue + * @param title Name of the venue + * @param address Address of the venue + * @return The newly created command + */ + public SendVenue sendVenue(Object chatId, float latitude, float longitude, String title, String address) { + return new SendVenue(api, chatId, latitude, longitude, title, address); + } + + /** + * Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a video from the Internet. + * @return The newly created command + */ + public SendVideo sendVideo(Object chatId, String video) { + return new SendVideo(api, chatId, video); + } + + /** + * Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param video Video to send. Upload a new video using multipart/form-data. + * @return The newly created command + */ + public SendVideo sendVideo(Object chatId, java.io.File video) { + return new SendVideo(api, chatId, video); + } + + /** + * Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param video Video to send. Upload a new video using multipart/form-data. + * @return The newly created command + */ + public SendVideo sendVideo(Object chatId, byte[] video) { + return new SendVideo(api, chatId, video); + } + + /** + * As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param videoNote Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended). Sending video notes by a URL is currently unsupported. + * @return The newly created command + */ + public SendVideoNote sendVideoNote(Object chatId, String videoNote) { + return new SendVideoNote(api, chatId, videoNote); + } + + /** + * As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param videoNote Video note to send. Upload a new video using multipart/form-data. + * @return The newly created command + */ + public SendVideoNote sendVideoNote(Object chatId, java.io.File videoNote) { + return new SendVideoNote(api, chatId, videoNote); + } + + /** + * As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent {@link Message} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param videoNote Video note to send. Upload a new video using multipart/form-data. + * @return The newly created command + */ + public SendVideoNote sendVideoNote(Object chatId, byte[] videoNote) { + return new SendVideoNote(api, chatId, videoNote); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as {@link Audio} or {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a file from the Internet. + * @return The newly created command + */ + public SendVoice sendVoice(Object chatId, String voice) { + return new SendVoice(api, chatId, voice); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as {@link Audio} or {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param voice Audio file to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendVoice sendVoice(Object chatId, java.io.File voice) { + return new SendVoice(api, chatId, voice); + } + + /** + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as {@link Audio} or {@link Document}). On success, the sent {@link Message} is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param voice Audio file to send. Upload a new one using multipart/form-data. + * @return The newly created command + */ + public SendVoice sendVoice(Object chatId, byte[] voice) { + return new SendVoice(api, chatId, voice); + } + + /** + * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param userId Unique identifier of the target user + * @param customTitle New custom title for the administrator; 0-16 characters, emoji are not allowed + * @return The newly created command + */ + public SetChatAdministratorCustomTitle setChatAdministratorCustomTitle(Object chatId, long userId, String customTitle) { + return new SetChatAdministratorCustomTitle(api, chatId, userId, customTitle); + } + + /** + * Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param description New chat description, 0-255 characters + * @return The newly created command + */ + public SetChatDescription setChatDescription(Object chatId, String description) { + return new SetChatDescription(api, chatId, description); + } + + /** + * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. + * @return The newly created command + */ + public SetChatMenuButton setChatMenuButton() { + return new SetChatMenuButton(api); + } + + /** + * Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the {@link PromoteChatMember#canRestrictMembers can_restrict_members} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param permissions An object for new default chat permissions + * @return The newly created command + */ + public SetChatPermissions setChatPermissions(Object chatId, ChatPermissions permissions) { + return new SetChatPermissions(api, chatId, permissions); + } + + /** + * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param photo New chat photo, uploaded using multipart/form-data + * @return The newly created command + */ + public SetChatPhoto setChatPhoto(Object chatId, java.io.File photo) { + return new SetChatPhoto(api, chatId, photo); + } + + /** + * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param photo New chat photo, uploaded using multipart/form-data + * @return The newly created command + */ + public SetChatPhoto setChatPhoto(Object chatId, byte[] photo) { + return new SetChatPhoto(api, chatId, photo); + } + + /** + * Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field {@link Chat#canSetStickerSet() can_set_sticker_set } optionally returned in {@link #getChat} requests to check if the bot can use this method. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param stickerSetName Name of the sticker set to be set as the group sticker set + * @return The newly created command + */ + public SetChatStickerSet setChatStickerSet(Object chatId, String stickerSetName) { + return new SetChatStickerSet(api, chatId, stickerSetName); + } + + /** + * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param title New chat title, 1-128 characters + * @return The newly created command + */ + public SetChatTitle setChatTitle(Object chatId, String title) { + return new SetChatTitle(api, chatId, title); + } + + /** + * Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. + * @param name Sticker set name + * @return The newly created command + */ + public SetCustomEmojiStickerSetThumbnail setCustomEmojiStickerSetThumbnail(String name) { + return new SetCustomEmojiStickerSetThumbnail(api, name); + } + + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the {@link Message} is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * @param userId User identifier + * @param score New score, must be non-negative + * @param inlineMessageId Identifier of the inline message + * @return The newly created command + */ + public SetGameScore setGameScore(long userId, int score, String inlineMessageId) { + return new SetGameScore(api, userId, score, inlineMessageId); + } + + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the {@link Message} is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * @param userId User identifier + * @param score New score, must be non-negative + * @param chatId Unique identifier for the target chat + * @param messageId Identifier of the sent message + * @return The newly created command + */ + public SetGameScore setGameScore(long userId, int score, Object chatId, int messageId) { + return new SetGameScore(api, userId, score, chatId, messageId); + } + + /** + * Use this method to change the list of the bot's commands. See this manual for more details about bot commands. Returns True on success. + * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. + * @return The newly created command + */ + public SetMyCommands setMyCommands(BotCommand... commands) { + return new SetMyCommands(api, commands); + } + + /** + * Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success. + * @return The newly created command + */ + public SetMyDefaultAdministratorRights setMyDefaultAdministratorRights() { + return new SetMyDefaultAdministratorRights(api); + } + + /** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. + * @return The newly created command + */ + public SetMyDescription setMyDescription() { + return new SetMyDescription(api); + } + + /** + * Use this method to change the bot's name. Returns True on success. + * @return The newly created command + */ + public SetMyName setMyName() { + return new SetMyName(api); + } + + /** + * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. + * @return The newly created command + */ + public SetMyShortDescription setMyShortDescription() { + return new SetMyShortDescription(api); + } + + /** + * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + *

+ * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. + * @param userId User identifier + * @param errors An array describing the errors + * @return The newly created command + */ + public SetPassportDataErrors setPassportDataErrors(long userId, PassportElementError... errors) { + return new SetPassportDataErrors(api, userId, errors); + } + + /** + * Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * @param sticker File identifier of the sticker + * @param emojiList A list of 1-20 emoji associated with the sticker + * @return The newly created command + */ + public SetStickerEmojiList setStickerEmojiList(String sticker, String[] emojiList) { + return new SetStickerEmojiList(api, sticker, emojiList); + } + + /** + * Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * @param sticker File identifier of the sticker + * @return The newly created command + */ + public SetStickerKeywords setStickerKeywords(String sticker) { + return new SetStickerKeywords(api, sticker); + } + + /** + * Use this method to change the {@link MaskPosition mask position} of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. + * @param sticker File identifier of the sticker + * @return The newly created command + */ + public SetStickerMaskPosition setStickerMaskPosition(String sticker) { + return new SetStickerMaskPosition(api, sticker); + } + + /** + * Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. + * @param sticker File identifier of the sticker + * @param position New sticker position in the set, zero-based + * @return The newly created command + */ + public SetStickerPositionInSet setStickerPositionInSet(String sticker, int position) { + return new SetStickerPositionInSet(api, sticker, position); + } + + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * @param name Sticker set name + * @param userId User identifier of the sticker set owner + * @return The newly created command + */ + @Deprecated + public SetStickerSetThumb setStickerSetThumb(String name, Long userId) { + return new SetStickerSetThumb(api, name, userId); + } + + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * @param name Sticker set name + * @param userId User identifier of the sticker set owner + * @param thumb A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + * @return The newly created command + */ + @Deprecated + public SetStickerSetThumb setStickerSetThumb(String name, Long userId, Object thumb) { + return new SetStickerSetThumb(api, name, userId, thumb); + } + + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * @param name Sticker set name + * @param userId User identifier of the sticker set owner + * @return The newly created command + */ + public SetStickerSetThumbnail setStickerSetThumbnail(String name, Long userId) { + return new SetStickerSetThumbnail(api, name, userId); + } + + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * @param name Sticker set name + * @param userId User identifier of the sticker set owner + * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + * @return The newly created command + */ + public SetStickerSetThumbnail setStickerSetThumbnail(String name, Long userId, Object thumbnail) { + return new SetStickerSetThumbnail(api, name, userId, thumbnail); + } + + /** + * Use this method to set the title of a created sticker set. Returns True on success. + * @param name Sticker set name + * @param title Sticker set title, 1-64 characters + * @return The newly created command + */ + public SetStickerSetTitle setStickerSetTitle(String name, String title) { + return new SetStickerSetTitle(api, name, title); + } + + /** + * Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized {@link Update}. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + *

+ * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. + * @return The newly created command + */ + public SetWebhook setWebhook() { + return new SetWebhook(api); + } + + /** + * Use this method to stop updating a live location message before {@link Location#livePeriod live_period} expires. On success, if the message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the message with live location to stop + * @return The newly created command + */ + public StopMessageLiveLocation stopMessageLiveLocation(Object chatId, int messageId) { + return new StopMessageLiveLocation(api, chatId, messageId); + } + + /** + * Use this method to stop updating a live location message before {@link Location#livePeriod live_period} expires. On success, if the message is not an inline message, the edited {@link Message} is returned, otherwise True is returned. + * @param inlineMessageId Identifier of the inline message + * @return The newly created command + */ + public StopMessageLiveLocation stopMessageLiveLocation(String inlineMessageId) { + return new StopMessageLiveLocation(api, inlineMessageId); + } + + /** + * Use this method to stop a poll which was sent by the bot. On success, the stopped {@link Poll} is returned. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param messageId Identifier of the original message with the poll + * @return The newly created command + */ + public StopPoll stopPoll(Object chatId, int messageId) { + return new StopPoll(api, chatId, messageId); + } + + /** + * Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. + * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @channel_username) + * @param userId Unique identifier of the target user + * @return The newly created command + */ + public UnbanChatMember unbanChatMember(Object chatId, long userId) { + return new UnbanChatMember(api, chatId, userId); + } + + /** + * Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @param senderChatId Unique identifier of the target sender chat + * @return The newly created command + */ + public UnbanChatSenderChat unbanChatSenderChat(Object chatId, long senderChatId) { + return new UnbanChatSenderChat(api, chatId, senderChatId); + } + + /** + * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public UnhideGeneralForumTopic unhideGeneralForumTopic(Long chatId) { + return new UnhideGeneralForumTopic(api, chatId); + } + + /** + * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canManageTopics can_manage_topics} administrator rights. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @return The newly created command + */ + public UnhideGeneralForumTopic unhideGeneralForumTopic(String chatId) { + return new UnhideGeneralForumTopic(api, chatId); + } + + /** + * Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in a supergroup or {@link PromoteChatMember#canEditMessages can_edit_messages} administrator right in a channel. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public UnpinAllChatMessages unpinAllChatMessages(Object chatId) { + return new UnpinAllChatMessages(api, chatId); + } + + /** + * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in the supergroup. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + @Deprecated + public UnpinAllForumTopicMessages unpinAllForumTopicMessages(Integer chatId, Integer messageThreadId) { + return new UnpinAllForumTopicMessages(api, chatId, messageThreadId); + } + + /** + * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in the supergroup. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public UnpinAllForumTopicMessages unpinAllForumTopicMessages(Long chatId, Integer messageThreadId) { + return new UnpinAllForumTopicMessages(api, chatId, messageThreadId); + } + + /** + * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in the supergroup. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroup_username) + * @param messageThreadId Unique identifier for the target message thread of the forum topic + * @return The newly created command + */ + public UnpinAllForumTopicMessages unpinAllForumTopicMessages(String chatId, Integer messageThreadId) { + return new UnpinAllForumTopicMessages(api, chatId, messageThreadId); + } + + /** + * Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the {@link PromoteChatMember#canPinMessages can_pin_messages} administrator right in a supergroup or {@link PromoteChatMember#canEditMessages can_edit_messages} administrator right in a channel. Returns True on success. + * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channel_username) + * @return The newly created command + */ + public UnpinChatMessage unpinChatMessage(Object chatId) { + return new UnpinChatMessage(api, chatId); + } + + /** + * Use this method to upload a file with a sticker for later use in the {@link #createNewStickerSet} and {@link #addStickerToSet} methods (the file can be used multiple times). Returns the uploaded {@link File} on success. + * @param userId User identifier of sticker file owner + * @param pngSticker A file with the sticker in .PNG format. + * @return The newly created command + */ + @Deprecated + public UploadStickerFile uploadStickerFile(Long userId, Object pngSticker) { + return new UploadStickerFile(api, userId, pngSticker); + } + + /** + * Use this method to upload a file with a sticker for later use in the {@link #createNewStickerSet} and {@link #addStickerToSet} methods (the file can be used multiple times). Returns the uploaded {@link File} on success. + * @param userId User identifier of sticker file owner + * @param sticker A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. + * @param stickerFormat Format of the sticker, must be one of “static”, “animated”, “video” + * @return The newly created command + */ + public UploadStickerFile uploadStickerFile(Long userId, Object sticker, Sticker.Format stickerFormat) { + return new UploadStickerFile(api, userId, sticker, stickerFormat); + } + public void setUpdatesListener(UpdatesListener listener) { - setUpdatesListener(listener, new GetUpdates()); + setUpdatesListener(listener, new GetUpdates(api)); } public void setUpdatesListener(UpdatesListener listener, GetUpdates request) { @@ -73,7 +1873,7 @@ public void setUpdatesListener(UpdatesListener listener, GetUpdates request) { } public void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler) { - setUpdatesListener(listener, exceptionHandler, new GetUpdates()); + setUpdatesListener(listener, exceptionHandler, new GetUpdates(api)); } public void setUpdatesListener(UpdatesListener listener, ExceptionHandler exceptionHandler, GetUpdates request) { diff --git a/library/src/main/java/com/pengrad/telegrambot/impl/UpdatesHandler.java b/library/src/main/java/com/pengrad/telegrambot/impl/UpdatesHandler.java index e6cf6242..e71bcf9f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/impl/UpdatesHandler.java +++ b/library/src/main/java/com/pengrad/telegrambot/impl/UpdatesHandler.java @@ -46,7 +46,7 @@ public void stop() { private void getUpdates(GetUpdates request) { if (bot == null || listener == null) return; - bot.execute(request, new Callback() { + request.execute(new Callback() { @Override public void onResponse(GetUpdates request, GetUpdatesResponse response) { if (listener == null) return; diff --git a/library/src/main/java/com/pengrad/telegrambot/passport/EncryptedPassportElement.java b/library/src/main/java/com/pengrad/telegrambot/passport/EncryptedPassportElement.java index 8d02a62e..eacb81eb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/passport/EncryptedPassportElement.java +++ b/library/src/main/java/com/pengrad/telegrambot/passport/EncryptedPassportElement.java @@ -42,7 +42,7 @@ public DecryptedData decryptData(Credentials credentials) throws Exception { } public byte[] decryptFile(PassportFile passportFile, FileCredentials fileCredentials, TelegramBot bot) throws Exception { - File file = bot.execute(new GetFile(passportFile.fileId())).file(); + File file = bot.getFile(passportFile.fileId()).execute().file(); byte[] fileData = bot.getFileContent(file); return decryptFile(fileData, fileCredentials); } diff --git a/library/src/main/java/com/pengrad/telegrambot/passport/SetPassportDataErrors.java b/library/src/main/java/com/pengrad/telegrambot/passport/SetPassportDataErrors.java index d5f9d990..c6ef39af 100644 --- a/library/src/main/java/com/pengrad/telegrambot/passport/SetPassportDataErrors.java +++ b/library/src/main/java/com/pengrad/telegrambot/passport/SetPassportDataErrors.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.passport; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.request.BaseRequest; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ */ public class SetPassportDataErrors extends BaseRequest { - public SetPassportDataErrors(long userId, PassportElementError... errors) { - super(BaseResponse.class); + public SetPassportDataErrors(TelegramBotClient api, long userId, PassportElementError... errors) { + super(api, BaseResponse.class); add("user_id", userId).add("errors", errors); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AbstractMultipartRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/AbstractMultipartRequest.java index 54c717e5..3986188e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AbstractMultipartRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AbstractMultipartRequest.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + import java.io.File; /** @@ -12,8 +14,8 @@ abstract public class AbstractMultipartRequest> extends BaseRequest { - public AbstractSendRequest(Object chatId) { - super(SendResponse.class); + public AbstractSendRequest(TelegramBotClient api, Object chatId) { + super(api, SendResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AbstractUploadRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/AbstractUploadRequest.java index 21401d3a..fc8fb88d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AbstractUploadRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AbstractUploadRequest.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; import java.io.File; @@ -12,8 +13,8 @@ abstract public class AbstractUploadRequest, R exten private final boolean isMultipart; - public AbstractUploadRequest(Class responseClass, String paramName, Object data) { - super(responseClass); + public AbstractUploadRequest(TelegramBotClient api, Class responseClass, String paramName, Object data) { + super(api, responseClass); if (data instanceof String) { isMultipart = false; } else if (data instanceof File) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AddStickerToSet.java b/library/src/main/java/com/pengrad/telegrambot/request/AddStickerToSet.java index 1f435bbc..e36947b3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AddStickerToSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AddStickerToSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MaskPosition; import com.pengrad.telegrambot.model.request.InputSticker; import com.pengrad.telegrambot.response.BaseResponse; @@ -14,47 +15,47 @@ public class AddStickerToSet extends AbstractUploadRequest { - public AnswerCallbackQuery(String callbackQueryId) { - super(BaseResponse.class); + public AnswerCallbackQuery(TelegramBotClient api, String callbackQueryId) { + super(api, BaseResponse.class); add("callback_query_id", callbackQueryId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AnswerInlineQuery.java b/library/src/main/java/com/pengrad/telegrambot/request/AnswerInlineQuery.java index e49f8e66..7af4e1f0 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AnswerInlineQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AnswerInlineQuery.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineQueryResult; import com.pengrad.telegrambot.model.request.InlineQueryResultsButton; import com.pengrad.telegrambot.response.BaseResponse; @@ -10,8 +11,8 @@ */ public class AnswerInlineQuery extends BaseRequest { - public AnswerInlineQuery(String inlineQueryId, InlineQueryResult... results) { - super(BaseResponse.class); + public AnswerInlineQuery(TelegramBotClient api, String inlineQueryId, InlineQueryResult... results) { + super(api, BaseResponse.class); add("inline_query_id", inlineQueryId).add("results", results); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AnswerPreCheckoutQuery.java b/library/src/main/java/com/pengrad/telegrambot/request/AnswerPreCheckoutQuery.java index 9a488c3c..bc6436ab 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AnswerPreCheckoutQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AnswerPreCheckoutQuery.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,13 +9,13 @@ */ public class AnswerPreCheckoutQuery extends BaseRequest { - public AnswerPreCheckoutQuery(String preCheckoutQueryId) { - super(BaseResponse.class); + public AnswerPreCheckoutQuery(TelegramBotClient api, String preCheckoutQueryId) { + super(api, BaseResponse.class); add("pre_checkout_query_id", preCheckoutQueryId).add("ok", true); } - public AnswerPreCheckoutQuery(String preCheckoutQueryId, String errorMessage) { - super(BaseResponse.class); + public AnswerPreCheckoutQuery(TelegramBotClient api, String preCheckoutQueryId, String errorMessage) { + super(api, BaseResponse.class); add("pre_checkout_query_id", preCheckoutQueryId).add("ok", false).add("error_message", errorMessage); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AnswerShippingQuery.java b/library/src/main/java/com/pengrad/telegrambot/request/AnswerShippingQuery.java index 85986093..52106064 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AnswerShippingQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AnswerShippingQuery.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.ShippingOption; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,13 +10,13 @@ */ public class AnswerShippingQuery extends BaseRequest { - public AnswerShippingQuery(String shippingQueryId, ShippingOption... shippingOptions) { - super(BaseResponse.class); + public AnswerShippingQuery(TelegramBotClient api, String shippingQueryId, ShippingOption... shippingOptions) { + super(api, BaseResponse.class); add("shipping_query_id", shippingQueryId).add("ok", true).add("shipping_options", shippingOptions); } - public AnswerShippingQuery(String shippingQueryId, String errorMessage) { - super(BaseResponse.class); + public AnswerShippingQuery(TelegramBotClient api, String shippingQueryId, String errorMessage) { + super(api, BaseResponse.class); add("shipping_query_id", shippingQueryId).add("ok", false).add("error_message", errorMessage); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/AnswerWebAppQuery.java b/library/src/main/java/com/pengrad/telegrambot/request/AnswerWebAppQuery.java index a6bfe964..88ca3adf 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/AnswerWebAppQuery.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/AnswerWebAppQuery.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineQueryResult; import com.pengrad.telegrambot.response.BaseResponse; import com.pengrad.telegrambot.response.SentWebAppMessageResponse; @@ -10,8 +11,8 @@ */ public class AnswerWebAppQuery extends BaseRequest { - public AnswerWebAppQuery(String web_app_query_id, InlineQueryResult result) { - super(SentWebAppMessageResponse.class); + public AnswerWebAppQuery(TelegramBotClient api, String web_app_query_id, InlineQueryResult result) { + super(api, SentWebAppMessageResponse.class); add("web_app_query_id", web_app_query_id).add("result", result); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ApproveChatJoinRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/ApproveChatJoinRequest.java index 841582c9..1f753fe9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/ApproveChatJoinRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/ApproveChatJoinRequest.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -13,8 +14,8 @@ public class ApproveChatJoinRequest extends BaseRequest { - public BanChatMember(Object chatId, long userId) { - super(BaseResponse.class); + public BanChatMember(TelegramBotClient api, Object chatId, long userId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/BanChatSenderChat.java b/library/src/main/java/com/pengrad/telegrambot/request/BanChatSenderChat.java index 35b0e199..dd868fa8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/BanChatSenderChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/BanChatSenderChat.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class BanChatSenderChat extends BaseRequest { - public BanChatSenderChat(Object chatId, long sender_chat_id) { - super(BaseResponse.class); + public BanChatSenderChat(TelegramBotClient api, Object chatId, long sender_chat_id) { + super(api, BaseResponse.class); add("chat_id", chatId).add("sender_chat_id", sender_chat_id); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/BaseRequest.java b/library/src/main/java/com/pengrad/telegrambot/request/BaseRequest.java index a5083de2..126def22 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/BaseRequest.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/BaseRequest.java @@ -1,6 +1,8 @@ package com.pengrad.telegrambot.request; import com.pengrad.telegrambot.BotUtils; +import com.pengrad.telegrambot.Callback; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; import java.util.LinkedHashMap; @@ -14,11 +16,12 @@ abstract public class BaseRequest, R extends BaseRes @SuppressWarnings("unchecked") protected final T thisAsT = (T) this; - + TelegramBotClient api; private final Class responseClass; private final Map parameters; - public BaseRequest(Class responseClass) { + public BaseRequest(TelegramBotClient api, Class responseClass) { + this.api = api; this.responseClass = responseClass; this.parameters = new LinkedHashMap<>(); } @@ -67,4 +70,12 @@ public String toWebhookResponse() { fullMap.put("method", getMethod()); return BotUtils.toJson(fullMap); } + + public R execute() { + return api.send(this); + } + + public void execute(Callback callback) { + api.send(this.thisAsT, callback); + } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/Close.java b/library/src/main/java/com/pengrad/telegrambot/request/Close.java index a69a5800..5552799d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/Close.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/Close.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,7 +9,7 @@ */ public class Close extends BaseRequest { - public Close() { - super(BaseResponse.class); + public Close(TelegramBotClient api) { + super(api, BaseResponse.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CloseForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/CloseForumTopic.java index 4d6ce4db..b8383e44 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CloseForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CloseForumTopic.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class CloseForumTopic extends BaseRequest { @@ -8,16 +9,16 @@ public class CloseForumTopic extends BaseRequest * @deprecated use constructor with Long for future compatibility */ @Deprecated - public CloseForumTopic(Integer chatId, Integer messageThreadId) { - this(chatId.toString(), messageThreadId); + public CloseForumTopic(TelegramBotClient api, Integer chatId, Integer messageThreadId) { + this(api, chatId.toString(), messageThreadId); } - public CloseForumTopic(Long chatId, Integer messageThreadId) { - this(chatId.toString(), messageThreadId); + public CloseForumTopic(TelegramBotClient api, Long chatId, Integer messageThreadId) { + this(api, chatId.toString(), messageThreadId); } - public CloseForumTopic(String chatId, Integer messageThreadId) { - super(BaseResponse.class); + public CloseForumTopic(TelegramBotClient api, String chatId, Integer messageThreadId) { + super(api, BaseResponse.class); add("chat_id", chatId); add("message_thread_id", messageThreadId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CloseGeneralForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/CloseGeneralForumTopic.java index 48e6e4ab..a56d245a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CloseGeneralForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CloseGeneralForumTopic.java @@ -1,16 +1,16 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class CloseGeneralForumTopic extends BaseRequest { - public CloseGeneralForumTopic(Long chatId) { - this(chatId.toString()); + public CloseGeneralForumTopic(TelegramBotClient api, Long chatId) { + this(api, chatId.toString()); } - public CloseGeneralForumTopic(String chatId) { - super(BaseResponse.class); + public CloseGeneralForumTopic(TelegramBotClient api, String chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } - } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java index ba8a19a7..d943659c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CopyMessage.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,8 +12,8 @@ */ public class CopyMessage extends BaseRequest { - public CopyMessage(Object chatId, Object fromChatId, int messageId) { - super(MessageIdResponse.class); + public CopyMessage(TelegramBotClient api, Object chatId, Object fromChatId, int messageId) { + super(api, MessageIdResponse.class); add("chat_id", chatId).add("from_chat_id", fromChatId).add("message_id", messageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CreateChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/CreateChatInviteLink.java index 10637e9c..1b216372 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CreateChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CreateChatInviteLink.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.ChatInviteLinkResponse; /** @@ -8,8 +9,8 @@ */ public class CreateChatInviteLink extends BaseRequest { - public CreateChatInviteLink(Object chatId) { - super(ChatInviteLinkResponse.class); + public CreateChatInviteLink(TelegramBotClient api, Object chatId) { + super(api, ChatInviteLinkResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CreateForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/CreateForumTopic.java index a57e0256..860003d2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CreateForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CreateForumTopic.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.CreateForumTopicResponse; public class CreateForumTopic extends BaseRequest { @@ -8,16 +9,16 @@ public class CreateForumTopic extends BaseRequest { - public CreateInvoiceLink(String title, String description, String payload, String providerToken, - String currency, LabeledPrice... prices) { - super(StringResponse.class); + public CreateInvoiceLink(TelegramBotClient api, String title, String description, String payload, String providerToken, + String currency, LabeledPrice... prices) { + super(api, StringResponse.class); add("title", title).add("description", description).add("payload", payload) .add("provider_token", providerToken).add("currency", currency).add("prices", prices); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java index 599b3671..47febe09 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/CreateNewStickerSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MaskPosition; import com.pengrad.telegrambot.model.Sticker.Format; import com.pengrad.telegrambot.model.Sticker.Type; @@ -16,40 +17,40 @@ public class CreateNewStickerSet extends BaseRequest { - public DeleteChatPhoto(Object chatId) { - super(BaseResponse.class); + public DeleteChatPhoto(TelegramBotClient api, Object chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteChatStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteChatStickerSet.java index ab63fa4b..9635d58c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/DeleteChatStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteChatStickerSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class DeleteChatStickerSet extends BaseRequest { - public DeleteChatStickerSet(Object chatId) { - super(BaseResponse.class); + public DeleteChatStickerSet(TelegramBotClient api, Object chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteForumTopic.java index bc0c8a65..461081cb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/DeleteForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteForumTopic.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class DeleteForumTopic extends BaseRequest { @@ -8,16 +9,16 @@ public class DeleteForumTopic extends BaseRequest { - public DeleteMessage(Object chatId, int messageId) { - super(BaseResponse.class); + public DeleteMessage(TelegramBotClient api, Object chatId, int messageId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("message_id", messageId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/model/DeleteMyCommands.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMyCommands.java similarity index 81% rename from library/src/main/java/com/pengrad/telegrambot/model/DeleteMyCommands.java rename to library/src/main/java/com/pengrad/telegrambot/request/DeleteMyCommands.java index cf308dbf..9d5b8255 100644 --- a/library/src/main/java/com/pengrad/telegrambot/model/DeleteMyCommands.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteMyCommands.java @@ -1,13 +1,13 @@ -package com.pengrad.telegrambot.model; +package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.botcommandscope.BotCommandScope; -import com.pengrad.telegrambot.request.BaseRequest; import com.pengrad.telegrambot.response.BaseResponse; public class DeleteMyCommands extends BaseRequest { - public DeleteMyCommands() { - super(BaseResponse.class); + public DeleteMyCommands(TelegramBotClient api) { + super(api, BaseResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerFromSet.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerFromSet.java index 349afb43..c4d718ba 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerFromSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerFromSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -7,8 +8,8 @@ * 23 July 2017 */ public class DeleteStickerFromSet extends BaseRequest { - public DeleteStickerFromSet(String sticker) { - super(BaseResponse.class); + public DeleteStickerFromSet(TelegramBotClient api, String sticker) { + super(api, BaseResponse.class); add("sticker", sticker); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerSet.java index b8c0be41..72d7e772 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/DeleteStickerSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ public class DeleteStickerSet extends BaseRequest { - public DeleteWebhook() { - super(BaseResponse.class); + public DeleteWebhook(TelegramBotClient api) { + super(api, BaseResponse.class); } public DeleteWebhook dropPendingUpdates(boolean dropPendingUpdates) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/EditChatInviteLink.java index 2934af2d..9e7e93ad 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditChatInviteLink.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.ChatInviteLinkResponse; /** @@ -8,8 +9,8 @@ */ public class EditChatInviteLink extends BaseRequest { - public EditChatInviteLink(Object chatId, String inviteLink) { - super(ChatInviteLinkResponse.class); + public EditChatInviteLink(TelegramBotClient api, Object chatId, String inviteLink) { + super(api, ChatInviteLinkResponse.class); add("chat_id", chatId); add("invite_link", inviteLink); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/EditForumTopic.java index 4c5d32eb..8a384f38 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditForumTopic.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class EditForumTopic extends BaseRequest { @@ -8,16 +9,16 @@ public class EditForumTopic extends BaseRequest { * @deprecated use constructor with Long for future compatibility */ @Deprecated - public EditForumTopic(Integer chatId, Integer messageThreadId) { - this(chatId.toString(), messageThreadId); + public EditForumTopic(TelegramBotClient api, Integer chatId, Integer messageThreadId) { + this(api, chatId.toString(), messageThreadId); } - public EditForumTopic(Long chatId, Integer messageThreadId) { - this(chatId.toString(), messageThreadId); + public EditForumTopic(TelegramBotClient api, Long chatId, Integer messageThreadId) { + this(api, chatId.toString(), messageThreadId); } - public EditForumTopic(String chatId, Integer messageThreadId) { - super(BaseResponse.class); + public EditForumTopic(TelegramBotClient api, String chatId, Integer messageThreadId) { + super(api, BaseResponse.class); add("chat_id", chatId); add("message_thread_id", messageThreadId); } @@ -26,16 +27,16 @@ public EditForumTopic(String chatId, Integer messageThreadId) { * @deprecated use constructor with Long for future compatibility */ @Deprecated - public EditForumTopic(Integer chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { - this(chatId.toString(), messageThreadId, name, iconCustomEmojiId); + public EditForumTopic(TelegramBotClient api, Integer chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + this(api, chatId.toString(), messageThreadId, name, iconCustomEmojiId); } - public EditForumTopic(Long chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { - this(chatId.toString(), messageThreadId, name, iconCustomEmojiId); + public EditForumTopic(TelegramBotClient api, Long chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + this(api, chatId.toString(), messageThreadId, name, iconCustomEmojiId); } - public EditForumTopic(String chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { - super(BaseResponse.class); + public EditForumTopic(TelegramBotClient api, String chatId, Integer messageThreadId, String name, String iconCustomEmojiId) { + super(api, BaseResponse.class); add("chat_id", chatId); add("message_thread_id", messageThreadId); add("name", name); diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditGeneralForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/EditGeneralForumTopic.java index aa9af8ea..0952f12e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditGeneralForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditGeneralForumTopic.java @@ -1,15 +1,16 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class EditGeneralForumTopic extends BaseRequest { - public EditGeneralForumTopic(Long chatId, String name) { - this(chatId.toString(), name); + public EditGeneralForumTopic(TelegramBotClient api, Long chatId, String name) { + this(api, chatId.toString(), name); } - public EditGeneralForumTopic(String chatId, String name) { - super(BaseResponse.class); + public EditGeneralForumTopic(TelegramBotClient api, String chatId, String name) { + super(api, BaseResponse.class); add("chat_id", chatId); add("name", name); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageCaption.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageCaption.java index 08df4d95..3c601335 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageCaption.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageCaption.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.model.request.ParseMode; @@ -12,13 +13,13 @@ */ public class EditMessageCaption extends BaseRequest { - public EditMessageCaption(Object chatId, int messageId) { - super(SendResponse.class); + public EditMessageCaption(TelegramBotClient api, Object chatId, int messageId) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId); } - public EditMessageCaption(String inlineMessageId) { - super(BaseResponse.class); + public EditMessageCaption(TelegramBotClient api, String inlineMessageId) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageLiveLocation.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageLiveLocation.java index 51ace086..5c4d9031 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageLiveLocation.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageLiveLocation.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.response.BaseResponse; import com.pengrad.telegrambot.response.SendResponse; @@ -10,13 +11,13 @@ */ public class EditMessageLiveLocation extends BaseRequest { - public EditMessageLiveLocation(Object chatId, int messageId, float latitude, float longitude) { - super(SendResponse.class); + public EditMessageLiveLocation(TelegramBotClient api, Object chatId, int messageId, float latitude, float longitude) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId).add("latitude", latitude).add("longitude", longitude); } - public EditMessageLiveLocation(String inlineMessageId, float latitude, float longitude) { - super(BaseResponse.class); + public EditMessageLiveLocation(TelegramBotClient api, String inlineMessageId, float latitude, float longitude) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId).add("latitude", latitude).add("longitude", longitude); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageMedia.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageMedia.java index 3794733f..bb74780b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageMedia.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageMedia.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.model.request.InputMedia; import com.pengrad.telegrambot.response.BaseResponse; @@ -16,14 +17,14 @@ public class EditMessageMedia extends BaseRequest media; - public EditMessageMedia(Object chatId, int messageId, InputMedia media) { - super(SendResponse.class); + public EditMessageMedia(TelegramBotClient api, Object chatId, int messageId, InputMedia media) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId); addMedia(media); } - public EditMessageMedia(String inlineMessageId, InputMedia media) { - super(BaseResponse.class); + public EditMessageMedia(TelegramBotClient api, String inlineMessageId, InputMedia media) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId); addMedia(media); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageReplyMarkup.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageReplyMarkup.java index cab32cfb..f2d30015 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageReplyMarkup.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageReplyMarkup.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.response.BaseResponse; import com.pengrad.telegrambot.response.SendResponse; @@ -10,13 +11,13 @@ */ public class EditMessageReplyMarkup extends BaseRequest { - public EditMessageReplyMarkup(Object chatId, int messageId) { - super(SendResponse.class); + public EditMessageReplyMarkup(TelegramBotClient api, Object chatId, int messageId) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId); } - public EditMessageReplyMarkup(String inlineMessageId) { - super(BaseResponse.class); + public EditMessageReplyMarkup(TelegramBotClient api, String inlineMessageId) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java index a8461a13..58c33087 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/EditMessageText.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.model.request.ParseMode; @@ -12,13 +13,13 @@ */ public class EditMessageText extends BaseRequest { - public EditMessageText(Object chatId, int messageId, String text) { - super(SendResponse.class); + public EditMessageText(TelegramBotClient api, Object chatId, int messageId, String text) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId).add("text", text); } - public EditMessageText(String inlineMessageId, String text) { - super(BaseResponse.class); + public EditMessageText(TelegramBotClient api, String inlineMessageId, String text) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId).add("text", text); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ExportChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/ExportChatInviteLink.java index 2561db44..5529148f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/ExportChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/ExportChatInviteLink.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.StringResponse; /** @@ -8,8 +9,8 @@ */ public class ExportChatInviteLink extends BaseRequest { - public ExportChatInviteLink(Object chatId) { - super(StringResponse.class); + public ExportChatInviteLink(TelegramBotClient api, Object chatId) { + super(api, StringResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java index 319ec817..a7803501 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/ForwardMessage.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.SendResponse; /** @@ -8,8 +9,8 @@ */ public class ForwardMessage extends BaseRequest { - public ForwardMessage(Object chatId, Object fromChatId, int messageId) { - super(SendResponse.class); + public ForwardMessage(TelegramBotClient api, Object chatId, Object fromChatId, int messageId) { + super(api, SendResponse.class); add("chat_id", chatId).add("from_chat_id", fromChatId).add("message_id", messageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChat.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChat.java index 17c2da40..86188a42 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChat.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatResponse; /** @@ -8,8 +9,8 @@ */ public class GetChat extends BaseRequest { - public GetChat(Object chatId) { - super(GetChatResponse.class); + public GetChat(TelegramBotClient api, Object chatId) { + super(api, GetChatResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java index f4a7a1e1..aab16778 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatAdministrators.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatAdministratorsResponse; /** @@ -8,8 +9,8 @@ */ public class GetChatAdministrators extends BaseRequest { - public GetChatAdministrators(Object chatId) { - super(GetChatAdministratorsResponse.class); + public GetChatAdministrators(TelegramBotClient api, Object chatId) { + super(api, GetChatAdministratorsResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMember.java index 683db6aa..35de4567 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMember.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatMemberResponse; /** @@ -8,8 +9,8 @@ */ public class GetChatMember extends BaseRequest { - public GetChatMember(Object chatId, long userId) { - super(GetChatMemberResponse.class); + public GetChatMember(TelegramBotClient api, Object chatId, long userId) { + super(api, GetChatMemberResponse.class); add("chat_id", chatId).add("user_id", userId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMemberCount.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMemberCount.java index dc57c2f4..308566e2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMemberCount.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMemberCount.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatMemberCountResponse; public class GetChatMemberCount extends BaseRequest { - public GetChatMemberCount(Object chatId) { - super(GetChatMemberCountResponse.class); + public GetChatMemberCount(TelegramBotClient api, Object chatId) { + super(api, GetChatMemberCountResponse.class); add("chat_id", chatId); } } \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMembersCount.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMembersCount.java index 78d86190..33b8d511 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMembersCount.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMembersCount.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatMembersCountResponse; /** @@ -12,8 +13,8 @@ @Deprecated public class GetChatMembersCount extends BaseRequest { - public GetChatMembersCount(Object chatId) { - super(GetChatMembersCountResponse.class); + public GetChatMembersCount(TelegramBotClient api, Object chatId) { + super(api, GetChatMembersCountResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMenuButton.java b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMenuButton.java index 22deb09e..f32bb012 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetChatMenuButton.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetChatMenuButton.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetChatMenuButtonResponse; /** @@ -8,8 +9,8 @@ */ public class GetChatMenuButton extends BaseRequest { - public GetChatMenuButton() { - super(GetChatMenuButtonResponse.class); + public GetChatMenuButton(TelegramBotClient api) { + super(api, GetChatMenuButtonResponse.class); } public GetChatMenuButton chatId(long chatId) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetCustomEmojiStickers.java b/library/src/main/java/com/pengrad/telegrambot/request/GetCustomEmojiStickers.java index 5252824d..22174b1f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetCustomEmojiStickers.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetCustomEmojiStickers.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetCustomEmojiStickersResponse; /** @@ -8,8 +9,8 @@ */ public class GetCustomEmojiStickers extends BaseRequest { - public GetCustomEmojiStickers(String... custom_emoji_ids) { - super(GetCustomEmojiStickersResponse.class); + public GetCustomEmojiStickers(TelegramBotClient api, String... custom_emoji_ids) { + super(api, GetCustomEmojiStickersResponse.class); add("custom_emoji_ids", custom_emoji_ids); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetFile.java b/library/src/main/java/com/pengrad/telegrambot/request/GetFile.java index d42ae5c9..7acbebb3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetFile.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetFile.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetFileResponse; /** @@ -8,8 +9,8 @@ */ public class GetFile extends BaseRequest { - public GetFile(String fileId) { - super(GetFileResponse.class); + public GetFile(TelegramBotClient api, String fileId) { + super(api, GetFileResponse.class); add("file_id", fileId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetForumTopicIconStickers.java b/library/src/main/java/com/pengrad/telegrambot/request/GetForumTopicIconStickers.java index d5f9d7ee..33a07da9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetForumTopicIconStickers.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetForumTopicIconStickers.java @@ -1,9 +1,10 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetForumTopicIconStickersResponse; public class GetForumTopicIconStickers extends BaseRequest { - public GetForumTopicIconStickers() { - super(GetForumTopicIconStickersResponse.class); + public GetForumTopicIconStickers(TelegramBotClient api) { + super(api, GetForumTopicIconStickersResponse.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetGameHighScores.java b/library/src/main/java/com/pengrad/telegrambot/request/GetGameHighScores.java index ed06ce1e..f2f3620c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetGameHighScores.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetGameHighScores.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetGameHighScoresResponse; /** @@ -8,13 +9,13 @@ */ public class GetGameHighScores extends BaseRequest { - public GetGameHighScores(long userId, Object chatId, int messageId) { - super(GetGameHighScoresResponse.class); + public GetGameHighScores(TelegramBotClient api, long userId, Object chatId, int messageId) { + super(api, GetGameHighScoresResponse.class); add("user_id", userId).add("chat_id", chatId).add("message_id", messageId); } - public GetGameHighScores(long userId, String inlineMessageId) { - super(GetGameHighScoresResponse.class); + public GetGameHighScores(TelegramBotClient api, long userId, String inlineMessageId) { + super(api, GetGameHighScoresResponse.class); add("user_id", userId).add("inline_message_id", inlineMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMe.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMe.java index bf499ebe..d6712705 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMe.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMe.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetMeResponse; /** @@ -8,7 +9,7 @@ */ public class GetMe extends BaseRequest { - public GetMe() { - super(GetMeResponse.class); + public GetMe(TelegramBotClient api) { + super(api, GetMeResponse.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMyCommands.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMyCommands.java index 2c27e509..592e620b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMyCommands.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMyCommands.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.botcommandscope.BotCommandScope; import com.pengrad.telegrambot.response.GetMyCommandsResponse; @@ -9,8 +10,8 @@ */ public class GetMyCommands extends BaseRequest { - public GetMyCommands() { - super(GetMyCommandsResponse.class); + public GetMyCommands(TelegramBotClient api) { + super(api, GetMyCommandsResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMyDefaultAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMyDefaultAdministratorRights.java index bb0fd2d0..78b50ba8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMyDefaultAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMyDefaultAdministratorRights.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetMyDefaultAdministratorRightsResponse; /** @@ -8,8 +9,8 @@ */ public class GetMyDefaultAdministratorRights extends BaseRequest { - public GetMyDefaultAdministratorRights() { - super(GetMyDefaultAdministratorRightsResponse.class); + public GetMyDefaultAdministratorRights(TelegramBotClient api) { + super(api, GetMyDefaultAdministratorRightsResponse.class); } public GetMyDefaultAdministratorRights forChannels(boolean forChannels) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMyDescription.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMyDescription.java index 8313c4e2..463da588 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMyDescription.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMyDescription.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetMyDescriptionResponse; public class GetMyDescription extends BaseRequest { - public GetMyDescription() { - super(GetMyDescriptionResponse.class); + public GetMyDescription(TelegramBotClient api) { + super(api, GetMyDescriptionResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMyName.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMyName.java index 76994540..7f43259c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMyName.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMyName.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetMyNameResponse; public class GetMyName extends BaseRequest { - public GetMyName() { - super(GetMyNameResponse.class); + public GetMyName(TelegramBotClient api) { + super(api, GetMyNameResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetMyShortDescription.java b/library/src/main/java/com/pengrad/telegrambot/request/GetMyShortDescription.java index e46771e8..84b51e58 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetMyShortDescription.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetMyShortDescription.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetMyShortDescriptionResponse; public class GetMyShortDescription extends BaseRequest { - public GetMyShortDescription() { - super(GetMyShortDescriptionResponse.class); + public GetMyShortDescription(TelegramBotClient api) { + super(api, GetMyShortDescriptionResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/GetStickerSet.java index c571ada8..d8390a42 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetStickerSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetStickerSetResponse; /** @@ -8,8 +9,8 @@ */ public class GetStickerSet extends BaseRequest { - public GetStickerSet(String name) { - super(GetStickerSetResponse.class); + public GetStickerSet(TelegramBotClient api, String name) { + super(api, GetStickerSetResponse.class); add("name", name); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetUpdates.java b/library/src/main/java/com/pengrad/telegrambot/request/GetUpdates.java index cda20902..09976bb2 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetUpdates.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetUpdates.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetUpdatesResponse; /** @@ -11,8 +12,8 @@ public class GetUpdates extends BaseRequest { private int timeout = 0; private int limit = 100; - public GetUpdates() { - super(GetUpdatesResponse.class); + public GetUpdates(TelegramBotClient api) { + super(api, GetUpdatesResponse.class); } public GetUpdates offset(int offset) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetUserProfilePhotos.java b/library/src/main/java/com/pengrad/telegrambot/request/GetUserProfilePhotos.java index 10b9321c..f494c534 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetUserProfilePhotos.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetUserProfilePhotos.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetUserProfilePhotosResponse; /** @@ -8,8 +9,8 @@ */ public class GetUserProfilePhotos extends BaseRequest { - public GetUserProfilePhotos(long userId) { - super(GetUserProfilePhotosResponse.class); + public GetUserProfilePhotos(TelegramBotClient api, long userId) { + super(api, GetUserProfilePhotosResponse.class); add("user_id", userId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/GetWebhookInfo.java b/library/src/main/java/com/pengrad/telegrambot/request/GetWebhookInfo.java index ecfd16a3..e4454b1d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/GetWebhookInfo.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/GetWebhookInfo.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.GetWebhookInfoResponse; /** @@ -8,8 +9,8 @@ */ public class GetWebhookInfo extends BaseRequest { - public GetWebhookInfo() { - super(GetWebhookInfoResponse.class); + public GetWebhookInfo(TelegramBotClient api) { + super(api, GetWebhookInfoResponse.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/HideGeneralForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/HideGeneralForumTopic.java index d1657c09..62035eb4 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/HideGeneralForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/HideGeneralForumTopic.java @@ -1,15 +1,16 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class HideGeneralForumTopic extends BaseRequest { - public HideGeneralForumTopic(Long chatId) { - this(chatId.toString()); + public HideGeneralForumTopic(TelegramBotClient api, Long chatId) { + this(api, chatId.toString()); } - public HideGeneralForumTopic(String chatId) { - super(BaseResponse.class); + public HideGeneralForumTopic(TelegramBotClient api, String chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/KickChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/KickChatMember.java index b69360b4..3d25b4af 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/KickChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/KickChatMember.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -11,8 +12,8 @@ @Deprecated public class KickChatMember extends BaseRequest { - public KickChatMember(Object chatId, long userId) { - super(BaseResponse.class); + public KickChatMember(TelegramBotClient api, Object chatId, long userId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/LeaveChat.java b/library/src/main/java/com/pengrad/telegrambot/request/LeaveChat.java index e513af3e..76d3a697 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/LeaveChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/LeaveChat.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class LeaveChat extends BaseRequest { - public LeaveChat(Object chatId) { - super(BaseResponse.class); + public LeaveChat(TelegramBotClient api, Object chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/LogOut.java b/library/src/main/java/com/pengrad/telegrambot/request/LogOut.java index 11e09d16..4377ff3f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/LogOut.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/LogOut.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,7 +9,7 @@ */ public class LogOut extends BaseRequest { - public LogOut() { - super(BaseResponse.class); + public LogOut(TelegramBotClient api) { + super(api, BaseResponse.class); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java index 2857c95b..f8ab37e6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/PinChatMessage.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class PinChatMessage extends BaseRequest { - public PinChatMessage(Object chatId, int messageId) { - super(BaseResponse.class); + public PinChatMessage(TelegramBotClient api, Object chatId, int messageId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("message_id", messageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/PromoteChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/PromoteChatMember.java index 7abd5cba..39bee072 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/PromoteChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/PromoteChatMember.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class PromoteChatMember extends BaseRequest { - public PromoteChatMember(Object chatId, long userId) { - super(BaseResponse.class); + public PromoteChatMember(TelegramBotClient api, Object chatId, long userId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/ReopenForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/ReopenForumTopic.java index 23d83e1b..c4e870d1 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/ReopenForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/ReopenForumTopic.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class ReopenForumTopic extends BaseRequest { @@ -8,16 +9,16 @@ public class ReopenForumTopic extends BaseRequest { - public ReopenGeneralForumTopic(Long chatId) { - this(chatId.toString()); + public ReopenGeneralForumTopic(TelegramBotClient api, Long chatId) { + this(api, chatId.toString()); } - public ReopenGeneralForumTopic(String chatId) { - super(BaseResponse.class); + public ReopenGeneralForumTopic(TelegramBotClient api, String chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java index 1f44747f..a84d0af3 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/RestrictChatMember.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ */ public class RestrictChatMember extends BaseRequest { - public RestrictChatMember(Object chatId, long userId, ChatPermissions permissions) { - super(BaseResponse.class); + public RestrictChatMember(TelegramBotClient api, Object chatId, long userId, ChatPermissions permissions) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId).add("permissions", permissions); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/RevokeChatInviteLink.java b/library/src/main/java/com/pengrad/telegrambot/request/RevokeChatInviteLink.java index 3361e2ca..b6301868 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/RevokeChatInviteLink.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/RevokeChatInviteLink.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.ChatInviteLinkResponse; /** @@ -8,8 +9,8 @@ */ public class RevokeChatInviteLink extends BaseRequest { - public RevokeChatInviteLink(Object chatId, String inviteLink) { - super(ChatInviteLinkResponse.class); + public RevokeChatInviteLink(TelegramBotClient api, Object chatId, String inviteLink) { + super(api, ChatInviteLinkResponse.class); add("chat_id", chatId); add("invite_link", inviteLink); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendAnimation.java b/library/src/main/java/com/pengrad/telegrambot/request/SendAnimation.java index 564791c4..64dbf124 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendAnimation.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendAnimation.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendAnimation extends AbstractMultipartRequest { - public SendAnimation(Object chatId, String animation) { - super(chatId, animation); + public SendAnimation(TelegramBotClient api, Object chatId, String animation) { + super(api, chatId, animation); } - public SendAnimation(Object chatId, File animation) { - super(chatId, animation); + public SendAnimation(TelegramBotClient api, Object chatId, File animation) { + super(api, chatId, animation); } - public SendAnimation(Object chatId, byte[] animation) { - super(chatId, animation); + public SendAnimation(TelegramBotClient api, Object chatId, byte[] animation) { + super(api, chatId, animation); } public SendAnimation duration(int duration) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendAudio.java b/library/src/main/java/com/pengrad/telegrambot/request/SendAudio.java index 930b031d..df27d023 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendAudio.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendAudio.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendAudio extends AbstractMultipartRequest { - public SendAudio(Object chatId, String audio) { - super(chatId, audio); + public SendAudio(TelegramBotClient api, Object chatId, String audio) { + super(api, chatId, audio); } - public SendAudio(Object chatId, File audio) { - super(chatId, audio); + public SendAudio(TelegramBotClient api, Object chatId, File audio) { + super(api, chatId, audio); } - public SendAudio(Object chatId, byte[] audio) { - super(chatId, audio); + public SendAudio(TelegramBotClient api, Object chatId, byte[] audio) { + super(api, chatId, audio); } public SendAudio caption(String caption) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendChatAction.java b/library/src/main/java/com/pengrad/telegrambot/request/SendChatAction.java index b2e608a3..e236f10c 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendChatAction.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendChatAction.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.ChatAction; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,13 +10,13 @@ */ public class SendChatAction extends BaseRequest { - public SendChatAction(Object chatId, String action) { - super(BaseResponse.class); + public SendChatAction(TelegramBotClient api, Object chatId, String action) { + super(api, BaseResponse.class); add("chat_id", chatId).add("action", action); } - public SendChatAction(Object chatId, ChatAction action) { - super(BaseResponse.class); + public SendChatAction(TelegramBotClient api, Object chatId, ChatAction action) { + super(api, BaseResponse.class); add("chat_id", chatId).add("action", action.name()); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendContact.java b/library/src/main/java/com/pengrad/telegrambot/request/SendContact.java index 01a7e783..7c0a6f2b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendContact.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendContact.java @@ -1,13 +1,15 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + /** * stas * 5/1/16. */ public class SendContact extends AbstractSendRequest { - public SendContact(Object chatId, String phoneNumber, String firstName) { - super(chatId); + public SendContact(TelegramBotClient api, Object chatId, String phoneNumber, String firstName) { + super(api, chatId); add("phone_number", phoneNumber); add("first_name", firstName); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendDice.java b/library/src/main/java/com/pengrad/telegrambot/request/SendDice.java index 2efb0e75..49aba10e 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendDice.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendDice.java @@ -1,13 +1,15 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + /** * Stas Parshin * 31 March 2020 */ public class SendDice extends AbstractSendRequest { - public SendDice(Object chatId) { - super(chatId); + public SendDice(TelegramBotClient api, Object chatId) { + super(api, chatId); } public SendDice emoji(String emoji) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendDocument.java b/library/src/main/java/com/pengrad/telegrambot/request/SendDocument.java index ecbc5380..0fb37f3b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendDocument.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendDocument.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendDocument extends AbstractMultipartRequest { - public SendDocument(Object chatId, String document) { - super(chatId, document); + public SendDocument(TelegramBotClient api, Object chatId, String document) { + super(api, chatId, document); } - public SendDocument(Object chatId, File document) { - super(chatId, document); + public SendDocument(TelegramBotClient api, Object chatId, File document) { + super(api, chatId, document); } - public SendDocument(Object chatId, byte[] document) { - super(chatId, document); + public SendDocument(TelegramBotClient api, Object chatId, byte[] document) { + super(api, chatId, document); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendGame.java b/library/src/main/java/com/pengrad/telegrambot/request/SendGame.java index 188bb0a5..f00cc0e6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendGame.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendGame.java @@ -1,13 +1,15 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + /** * Stas Parshin * 03 October 2016 */ public class SendGame extends AbstractSendRequest { - public SendGame(Object chatId, String gameShortName) { - super(chatId); + public SendGame(TelegramBotClient api, Object chatId, String gameShortName) { + super(api, chatId); add("game_short_name", gameShortName); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendInvoice.java b/library/src/main/java/com/pengrad/telegrambot/request/SendInvoice.java index 39c08e2e..768be9d8 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendInvoice.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendInvoice.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.LabeledPrice; /** @@ -8,17 +9,17 @@ */ public class SendInvoice extends AbstractSendRequest { - public SendInvoice(Long chatId, String title, String description, String payload, String providerToken, + public SendInvoice(TelegramBotClient api, Long chatId, String title, String description, String payload, String providerToken, String currency, LabeledPrice... prices) { - super(chatId); + super(api, chatId); add("title", title).add("description", description).add("payload", payload).add("provider_token", providerToken) .add("currency", currency).add("prices", prices); } // Backward compatibility: API 5.2, parameter "start_parameter" became optional - public SendInvoice(Long chatId, String title, String description, String payload, String providerToken, - String startParameter, String currency, LabeledPrice... prices) { - this(chatId, title, description, payload, providerToken, currency, prices); + public SendInvoice(TelegramBotClient api, Long chatId, String title, String description, String payload, String providerToken, + String startParameter, String currency, LabeledPrice... prices) { + this(api, chatId, title, description, payload, providerToken, currency, prices); add("start_parameter", startParameter); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendLocation.java b/library/src/main/java/com/pengrad/telegrambot/request/SendLocation.java index caa1999a..c7966806 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendLocation.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendLocation.java @@ -1,13 +1,15 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + /** * stas * 5/1/16. */ public class SendLocation extends AbstractSendRequest { - public SendLocation(Object chatId, float latitude, float longitude) { - super(chatId); + public SendLocation(TelegramBotClient api, Object chatId, float latitude, float longitude) { + super(api, chatId); add("latitude", latitude); add("longitude", longitude); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java index 607dad76..3b2236ad 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMediaGroup.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InputMedia; import com.pengrad.telegrambot.response.MessagesResponse; @@ -13,8 +14,8 @@ public class SendMediaGroup extends BaseRequest... media) { - super(MessagesResponse.class); + public SendMediaGroup(TelegramBotClient api, Object chatId, InputMedia... media) { + super(api, MessagesResponse.class); add("chat_id", chatId).add("media", media); for (InputMedia m : media) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java b/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java index 170126ec..14b44663 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendMessage.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -9,8 +10,8 @@ */ public class SendMessage extends AbstractSendRequest { - public SendMessage(Object chatId, String text) { - super(chatId); + public SendMessage(TelegramBotClient api, Object chatId, String text) { + super(api, chatId); add("text", text); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendPhoto.java b/library/src/main/java/com/pengrad/telegrambot/request/SendPhoto.java index bd0aa124..e4040fc6 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendPhoto.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendPhoto.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendPhoto extends AbstractMultipartRequest { - public SendPhoto(Object chatId, String photo) { - super(chatId, photo); + public SendPhoto(TelegramBotClient api, Object chatId, String photo) { + super(api, chatId, photo); } - public SendPhoto(Object chatId, File photo) { - super(chatId, photo); + public SendPhoto(TelegramBotClient api, Object chatId, File photo) { + super(api, chatId, photo); } - public SendPhoto(Object chatId, byte[] photo) { - super(chatId, photo); + public SendPhoto(TelegramBotClient api, Object chatId, byte[] photo) { + super(api, chatId, photo); } public SendPhoto caption(String caption) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.java b/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.java index 1ab80a8a..c339b2dd 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendPoll.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.Poll; import com.pengrad.telegrambot.model.request.ParseMode; @@ -10,8 +11,8 @@ */ public class SendPoll extends AbstractSendRequest { - public SendPoll(Object chatId, String question, String... options) { - super(chatId); + public SendPoll(TelegramBotClient api, Object chatId, String question, String... options) { + super(api, chatId); add("question", question); add("options", options); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendSticker.java b/library/src/main/java/com/pengrad/telegrambot/request/SendSticker.java index ad39fced..58eb406f 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendSticker.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendSticker.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + import java.io.File; /** @@ -8,16 +10,16 @@ */ public class SendSticker extends AbstractMultipartRequest { - public SendSticker(Object chatId, String sticker) { - super(chatId, sticker); + public SendSticker(TelegramBotClient api, Object chatId, String sticker) { + super(api, chatId, sticker); } - public SendSticker(Object chatId, File sticker) { - super(chatId, sticker); + public SendSticker(TelegramBotClient api, Object chatId, File sticker) { + super(api, chatId, sticker); } - public SendSticker(Object chatId, byte[] sticker) { - super(chatId, sticker); + public SendSticker(TelegramBotClient api, Object chatId, byte[] sticker) { + super(api, chatId, sticker); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java b/library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java index c9c1d4ac..73a1a123 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java @@ -1,13 +1,15 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + /** * stas * 5/1/16. */ public class SendVenue extends AbstractSendRequest { - public SendVenue(Object chatId, float latitude, float longitude, String title, String address) { - super(chatId); + public SendVenue(TelegramBotClient api, Object chatId, float latitude, float longitude, String title, String address) { + super(api, chatId); add("latitude", latitude); add("longitude", longitude); add("title", title); diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendVideo.java b/library/src/main/java/com/pengrad/telegrambot/request/SendVideo.java index bb3f2b28..2b332737 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendVideo.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendVideo.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendVideo extends AbstractMultipartRequest { - public SendVideo(Object chatId, String video) { - super(chatId, video); + public SendVideo(TelegramBotClient api, Object chatId, String video) { + super(api, chatId, video); } - public SendVideo(Object chatId, File video) { - super(chatId, video); + public SendVideo(TelegramBotClient api, Object chatId, File video) { + super(api, chatId, video); } - public SendVideo(Object chatId, byte[] video) { - super(chatId, video); + public SendVideo(TelegramBotClient api, Object chatId, byte[] video) { + super(api, chatId, video); } public SendVideo duration(int duration) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendVideoNote.java b/library/src/main/java/com/pengrad/telegrambot/request/SendVideoNote.java index 0164782f..5105c6bb 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendVideoNote.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendVideoNote.java @@ -1,5 +1,7 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; + import java.io.File; /** @@ -8,16 +10,16 @@ */ public class SendVideoNote extends AbstractMultipartRequest { - public SendVideoNote(Object chatId, String videoNote) { - super(chatId, videoNote); + public SendVideoNote(TelegramBotClient api, Object chatId, String videoNote) { + super(api, chatId, videoNote); } - public SendVideoNote(Object chatId, File videoNote) { - super(chatId, videoNote); + public SendVideoNote(TelegramBotClient api, Object chatId, File videoNote) { + super(api, chatId, videoNote); } - public SendVideoNote(Object chatId, byte[] videoNote) { - super(chatId, videoNote); + public SendVideoNote(TelegramBotClient api, Object chatId, byte[] videoNote) { + super(api, chatId, videoNote); } public SendVideoNote duration(int duration) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SendVoice.java b/library/src/main/java/com/pengrad/telegrambot/request/SendVoice.java index 7ecd36aa..1d4e8cb9 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SendVoice.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SendVoice.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MessageEntity; import com.pengrad.telegrambot.model.request.ParseMode; @@ -11,16 +12,16 @@ */ public class SendVoice extends AbstractMultipartRequest { - public SendVoice(Object chatId, String voice) { - super(chatId, voice); + public SendVoice(TelegramBotClient api, Object chatId, String voice) { + super(api, chatId, voice); } - public SendVoice(Object chatId, File voice) { - super(chatId, voice); + public SendVoice(TelegramBotClient api, Object chatId, File voice) { + super(api, chatId, voice); } - public SendVoice(Object chatId, byte[] voice) { - super(chatId, voice); + public SendVoice(TelegramBotClient api, Object chatId, byte[] voice) { + super(api, chatId, voice); } public SendVoice caption(String caption) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatAdministratorCustomTitle.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatAdministratorCustomTitle.java index ff33cdbb..d385548d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatAdministratorCustomTitle.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatAdministratorCustomTitle.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class SetChatAdministratorCustomTitle extends BaseRequest { - public SetChatAdministratorCustomTitle(Object chatId, long userId, String customTitle) { - super(BaseResponse.class); + public SetChatAdministratorCustomTitle(TelegramBotClient api, Object chatId, long userId, String customTitle) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId).add("custom_title", customTitle); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatDescription.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatDescription.java index ad9a6f7c..df7e0832 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatDescription.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatDescription.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class SetChatDescription extends BaseRequest { - public SetChatDescription(Object chatId, String description) { - super(BaseResponse.class); + public SetChatDescription(TelegramBotClient api, Object chatId, String description) { + super(api, BaseResponse.class); add("chat_id", chatId).add("description", description); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatMenuButton.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatMenuButton.java index e859def0..26e39017 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatMenuButton.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatMenuButton.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.MenuButton; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ */ public class SetChatMenuButton extends BaseRequest { - public SetChatMenuButton() { - super(BaseResponse.class); + public SetChatMenuButton(TelegramBotClient api) { + super(api, BaseResponse.class); } public SetChatMenuButton chatId(long chatId) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java index 88f9275d..244c9617 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPermissions.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.ChatPermissions; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ */ public class SetChatPermissions extends BaseRequest { - public SetChatPermissions(Object chatId, ChatPermissions permissions) { - super(BaseResponse.class); + public SetChatPermissions(TelegramBotClient api, Object chatId, ChatPermissions permissions) { + super(api, BaseResponse.class); add("chat_id", chatId).add("permissions", permissions); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPhoto.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPhoto.java index fa3802f2..cee6bbd5 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatPhoto.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatPhoto.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; import java.io.File; @@ -10,13 +11,13 @@ */ public class SetChatPhoto extends BaseRequest { - public SetChatPhoto(Object chatId, byte[] photo) { - super(BaseResponse.class); + public SetChatPhoto(TelegramBotClient api, Object chatId, byte[] photo) { + super(api, BaseResponse.class); add("chat_id", chatId).add("photo", photo); } - public SetChatPhoto(Object chatId, File photo) { - super(BaseResponse.class); + public SetChatPhoto(TelegramBotClient api, Object chatId, File photo) { + super(api, BaseResponse.class); add("chat_id", chatId).add("photo", photo); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatStickerSet.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatStickerSet.java index e2692a79..f72ab5e0 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatStickerSet.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatStickerSet.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class SetChatStickerSet extends BaseRequest { - public SetChatStickerSet(Object chatId, String stickerSetName) { - super(BaseResponse.class); + public SetChatStickerSet(TelegramBotClient api, Object chatId, String stickerSetName) { + super(api, BaseResponse.class); add("chat_id", chatId).add("sticker_set_name", stickerSetName); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetChatTitle.java b/library/src/main/java/com/pengrad/telegrambot/request/SetChatTitle.java index 1a9ce8ff..7793f251 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetChatTitle.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetChatTitle.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class SetChatTitle extends BaseRequest { - public SetChatTitle(Object chatId, String title) { - super(BaseResponse.class); + public SetChatTitle(TelegramBotClient api, Object chatId, String title) { + super(api, BaseResponse.class); add("chat_id", chatId).add("title", title); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetCustomEmojiStickerSetThumbnail.java b/library/src/main/java/com/pengrad/telegrambot/request/SetCustomEmojiStickerSetThumbnail.java index 9bc4e528..b16f567d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetCustomEmojiStickerSetThumbnail.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetCustomEmojiStickerSetThumbnail.java @@ -1,12 +1,13 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class SetCustomEmojiStickerSetThumbnail extends BaseRequest { - public SetCustomEmojiStickerSetThumbnail(String name) { - super(BaseResponse.class); + public SetCustomEmojiStickerSetThumbnail(TelegramBotClient api, String name) { + super(api, BaseResponse.class); add("name", name); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetGameScore.java b/library/src/main/java/com/pengrad/telegrambot/request/SetGameScore.java index 4999ce10..bd25924a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetGameScore.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetGameScore.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; import com.pengrad.telegrambot.response.SendResponse; @@ -9,13 +10,13 @@ */ public class SetGameScore extends BaseRequest { - public SetGameScore(long userId, int score, Object chatId, int messageId) { - super(SendResponse.class); + public SetGameScore(TelegramBotClient api, long userId, int score, Object chatId, int messageId) { + super(api, SendResponse.class); add("user_id", userId).add("score", score).add("chat_id", chatId).add("message_id", messageId); } - public SetGameScore(long userId, int score, String inlineMessageId) { - super(BaseResponse.class); + public SetGameScore(TelegramBotClient api, long userId, int score, String inlineMessageId) { + super(api, BaseResponse.class); add("user_id", userId).add("score", score).add("inline_message_id", inlineMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyCommands.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyCommands.java index f0d0350b..b58f1b52 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyCommands.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyCommands.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.BotCommand; import com.pengrad.telegrambot.model.botcommandscope.BotCommandScope; import com.pengrad.telegrambot.response.BaseResponse; @@ -10,8 +11,8 @@ */ public class SetMyCommands extends BaseRequest { - public SetMyCommands(BotCommand... commands) { - super(BaseResponse.class); + public SetMyCommands(TelegramBotClient api, BotCommand... commands) { + super(api, BaseResponse.class); add("commands", commands); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java index 74d00283..24bdac14 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDefaultAdministratorRights.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.ChatAdministratorRights; import com.pengrad.telegrambot.response.BaseResponse; @@ -9,8 +10,8 @@ */ public class SetMyDefaultAdministratorRights extends BaseRequest { - public SetMyDefaultAdministratorRights() { - super(BaseResponse.class); + public SetMyDefaultAdministratorRights(TelegramBotClient api) { + super(api, BaseResponse.class); } public SetMyDefaultAdministratorRights rights(ChatAdministratorRights chatAdministratorRights) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDescription.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDescription.java index f4410306..1c6630f7 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyDescription.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyDescription.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class SetMyDescription extends BaseRequest { - public SetMyDescription() { - super(BaseResponse.class); + public SetMyDescription(TelegramBotClient api) { + super(api, BaseResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyName.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyName.java index f7ca690d..4a9a3cc7 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyName.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyName.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class SetMyName extends BaseRequest { - public SetMyName() { - super(BaseResponse.class); + public SetMyName(TelegramBotClient api) { + super(api, BaseResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetMyShortDescription.java b/library/src/main/java/com/pengrad/telegrambot/request/SetMyShortDescription.java index 10a5da20..e760976a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetMyShortDescription.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetMyShortDescription.java @@ -1,11 +1,12 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class SetMyShortDescription extends BaseRequest { - public SetMyShortDescription() { - super(BaseResponse.class); + public SetMyShortDescription(TelegramBotClient api) { + super(api, BaseResponse.class); } /** diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerEmojiList.java b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerEmojiList.java index 4170b6ed..2269b5cd 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerEmojiList.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerEmojiList.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; @@ -10,8 +11,8 @@ public class SetStickerEmojiList extends BaseRequest { - public SetStickerPositionInSet(String sticker, int position) { - super(BaseResponse.class); + public SetStickerPositionInSet(TelegramBotClient api, String sticker, int position) { + super(api, BaseResponse.class); add("sticker", sticker).add("position", position); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumb.java b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumb.java index ef9d6070..66897458 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumb.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumb.java @@ -1,25 +1,24 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** * Stas Parshin * 31 March 2020 + * @deprecated Use SetStickerSetThumbnail instead (since API v6.6) */ +@Deprecated public class SetStickerSetThumb extends AbstractUploadRequest { - /** - * @deprecated Use SetStickerSetThumbnail instead (since API v6.6) - */ - @Deprecated - public SetStickerSetThumb(String name, Long userId, Object thumb) { - super(BaseResponse.class, "thumb", thumb); + public SetStickerSetThumb(TelegramBotClient api, String name, Long userId, Object thumb) { + super(api, BaseResponse.class, "thumb", thumb); add("name", name); add("user_id", userId); } - public SetStickerSetThumb(String name, Long userId) { - super(BaseResponse.class, "name", name); + public SetStickerSetThumb(TelegramBotClient api, String name, Long userId) { + super(api, BaseResponse.class, "name", name); add("user_id", userId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java index 18cc20e7..b440d20d 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetThumbnail.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,14 +9,14 @@ */ public class SetStickerSetThumbnail extends AbstractUploadRequest { - public SetStickerSetThumbnail(String name, Long userId, Object thumbnail) { - super(BaseResponse.class, "thumbnail", thumbnail); + public SetStickerSetThumbnail(TelegramBotClient api, String name, Long userId, Object thumbnail) { + super(api, BaseResponse.class, "thumbnail", thumbnail); add("name", name); add("user_id", userId); } - public SetStickerSetThumbnail(String name, Long userId) { - super(BaseResponse.class, "name", name); + public SetStickerSetThumbnail(TelegramBotClient api, String name, Long userId) { + super(api, BaseResponse.class, "name", name); add("user_id", userId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetTitle.java b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetTitle.java index c467fabd..44fdfc3b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetTitle.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/SetStickerSetTitle.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; @@ -10,8 +11,8 @@ public class SetStickerSetTitle extends BaseRequest { private boolean isMultipart = false; - public SetWebhook() { - super(BaseResponse.class); + public SetWebhook(TelegramBotClient api) { + super(api, BaseResponse.class); } public SetWebhook url(String url) { diff --git a/library/src/main/java/com/pengrad/telegrambot/request/StopMessageLiveLocation.java b/library/src/main/java/com/pengrad/telegrambot/request/StopMessageLiveLocation.java index 9869471e..661e0a5a 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/StopMessageLiveLocation.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/StopMessageLiveLocation.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; import com.pengrad.telegrambot.response.BaseResponse; import com.pengrad.telegrambot.response.SendResponse; @@ -10,13 +11,13 @@ */ public class StopMessageLiveLocation extends BaseRequest { - public StopMessageLiveLocation(Object chatId, int messageId) { - super(SendResponse.class); + public StopMessageLiveLocation(TelegramBotClient api, Object chatId, int messageId) { + super(api, SendResponse.class); add("chat_id", chatId).add("message_id", messageId); } - public StopMessageLiveLocation(String inlineMessageId) { - super(BaseResponse.class); + public StopMessageLiveLocation(TelegramBotClient api, String inlineMessageId) { + super(api, BaseResponse.class); add("inline_message_id", inlineMessageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/StopPoll.java b/library/src/main/java/com/pengrad/telegrambot/request/StopPoll.java index 2a19e356..fbbaf600 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/StopPoll.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/StopPoll.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.request.Keyboard; import com.pengrad.telegrambot.response.PollResponse; @@ -9,8 +10,8 @@ */ public class StopPoll extends BaseRequest { - public StopPoll(Object chatId, int messageId) { - super(PollResponse.class); + public StopPoll(TelegramBotClient api, Object chatId, int messageId) { + super(api, PollResponse.class); add("chat_id", chatId).add("message_id", messageId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatMember.java b/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatMember.java index c8e523c4..baa0f568 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatMember.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatMember.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class UnbanChatMember extends BaseRequest { - public UnbanChatMember(Object chatId, long userId) { - super(BaseResponse.class); + public UnbanChatMember(TelegramBotClient api, Object chatId, long userId) { + super(api, BaseResponse.class); add("chat_id", chatId).add("user_id", userId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatSenderChat.java b/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatSenderChat.java index 2c21b5ec..dc9d5432 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatSenderChat.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UnbanChatSenderChat.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class UnbanChatSenderChat extends BaseRequest { - public UnbanChatSenderChat(Object chatId, long sender_chat_id) { - super(BaseResponse.class); + public UnbanChatSenderChat(TelegramBotClient api, Object chatId, long sender_chat_id) { + super(api, BaseResponse.class); add("chat_id", chatId).add("sender_chat_id", sender_chat_id); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UnhideGeneralForumTopic.java b/library/src/main/java/com/pengrad/telegrambot/request/UnhideGeneralForumTopic.java index 1d0415e7..e7817057 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UnhideGeneralForumTopic.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UnhideGeneralForumTopic.java @@ -1,15 +1,16 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class UnhideGeneralForumTopic extends BaseRequest { - public UnhideGeneralForumTopic(Long chatId) { - this(chatId.toString()); + public UnhideGeneralForumTopic(TelegramBotClient api, Long chatId) { + this(api, chatId.toString()); } - public UnhideGeneralForumTopic(String chatId) { - super(BaseResponse.class); + public UnhideGeneralForumTopic(TelegramBotClient api, String chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllChatMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllChatMessages.java index adf2d725..2140007b 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllChatMessages.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllChatMessages.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; /** @@ -8,8 +9,8 @@ */ public class UnpinAllChatMessages extends BaseRequest { - public UnpinAllChatMessages(Object chatId) { - super(BaseResponse.class); + public UnpinAllChatMessages(TelegramBotClient api, Object chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllForumTopicMessages.java b/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllForumTopicMessages.java index 4121174d..a8f245a7 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllForumTopicMessages.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UnpinAllForumTopicMessages.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.response.BaseResponse; public class UnpinAllForumTopicMessages extends BaseRequest { @@ -8,16 +9,16 @@ public class UnpinAllForumTopicMessages extends BaseRequest { - public UnpinChatMessage(Object chatId) { - super(BaseResponse.class); + public UnpinChatMessage(TelegramBotClient api, Object chatId) { + super(api, BaseResponse.class); add("chat_id", chatId); } diff --git a/library/src/main/java/com/pengrad/telegrambot/request/UploadStickerFile.java b/library/src/main/java/com/pengrad/telegrambot/request/UploadStickerFile.java index 08a607c0..c10e2826 100644 --- a/library/src/main/java/com/pengrad/telegrambot/request/UploadStickerFile.java +++ b/library/src/main/java/com/pengrad/telegrambot/request/UploadStickerFile.java @@ -1,5 +1,6 @@ package com.pengrad.telegrambot.request; +import com.pengrad.telegrambot.impl.TelegramBotClient; import com.pengrad.telegrambot.model.Sticker.Format; import com.pengrad.telegrambot.response.GetFileResponse; @@ -13,16 +14,16 @@ public class UploadStickerFile extends AbstractUploadRequestbold"; - SendResponse sendResponse = (SendResponse) bot.execute(new EditMessageCaption(chatId, 8124) + SendResponse sendResponse = (SendResponse) bot.editMessageCaption(chatId, 8124) .caption(text) .parseMode(ParseMode.HTML) - .replyMarkup(new InlineKeyboardMarkup())); + .replyMarkup(new InlineKeyboardMarkup()) + .execute(); assertTrue(sendResponse.isOk()); Message message = sendResponse.message(); @@ -285,10 +286,10 @@ public void editMessageCaption() { assertEquals((Integer) 21, captionEntity.offset()); assertEquals((Integer) 4, captionEntity.length()); - BaseResponse response = bot.execute(new EditMessageCaption(channelName, 511).caption(text)); + BaseResponse response = bot.editMessageCaption(channelName, 511).caption(text).execute(); assertTrue(response.isOk()); - response = bot.execute(new EditMessageCaption("AgAAAPrwAQCj_Q4D2s-51_8jsuU").caption(text)); + response = bot.editMessageCaption("AgAAAPrwAQCj_Q4D2s-51_8jsuU").caption(text).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: MESSAGE_ID_INVALID", response.description()); @@ -302,13 +303,13 @@ public void editMessageReplyMarkup() { InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup(new InlineKeyboardButton(text).url("https://google.com")); InlineKeyboardMarkup gameKeyboard = new InlineKeyboardMarkup(new InlineKeyboardButton(text).callbackGame("test game")); - BaseResponse response = bot.execute(new EditMessageReplyMarkup(chatId, 8124).replyMarkup(keyboard)); + BaseResponse response = bot.editMessageReplyMarkup(chatId, 8124).replyMarkup(keyboard).execute(); assertTrue(response.isOk()); - response = bot.execute(new EditMessageReplyMarkup(channelName, 511).replyMarkup(keyboard)); + response = bot.editMessageReplyMarkup(channelName, 511).replyMarkup(keyboard).execute(); assertTrue(response.isOk()); - response = bot.execute(new EditMessageReplyMarkup("AgAAAPrwAQCj_Q4D2s-51_8jsuU").replyMarkup(gameKeyboard)); + response = bot.editMessageReplyMarkup("AgAAAPrwAQCj_Q4D2s-51_8jsuU").replyMarkup(gameKeyboard).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: MESSAGE_ID_INVALID", response.description()); @@ -398,13 +399,13 @@ public void answerInline() { new InlineQueryResultCachedVoice("25", voiceFileId, "title").caption("cap bold").parseMode(ParseMode.HTML), }; - BaseResponse response = bot.execute(new AnswerInlineQuery(inlineQueryId, results) + BaseResponse response = bot.answerInlineQuery(inlineQueryId, results) .cacheTime(100) .isPersonal(true) .nextOffset("offset") .switchPmText("go pm") .switchPmParameter("my_pm_parameter") - ); + .execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); @@ -443,11 +444,11 @@ public void answerCallback() { assertNull(callbackQuery.inlineMessageId()); assertNull(callbackQuery.data()); - BaseResponse response = bot.execute(new AnswerCallbackQuery(callbackQuery.id()) + BaseResponse response = bot.answerCallbackQuery(callbackQuery.id()) .text("answer callback") .url("telegram.me/pengrad_test_bot?game=pengrad_test_game") .showAlert(false) - .cacheTime(1)); + .cacheTime(1).execute(); assertFalse(response.isOk()); assertEquals(400, response.errorCode()); @@ -456,7 +457,7 @@ public void answerCallback() { @Test public void getChat() throws MalformedURLException, URISyntaxException { - Chat chat = bot.execute(new GetChat(groupId)).chat(); + Chat chat = bot.getChat(groupId).execute().chat(); ChatTest.checkChat(chat, true); assertEquals(Chat.Type.supergroup, chat.type()); assertTrue(chat.title().contains("Test Bot Group")); @@ -477,13 +478,13 @@ public void getChat() throws MalformedURLException, URISyntaxException { assertNull(chat.getActiveUsernames()); assertNull(chat.getEmojiStatusCustomEmojiId()); - chat = bot.execute(new GetChat(chatId)).chat(); + chat = bot.getChat(chatId).execute().chat(); assertNotNull(chat.firstName()); assertNull(chat.lastName()); assertEquals("yo", chat.bio()); assertTrue(chat.hasPrivateForwards()); - chat = bot.execute(new GetChat(localGroup)).chat(); + chat = bot.getChat(localGroup).execute().chat(); ChatLocation location = chat.location(); assertNotNull(location); assertEquals(60.94062f, location.location().latitude(), 0f); @@ -494,7 +495,7 @@ public void getChat() throws MalformedURLException, URISyntaxException { @Test public void leaveChat() { - BaseResponse response = bot.execute(new LeaveChat(chatId)); + BaseResponse response = bot.leaveChat(chatId).execute(); assertFalse(response.isOk()); assertEquals(400, response.errorCode()); assertEquals("Bad Request: chat member status can't be changed in private chats", response.description()); @@ -502,7 +503,7 @@ public void leaveChat() { @Test public void getChatAdministrators() { - GetChatAdministratorsResponse response = bot.execute(new GetChatAdministrators(groupId)); + GetChatAdministratorsResponse response = bot.getChatAdministrators(groupId).execute(); for (ChatMember chatMember : response.administrators()) { ChatMemberTest.check(chatMember); if (chatMember.user().firstName().equals("Test Bot")) { @@ -522,7 +523,7 @@ public void getChatAdministrators() { @Test public void getChatMember() { restrictChatMember(); - ChatMember chatMember = bot.execute(new GetChatMember(groupId, memberBot)).chatMember(); + ChatMember chatMember = bot.getChatMember(groupId, memberBot).execute().chatMember(); ChatMemberTest.check(chatMember); assertEquals(ChatMember.Status.restricted, chatMember.status()); assertEquals(Integer.valueOf(0), chatMember.untilDate()); @@ -547,20 +548,20 @@ public void getChatMember() { @Test public void getChatMembersCount() { - GetChatMembersCountResponse response = bot.execute(new GetChatMembersCount(chatId)); + GetChatMembersCountResponse response = bot.getChatMembersCount(chatId).execute(); assertEquals(2, response.count()); } @Test public void getChatMemberCount() { - GetChatMemberCountResponse response = bot.execute(new GetChatMemberCount(chatId)); + GetChatMemberCountResponse response = bot.getChatMemberCount(chatId).execute(); assertEquals(2, response.count()); } @Test public void getUserProfilePhotos() { int offset = 0; - GetUserProfilePhotosResponse response = bot.execute(new GetUserProfilePhotos(chatId).limit(100).offset(offset)); + GetUserProfilePhotosResponse response = bot.getUserProfilePhotos(chatId).limit(100).offset(offset).execute(); UserProfilePhotos photos = response.photos(); assertEquals(photos.totalCount() - offset, photos.photos().length); for (PhotoSize[] photo : photos.photos()) { @@ -568,28 +569,28 @@ public void getUserProfilePhotos() { } if (photos.totalCount() > 1) { - photos = bot.execute(new GetUserProfilePhotos(chatId).limit(1)).photos(); + photos = bot.getUserProfilePhotos(chatId).limit(1).execute().photos(); assertEquals(1, photos.photos().length); } } @Test public void sendMessage() { - SendResponse sendResponse = bot.execute(new SendMessage(chatId, "reply this message").replyMarkup( - new ForceReply().inputFieldPlaceholder("input-placeholder").selective(true) - )); + SendResponse sendResponse = bot.sendMessage(chatId, "reply this message") + .replyMarkup(new ForceReply().inputFieldPlaceholder("input-placeholder").selective(true)) + .execute(); MessageTest.checkTextMessage(sendResponse.message()); assertNotNull(sendResponse.message().from()); - sendResponse = bot.execute(new SendMessage(chatId, "remove keyboard") + sendResponse = bot.sendMessage(chatId, "remove keyboard") .replyMarkup(new ReplyKeyboardRemove()) .disableNotification(true) .replyToMessageId(8087) - ); + .execute(); MessageTest.checkTextMessage(sendResponse.message()); assertNotNull(sendResponse.message().replyToMessage()); - sendResponse = bot.execute(new SendMessage(chatId, "message with keyboard") + sendResponse = bot.sendMessage(chatId, "message with keyboard") .parseMode(ParseMode.HTML) .disableWebPagePreview(false) .protectContent(true) @@ -608,20 +609,22 @@ public void sendMessage() { .resizeKeyboard(true) .inputFieldPlaceholder("input-placeholder") .isPersistent(false) - .selective(true))); + .selective(true)) + .execute(); assertTrue(sendResponse.message().hasProtectedContent()); MessageTest.checkTextMessage(sendResponse.message()); - sendResponse = bot.execute(new SendMessage(chatId, "simple buttons") - .replyMarkup(new ReplyKeyboardMarkup("ok", "cancel"))); + sendResponse = bot.sendMessage(chatId, "simple buttons") + .replyMarkup(new ReplyKeyboardMarkup("ok", "cancel")) + .execute(); MessageTest.checkTextMessage(sendResponse.message()); } @Test public void sendMessageToChannel() { String url = "https://google.com/"; - SendMessage request = new SendMessage(channelName, "channel message [GG](" + url + ")").parseMode(ParseMode.Markdown); - SendResponse sendResponse = bot.execute(request); + SendMessage request = bot.sendMessage(channelName, "channel message [GG](" + url + ")").parseMode(ParseMode.Markdown); + SendResponse sendResponse = request.execute(); Message message = sendResponse.message(); MessageTest.checkTextMessage(message); assertEquals(url, message.entities()[0].url()); @@ -630,15 +633,15 @@ public void sendMessageToChannel() { @Test public void sendMessageToChannelId() { - SendMessage request = new SendMessage(channelId, "channel by id message"); - SendResponse sendResponse = bot.execute(request); + SendMessage request = bot.sendMessage(channelId, "channel by id message"); + SendResponse sendResponse = request.execute(); Message message = sendResponse.message(); MessageTest.checkTextMessage(message); } @Test public void forwardMessage() { - SendResponse response = bot.execute(new ForwardMessage(chatId, chatId, forwardMessageId).disableNotification(true)); + SendResponse response = bot.forwardMessage(chatId, chatId, forwardMessageId).disableNotification(true).execute(); Message message = response.message(); MessageTest.checkMessage(message); assertNotNull(message.forwardDate()); @@ -649,13 +652,13 @@ public void forwardMessage() { assertEquals("gif", viaBot.username()); // message from user with open account - message = bot.execute(new ForwardMessage(chatId, chatId, forwardMessageIdUser)).message(); + message = bot.forwardMessage(chatId, chatId, forwardMessageIdUser).execute().message(); MessageTest.checkMessage(message); assertNotNull(message.forwardDate()); assertNull(message.forwardSenderName()); assertNotNull(message.forwardFrom()); - message = bot.execute(new ForwardMessage(channelName, channelName, 651)).message(); + message = bot.forwardMessage(channelName, channelName, 651).execute().message(); assertNotNull(message.authorSignature()); assertNotNull(message.forwardSignature()); assertEquals(Integer.valueOf(651), message.forwardFromMessageId()); @@ -664,7 +667,7 @@ public void forwardMessage() { assertEquals(Chat.Type.channel, chat.type()); assertNull(message.forwardSenderName()); - message = bot.execute(new ForwardMessage(chatId, groupId, 352).messageThreadId(0)).message(); + message = bot.forwardMessage(chatId, groupId, 352).messageThreadId(0).execute().message(); assertEquals(MessageEntity.Type.text_mention, message.entities()[0].type()); assertNotNull(message.entities()[0].user()); assertNotNull(message.forwardSenderName()); @@ -672,7 +675,7 @@ public void forwardMessage() { @Test public void copyMessage() { - MessageIdResponse response = bot.execute(new CopyMessage(chatId, chatId, forwardMessageId) + MessageIdResponse response = bot.copyMessage(chatId, chatId, forwardMessageId) .messageThreadId(0) .caption("new **caption**") .parseMode(ParseMode.MarkdownV2) @@ -680,15 +683,15 @@ public void copyMessage() { .allowSendingWithoutReply(false) .replyToMessageId(1) .disableNotification(true) - ); + .execute(); assertTrue(response.messageId() > 0); } @Test public void sendAudio() { - Message message = bot.execute(new SendAudio(chatId, audioFileId) + Message message = bot.sendAudio(chatId, audioFileId) .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7)) - ).message(); + .execute().message(); MessageTest.checkMessage(message); AudioTest.checkAudio(message.audio(), false); MessageEntity captionEntity = message.captionEntities()[0]; @@ -696,7 +699,7 @@ public void sendAudio() { assertEquals((Integer) 0, captionEntity.offset()); assertEquals((Integer) 7, captionEntity.length()); - message = bot.execute(new SendAudio(chatId, audioFile).thumb(thumbFile)).message(); + message = bot.sendAudio(chatId, audioFile).thumb(thumbFile).execute().message(); MessageTest.checkMessage(message); AudioTest.checkAudio(message.audio()); assertEquals(thumbSize, message.audio().thumb().fileSize()); @@ -704,9 +707,9 @@ public void sendAudio() { String cap = "http://ya.ru bold #audio @pengrad_test_bot", title = "title", performer = "performer"; ParseMode parseMode = ParseMode.HTML; int duration = 100; - SendAudio sendAudio = new SendAudio(chatId, audioBytes).thumb(thumbBytes).duration(duration) + SendAudio sendAudio = bot.sendAudio(chatId, audioBytes).thumb(thumbBytes).duration(duration) .caption(cap).parseMode(parseMode).performer(performer).title(title); - message = bot.execute(sendAudio).message(); + message = sendAudio.execute().message(); MessageTest.checkMessage(message); Audio audio = message.audio(); @@ -735,8 +738,8 @@ public void underlineStrikethroughMessageEntity() { String cap = "under1 under2 strike1 strike2 strike3"; cap += " nested-tag"; ParseMode parseMode = ParseMode.HTML; - SendAudio sendAudio = new SendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); - Message message = bot.execute(sendAudio).message(); + SendAudio sendAudio = bot.sendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); + Message message = sendAudio.execute().message(); MessageTest.checkMessage(message); String htmlCaption = cap @@ -789,8 +792,8 @@ public void underlineStrikethroughMessageEntity() { public void underlineStrikethroughMarkdown() { String cap = "__under1__ ~strike1~ __~nested~__"; ParseMode parseMode = ParseMode.MarkdownV2; - SendAudio sendAudio = new SendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); - Message message = bot.execute(sendAudio).message(); + SendAudio sendAudio = bot.sendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); + Message message = sendAudio.execute().message(); MessageTest.checkMessage(message); String htmlCaption = cap.replace("__", "").replace("~", ""); @@ -821,8 +824,8 @@ public void underlineStrikethroughMarkdown() { @Test public void sendSpoilerMessage() { - SendResponse response = bot.execute(new SendMessage(chatId, "ok this is spoiler ha-ha-ha") - .entities(new MessageEntity(MessageEntity.Type.spoiler, 19, 8))); + SendResponse response = bot.sendMessage(chatId, "ok this is spoiler ha-ha-ha") + .entities(new MessageEntity(MessageEntity.Type.spoiler, 19, 8)).execute(); MessageEntity entity = response.message().entities()[0]; assertEquals(MessageEntity.Type.spoiler, entity.type()); @@ -836,8 +839,8 @@ public void preMessageEntity() { "String s = new String();\n" + "```"; ParseMode parseMode = ParseMode.MarkdownV2; - SendAudio sendAudio = new SendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); - Message message = bot.execute(sendAudio).message(); + SendAudio sendAudio = bot.sendAudio(chatId, audioFileId).caption(cap).parseMode(parseMode); + Message message = sendAudio.execute().message(); MessageTest.checkMessage(message); assertEquals(1, message.captionEntities().length); assertEquals("java", message.captionEntities()[0].language()); @@ -845,14 +848,13 @@ public void preMessageEntity() { @Test public void sendDocument() { - Message message = bot.execute(new SendDocument(chatId, docFileId)).message(); + Message message = bot.sendDocument(chatId, docFileId).execute().message(); MessageTest.checkMessage(message); DocumentTest.check(message.document()); - message = bot.execute( - new SendDocument(chatId, docBytes).thumb(thumbBytes).contentType("application/pdf") - .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7))) - .message(); + message = bot.sendDocument(chatId, docBytes).thumb(thumbBytes).contentType("application/pdf") + .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7)) + .execute().message(); MessageTest.checkMessage(message); DocumentTest.check(message.document()); assertEquals(thumbSize, message.document().thumb().fileSize()); @@ -863,10 +865,8 @@ public void sendDocument() { String caption = "caption bold", fileName = "my doc.pdf"; ParseMode parseMode = ParseMode.HTML; - message = bot.execute( - new SendDocument(chatId, docFile).fileName(fileName).thumb(thumbFile).caption(caption).parseMode(parseMode) - .disableContentTypeDetection(true)) - .message(); + message = bot.sendDocument(chatId, docFile).fileName(fileName).thumb(thumbFile).caption(caption).parseMode(parseMode) + .disableContentTypeDetection(true).execute().message(); MessageTest.checkMessage(message); DocumentTest.check(message.document()); assertEquals(caption.replace("", "").replace("", ""), message.caption()); @@ -881,12 +881,13 @@ public void sendDocument() { @Test public void sendPhoto() { - Message message = bot.execute(new SendPhoto(chatId, photoFileId)).message(); + Message message = bot.sendPhoto(chatId, photoFileId).execute().message(); MessageTest.checkMessage(message); PhotoSizeTest.checkPhotos(false, message.photo()); - message = bot.execute(new SendPhoto(chatId, imageFile).hasSpoiler(true) - .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7))).message(); + message = bot.sendPhoto(chatId, imageFile).hasSpoiler(true) + .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7)) + .execute().message(); MessageTest.checkMessage(message); PhotoSizeTest.checkPhotos(message.photo()); MessageEntity captionEntity = message.captionEntities()[0]; @@ -895,7 +896,7 @@ public void sendPhoto() { assertEquals((Integer) 7, captionEntity.length()); String caption = "caption bold"; - message = bot.execute(new SendPhoto(channelName, imageBytes).caption(caption).parseMode(ParseMode.HTML)).message(); + message = bot.sendPhoto(channelName, imageBytes).caption(caption).parseMode(ParseMode.HTML).execute().message(); MessageTest.checkMessage(message); assertEquals(caption.replace("", "").replace("", ""), message.caption()); PhotoSizeTest.checkPhotos(message.photo()); @@ -908,33 +909,33 @@ public void sendPhoto() { @Test public void sendSticker() { - Message message = bot.execute(new SendSticker(chatId, stickerFileAnim).emoji("\uD83D\uDE00")).message(); + Message message = bot.sendSticker(chatId, stickerFileAnim).emoji("\uD83D\uDE00").execute().message(); MessageTest.checkMessage(message); StickerTest.check(message.sticker(), false, true); assertTrue(message.sticker().isAnimated()); assertEquals("\uD83D\uDE00", message.sticker().emoji()); assertEquals(Sticker.Type.regular, message.sticker().type()); - message = bot.execute(new SendSticker(chatId, stickerId).thumbnail(thumbFile)).message(); + message = bot.sendSticker(chatId, stickerId).thumbnail(thumbFile).execute().message(); MessageTest.checkMessage(message); StickerTest.check(message.sticker(), true, false); assertFalse(message.sticker().isAnimated()); - message = bot.execute(new SendSticker(chatId, imageBytes).thumbnail(thumbBytes)).message(); + message = bot.sendSticker(chatId, imageBytes).thumbnail(thumbBytes).execute().message(); MessageTest.checkMessage(message); StickerTest.check(message.sticker(), false, true); } @Test public void sendVideo() { - Message message = bot.execute(new SendVideo(chatId, videoFileId).hasSpoiler(true)).message(); + Message message = bot.sendVideo(chatId, videoFileId).hasSpoiler(true).execute().message(); MessageTest.checkMessage(message); VideoTest.check(message.video(), false); - message = bot.execute(new SendVideo(chatId, videoFile) + message = bot.sendVideo(chatId, videoFile) .thumb(thumbFile) .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7)) - ).message(); + .execute().message(); MessageTest.checkMessage(message); VideoTest.check(message.video()); assertNotEquals("telegram should generate thumb", thumbSize, message.video().thumb().fileSize()); @@ -946,10 +947,10 @@ public void sendVideo() { String caption = "caption bold"; int duration = 100; - message = bot.execute( - new SendVideo(chatId, videoBytes).thumb(thumbBytes) + message = bot.sendVideo(chatId, videoBytes).thumb(thumbBytes) .caption(caption).parseMode(ParseMode.HTML) - .duration(duration).height(1).width(2).supportsStreaming(true)) + .duration(duration).height(1).width(2).supportsStreaming(true) + .execute() .message(); System.out.println(message); MessageTest.checkMessage(message); @@ -971,17 +972,18 @@ public void sendVideo() { @Test public void sendVoice() { - Message message = bot.execute(new SendVoice(chatId, voiceFileId)).message(); + Message message = bot.sendVoice(chatId, voiceFileId).execute().message(); MessageTest.checkMessage(message); VoiceTest.check(message.voice(), false); - message = bot.execute(new SendVoice(chatId, audioFile)).message(); + message = bot.sendVoice(chatId, audioFile).execute().message(); MessageTest.checkMessage(message); VoiceTest.check(message.voice()); String caption = "caption bold"; int duration = 100; - message = bot.execute(new SendVoice(chatId, audioBytes).caption(caption).parseMode(ParseMode.HTML).duration(duration)).message(); + message = bot.sendVoice(chatId, audioBytes).caption(caption).parseMode(ParseMode.HTML).duration(duration) + .execute().message(); MessageTest.checkMessage(message); assertEquals(caption.replace("", "").replace("", ""), message.caption()); VoiceTest.check(message.voice()); @@ -995,7 +997,7 @@ public void sendVoice() { @Test public void getWebhookInfo() { - GetWebhookInfoResponse response = bot.execute(new GetWebhookInfo()); + GetWebhookInfoResponse response = bot.getWebhookInfo().execute(); WebhookInfo webhookInfo = response.webhookInfo(); assertNotNull(webhookInfo.url()); assertFalse(webhookInfo.hasCustomCertificate()); @@ -1008,7 +1010,7 @@ public void setWebhook() throws IOException { Integer maxConnections = 100; String[] allowedUpdates = {"message", "callback_query"}; String ipAddress = "1.1.1.1"; - BaseResponse response = bot.execute(new SetWebhook() + BaseResponse response = bot.setWebhook() .url(url) .certificate(new File(certificateFile)) .ipAddress(ipAddress) @@ -1016,10 +1018,10 @@ public void setWebhook() throws IOException { .allowedUpdates(allowedUpdates) .secretToken("secret-token") .dropPendingUpdates(true) - ); + .execute(); assertTrue(response.isOk()); - WebhookInfo webhookInfo = bot.execute(new GetWebhookInfo()).webhookInfo(); + WebhookInfo webhookInfo = bot.getWebhookInfo().execute().webhookInfo(); assertEquals(url, webhookInfo.url()); assertTrue(webhookInfo.hasCustomCertificate()); assertEquals(maxConnections, webhookInfo.maxConnections()); @@ -1035,17 +1037,17 @@ public void setWebhook() throws IOException { assertEquals(ipAddress, webhookInfo.ipAddress()); assertTrue(webhookInfo.pendingUpdateCount() >= 0); - response = bot.execute(new SetWebhook().url("https://google.com") - .certificate(Files.readAllBytes(new File(certificateFile).toPath())).allowedUpdates("")); + response = bot.setWebhook().url("https://google.com") + .certificate(Files.readAllBytes(new File(certificateFile).toPath())).allowedUpdates("").execute(); assertTrue(response.isOk()); - response = bot.execute(new SetWebhook()); + response = bot.setWebhook().execute(); assertTrue(response.isOk()); } @Test public void deleteWebhook() { - BaseResponse response = bot.execute(new DeleteWebhook().dropPendingUpdates(true)); + BaseResponse response = bot.deleteWebhook().dropPendingUpdates(true).execute(); assertTrue(response.isOk()); } @@ -1065,7 +1067,7 @@ public void sendGame() { InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup(inlineKeyboard); String desc = "pengrad_test_game"; - Message message = bot.execute(new SendGame(chatId, desc).replyMarkup(keyboardMarkup)).message(); + Message message = bot.sendGame(chatId, desc).replyMarkup(keyboardMarkup).execute().message(); MessageTest.checkMessage(message); Game game = message.game(); GameTest.check(game); @@ -1088,20 +1090,21 @@ public void sendGame() { @Test public void setGameScore() { int res = (int) (System.currentTimeMillis() / 1000); - BaseResponse response = bot.execute(new SetGameScore(chatId, res, "AgAAAPrwAQCj_Q4D2s-51_8jsuU")); + BaseResponse response = bot.setGameScore(chatId, res, "AgAAAPrwAQCj_Q4D2s-51_8jsuU").execute(); assertTrue(response.isOk()); - SendResponse sendResponse = (SendResponse) bot.execute( - new SetGameScore(chatId, res + 1, chatId, 8162).force(true).disableEditMessage(true)); + SendResponse sendResponse = (SendResponse) bot.setGameScore(chatId, res + 1, chatId, 8162) + .force(true).disableEditMessage(true).execute(); GameTest.check(sendResponse.message().game()); } @Test public void getGameHighScores() { - GameHighScore[] scores = bot.execute(new GetGameHighScores(chatId, "AgAAAPrwAQCj_Q4D2s-51_8jsuU")).result(); + GameHighScore[] scores = bot.getGameHighScores(chatId, "AgAAAPrwAQCj_Q4D2s-51_8jsuU") + .execute().result(); GameHighScoreTest.check(scores); - scores = bot.execute(new GetGameHighScores(chatId, chatId, 8162)).result(); + scores = bot.getGameHighScores(chatId, chatId, 8162).execute().result(); GameHighScoreTest.check(scores); } @@ -1109,12 +1112,12 @@ public void getGameHighScores() { public void sendLocation() { float lat = 21.999998f, lng = 105.2f, horizontalAccuracy = 1.9f; int livePeriod = 60, heading = 120, proximityAlertRadius = 50000; - Location location = bot.execute(new SendLocation(chatId, lat, lng) + Location location = bot.sendLocation(chatId, lat, lng) .horizontalAccuracy(horizontalAccuracy) .livePeriod(livePeriod) .heading(heading) .proximityAlertRadius(proximityAlertRadius) - ).message().location(); + .execute().message().location(); assertEquals(lat, location.latitude(), 0.00001f); assertEquals(lng, location.longitude(), 0.00001f); assertEquals(horizontalAccuracy, location.horizontalAccuracy(), 0.11f); @@ -1127,9 +1130,9 @@ public void sendLocation() { public void sendVenue() { float lat = 21.999998f, lng = 105.2f; String title = "title", address = "addr", frsqrId = "asdfasdf", frsqrType = "frType"; - Venue venue = bot.execute(new SendVenue(chatId, lat, lng, title, address) + Venue venue = bot.sendVenue(chatId, lat, lng, title, address) .foursquareId(frsqrId).foursquareType(frsqrType) - ).message().venue(); + .execute().message().venue(); assertEquals(lat, venue.location().latitude(), 0f); assertEquals(lng, venue.location().longitude(), 0f); assertEquals(address, venue.address()); @@ -1138,9 +1141,9 @@ public void sendVenue() { assertEquals(frsqrType, venue.foursquareType()); String ggId = "ggId", ggType = "library"; - venue = bot.execute(new SendVenue(chatId, lat, lng, title, address) + venue = bot.sendVenue(chatId, lat, lng, title, address) .googlePlaceId(ggId).googlePlaceType(ggType) - ).message().venue(); + .execute().message().venue(); assertEquals(ggId, venue.googlePlaceId()); assertEquals(ggType, venue.googlePlaceType()); } @@ -1148,7 +1151,8 @@ public void sendVenue() { @Test public void sendContact() { String phone = "000111", name = "first", lastName = "last", vcard = "ok vcard"; - Contact contact = bot.execute(new SendContact(chatId, phone, name).lastName(lastName).vcard(vcard)).message().contact(); + Contact contact = bot.sendContact(chatId, phone, name).lastName(lastName).vcard(vcard) + .execute().message().contact(); assertEquals(phone, contact.phoneNumber()); assertEquals(name, contact.firstName()); assertEquals(lastName, contact.lastName()); @@ -1158,55 +1162,55 @@ public void sendContact() { @Test public void deleteMessage() { - Message message = bot.execute(new SendMessage(chatId, "message for delete")).message(); - BaseResponse response = bot.execute(new DeleteMessage(chatId, message.messageId())); + Message message = bot.sendMessage(chatId, "message for delete").execute().message(); + BaseResponse response = bot.deleteMessage(chatId, message.messageId()).execute(); assertTrue(response.isOk()); } @Test public void sendChatAction() { - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.typing.name())).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.typing)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.upload_photo)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.record_video)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.upload_video)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.record_voice)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.upload_voice)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.upload_document)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.find_location)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.record_video_note)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.upload_video_note)).isOk()); - assertTrue(bot.execute(new SendChatAction(chatId, ChatAction.choose_sticker)).isOk()); - assertTrue(bot.execute(new SendChatAction(forum, ChatAction.choose_sticker).messageThreadId(forumEditThread)).isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.typing.name()).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.typing).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.upload_photo).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.record_video).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.upload_video).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.record_voice).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.upload_voice).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.upload_document).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.find_location).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.record_video_note).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.upload_video_note).execute().isOk()); + assertTrue(bot.sendChatAction(chatId, ChatAction.choose_sticker).execute().isOk()); + assertTrue(bot.sendChatAction(forum, ChatAction.choose_sticker).messageThreadId(forumEditThread).execute().isOk()); } @Test public void sendVideoNote() { - SendResponse response = bot.execute(new SendVideoNote(chatId, "DQADAgADmQADYgwpSbum1JrxPsbmAg")); + SendResponse response = bot.sendVideoNote(chatId, "DQADAgADmQADYgwpSbum1JrxPsbmAg").execute(); VideoNoteCheck.check(response.message().videoNote()); } @Test public void sendVideoNoteFile() { - SendResponse response = bot.execute(new SendVideoNote(chatId, videoNoteFile).thumb(thumbFile).length(20).duration(30)); + SendResponse response = bot.sendVideoNote(chatId, videoNoteFile).thumb(thumbFile).length(20).duration(30).execute(); VideoNoteCheck.check(response.message().videoNote(), true); assertNotEquals("telegram should generate thumb", thumbSize, response.message().videoNote().thumb().fileSize()); - response = bot.execute(new SendVideoNote(chatId, videoNoteBytes).thumb(thumbBytes)); + response = bot.sendVideoNote(chatId, videoNoteBytes).thumb(thumbBytes).execute(); VideoNoteCheck.check(response.message().videoNote(), true); assertNotEquals("telegram should generate thumb", thumbSize, response.message().videoNote().thumb().fileSize()); } @Test public void setChatAdministratorCustomTitle() { - BaseResponse response = bot.execute(new PromoteChatMember(groupId, memberBot).canPromoteMembers(true)); + BaseResponse response = bot.promoteChatMember(groupId, memberBot).canPromoteMembers(true).execute(); assertTrue(response.isOk()); String customTitle = "aqi " + new Random().nextInt(999999); - response = bot.execute(new SetChatAdministratorCustomTitle(groupId, memberBot, customTitle)); + response = bot.setChatAdministratorCustomTitle(groupId, memberBot, customTitle).execute(); assertTrue(response.isOk()); - ChatMember member = bot.execute(new GetChatMember(groupId, memberBot)).chatMember(); + ChatMember member = bot.getChatMember(groupId, memberBot).execute().chatMember(); ChatMemberTest.check(member); assertEquals(customTitle, member.customTitle()); assertFalse(member.isAnonymous()); @@ -1230,11 +1234,11 @@ public void setChatPermissions() { setPerms.canInviteUsers(bool); setPerms.canPinMessages(bool); setPerms.canManageTopics(bool); - BaseResponse response = bot.execute(new SetChatPermissions(groupId, setPerms) - .useIndependentChatPermissions(false)); + BaseResponse response = bot.setChatPermissions(groupId, setPerms) + .useIndependentChatPermissions(false).execute(); assertTrue(response.isOk()); - Chat chat = bot.execute(new GetChat(groupId)).chat(); + Chat chat = bot.getChat(groupId).execute().chat(); ChatPermissions permissions = chat.permissions(); if (bool) { assertTrue(permissions.canSendMessages()); @@ -1272,24 +1276,24 @@ public void setChatPermissions() { @Test public void exportChatInviteLink() { - StringResponse response = bot.execute(new ExportChatInviteLink(groupId)); + StringResponse response = bot.exportChatInviteLink(groupId).execute(); assertTrue(response.isOk()); assertNotNull(response.result()); } @Test public void setChatPhoto() throws IOException { - BaseResponse response = bot.execute(new SetChatPhoto(groupId, imageFile)); + BaseResponse response = bot.setChatPhoto(groupId, imageFile).execute(); assertTrue(response.isOk()); byte[] bytes = Files.readAllBytes(imageFile.toPath()); - response = bot.execute(new SetChatPhoto(groupId, bytes)); + response = bot.setChatPhoto(groupId, bytes).execute(); assertTrue(response.isOk()); } @Test public void deleteChatPhoto() { - BaseResponse response = bot.execute(new DeleteChatPhoto(groupId)); + BaseResponse response = bot.deleteChatPhoto(groupId).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: CHAT_NOT_MODIFIED", response.description()); @@ -1298,19 +1302,19 @@ public void deleteChatPhoto() { @Test public void setChatTitle() { - BaseResponse response = bot.execute(new SetChatTitle(groupId, "Test Bot Group " + System.currentTimeMillis())); + BaseResponse response = bot.setChatTitle(groupId, "Test Bot Group " + System.currentTimeMillis()).execute(); assertTrue(response.isOk()); } @Test public void setChatDescription() { - BaseResponse response = bot.execute(new SetChatDescription(groupId, "New desc " + System.currentTimeMillis())); + BaseResponse response = bot.setChatDescription(groupId, "New desc " + System.currentTimeMillis()).execute(); assertTrue(response.isOk()); } @Test public void pinChatMessage() { - BaseResponse response = bot.execute(new PinChatMessage(groupId, 18).disableNotification(false)); + BaseResponse response = bot.pinChatMessage(groupId, 18).disableNotification(false).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: CHAT_NOT_MODIFIED", response.description()); @@ -1319,19 +1323,19 @@ public void pinChatMessage() { @Test public void unpinChatMessage() { - BaseResponse response = bot.execute(new UnpinChatMessage(groupId).messageId(3600)); + BaseResponse response = bot.unpinChatMessage(groupId).messageId(3600).execute(); assertTrue(response.isOk()); } @Test public void unpinAllChatMessages() { - BaseResponse response = bot.execute(new UnpinAllChatMessages(groupId)); + BaseResponse response = bot.unpinAllChatMessages(groupId).execute(); assertTrue(response.isOk()); } @Test public void getStickerSet() { - GetStickerSetResponse response = bot.execute(new GetStickerSet(stickerSet)); + GetStickerSetResponse response = bot.getStickerSet(stickerSet).execute(); StickerSet stickerSet = response.stickerSet(); for (Sticker sticker : response.stickerSet().stickers()) { StickerTest.check(sticker, true, true); @@ -1339,7 +1343,7 @@ public void getStickerSet() { // clean up stickers, max 120 allowed if (stickerSet.stickers().length > 50) { for (int i = stickerSet.stickers().length - 1; i > stickerSet.stickers().length - 10; i--) { - bot.execute(new DeleteStickerFromSet(stickerSet.stickers()[i].fileId())); + bot.deleteStickerFromSet(stickerSet.stickers()[i].fileId()).execute(); } } assertTrue(stickerSet.containsMasks()); @@ -1360,60 +1364,56 @@ public void getStickerSet() { @Test public void uploadStickerFile() throws IOException { byte[] bytes = Files.readAllBytes(stickerFile.toPath()); - GetFileResponse response = bot.execute(new UploadStickerFile(chatId, bytes)); + GetFileResponse response = bot.uploadStickerFile(chatId, bytes).execute(); FileTest.check(response.file(), false); - response = bot.execute(new UploadStickerFile(chatId, bytes, Sticker.Format.Static)); + response = bot.uploadStickerFile(chatId, bytes, Sticker.Format.Static).execute(); FileTest.check(response.file(), false); } @Test public void createNewPngStickerSet() { String name = "test" + System.currentTimeMillis() + "_by_pengrad_test_bot"; - BaseResponse response = bot.execute( - CreateNewStickerSet.pngSticker(chatId, name, "test1", "\uD83D\uDE00", stickerFile) + BaseResponse response = bot.createNewStaticStickerSet(chatId, name, "test1", "\uD83D\uDE00", stickerFile) .stickerType(Sticker.Type.mask) - .maskPosition(new MaskPosition(MaskPosition.Point.forehead, 0f, 0f, 1f))); + .maskPosition(new MaskPosition(MaskPosition.Point.forehead, 0f, 0f, 1f)) + .execute(); assertTrue(response.isOk()); - response = bot.execute(new AddStickerToSet(chatId, name, + response = bot.addStickerToSet(chatId, name, new InputSticker(stickerId, new String[]{"\uD83D\uDE00"})) - .maskPosition(new MaskPosition("eyes", 0f, 0f, 1f))); + .maskPosition(new MaskPosition("eyes", 0f, 0f, 1f)).execute(); assertTrue(response.isOk()); } @Test public void createNewWebmStickerSetAndAddSticker() { String setName = "test" + System.currentTimeMillis() + "_by_pengrad_test_bot"; - BaseResponse response = bot.execute( - CreateNewStickerSet.webmSticker(chatId, setName, + BaseResponse response = bot.createNewVideoStickerSet(chatId, setName, "test1", "\uD83D\uDE00", stickerFileVid) .stickerType(Sticker.Type.mask) - .maskPosition(new MaskPosition(MaskPosition.Point.forehead, 0f, 0f, 1f))); + .maskPosition(new MaskPosition(MaskPosition.Point.forehead, 0f, 0f, 1f)) + .execute(); assertTrue(response.isOk()); - response = bot.execute( - AddStickerToSet.webmSticker(chatId, setName, "\uD83D\uDE15", stickerFileVid)); + response = bot.addVideoStickerToSet(chatId, setName, "\uD83D\uDE15", stickerFileVid).execute(); assertTrue(response.isOk()); } @Test public void addStickerToSet() { - BaseResponse response = bot.execute( - AddStickerToSet.pngSticker(chatId, stickerSet, "\uD83D\uDE15", "BQADAgADuAAD7yupS4eB23UmZhGuAg") - .maskPosition(new MaskPosition("eyes", 0f, 0f, 1f))); + BaseResponse response = bot.addStaticStickerToSet(chatId, stickerSet, "\uD83D\uDE15", "BQADAgADuAAD7yupS4eB23UmZhGuAg") + .maskPosition(new MaskPosition("eyes", 0f, 0f, 1f)).execute(); assertTrue(response.isOk()); } @Test public void createSetAndAddStickerTgs() { String setName = "test" + System.currentTimeMillis() + "_by_pengrad_test_bot"; - BaseResponse response = bot.execute( - CreateNewStickerSet.tgsSticker(chatId, setName, "test1", "\uD83D\uDE00", stickerFileAnim)); + BaseResponse response = bot.createNewAnimatedStickerSet(chatId, setName, "test1", "\uD83D\uDE00", stickerFileAnim).execute(); assertTrue(response.isOk()); - response = bot.execute( - AddStickerToSet.tgsSticker(chatId, setName, "\uD83D\uDE15", stickerFileAnim)); + response = bot.addAnimatedStickerToSet(chatId, setName, "\uD83D\uDE15", stickerFileAnim).execute(); assertTrue(response.isOk()); } @@ -1421,17 +1421,17 @@ public void createSetAndAddStickerTgs() { public void createNewStickerSet() { String setName = "testNEW" + System.currentTimeMillis() + "_by_pengrad_test_bot"; String title = "test112312312"; - BaseResponse response = bot.execute( - new CreateNewStickerSet(chatId, setName, title, new InputSticker[]{ + BaseResponse response = bot.createNewStickerSet(chatId, setName, title, new InputSticker[]{ new InputSticker(stickerFile, new String[]{"\uD83D\uDE00"}) .keywords(new String[]{"yes", "no"}) .maskPosition(new MaskPosition(MaskPosition.Point.forehead, 10f, 20f, 1f)) }, Sticker.Format.Static) - .containsMasks(false) - .needsRepainting(false)); + .containsMasks(false) + .needsRepainting(false) + .execute(); assertTrue(response.isOk()); - StickerSet set = bot.execute(new GetStickerSet(setName)).stickerSet(); + StickerSet set = bot.getStickerSet(setName).execute().stickerSet(); assertEquals(setName, set.name()); assertEquals(title, set.title()); assertFalse(set.isVideo()); @@ -1443,44 +1443,44 @@ public void createNewStickerSet() { assertNull(stickers[0].premiumAnimation()); assertNull(stickers[0].customEmojiId()); - response = bot.execute(new SetStickerSetTitle(setName, "new title")); + response = bot.setStickerSetTitle(setName, "new title").execute(); assertTrue(response.isOk()); String stickerId = stickers[0].fileId(); - response = bot.execute(new SetStickerEmojiList(stickerId, new String[]{"\uD83D\uDE00"})); + response = bot.setStickerEmojiList(stickerId, new String[]{"\uD83D\uDE00"}).execute(); assertTrue(response.isOk()); - response = bot.execute(new SetStickerKeywords(stickerId).keywords(new String[]{"ok"})); + response = bot.setStickerKeywords(stickerId).keywords(new String[]{"ok"}).execute(); assertTrue(response.isOk()); - response = bot.execute(new SetStickerMaskPosition(stickerId) - .maskPosition(new MaskPosition(MaskPosition.Point.mouth, 0f, 0f, 0f))); + response = bot.setStickerMaskPosition(stickerId) + .maskPosition(new MaskPosition(MaskPosition.Point.mouth, 0f, 0f, 0f)).execute(); assertFalse(response.isOk()); assertEquals("Bad Request: STICKER_MASK_COORDS_NOT_SUPPORTED", response.description()); - response = bot.execute(new DeleteStickerSet(setName)); + response = bot.deleteStickerSet(setName).execute(); assertTrue(response.isOk()); } @Test public void setStickerPositionInSet() { - GetStickerSetResponse setResponse = bot.execute(new GetStickerSet(stickerSet)); + GetStickerSetResponse setResponse = bot.getStickerSet(stickerSet).execute(); Sticker sticker = setResponse.stickerSet().stickers()[0]; - BaseResponse response = bot.execute(new SetStickerPositionInSet(sticker.fileId(), 0)); + BaseResponse response = bot.setStickerPositionInSet(sticker.fileId(), 0).execute(); assertTrue(response.isOk()); } @Test public void deleteStickerFromSet() { - BaseResponse response = bot.execute(AddStickerToSet.pngSticker(chatId, stickerSet, "\uD83D\uDE15", stickerFile)); + BaseResponse response = bot.addStaticStickerToSet(chatId, stickerSet, "\uD83D\uDE15", stickerFile).execute(); assertTrue(response.isOk()); - GetStickerSetResponse setResponse = bot.execute(new GetStickerSet(stickerSet)); + GetStickerSetResponse setResponse = bot.getStickerSet(stickerSet).execute(); int size = setResponse.stickerSet().stickers().length; Sticker sticker = setResponse.stickerSet().stickers()[size - 1]; - response = bot.execute(new DeleteStickerFromSet(sticker.fileId())); + response = bot.deleteStickerFromSet(sticker.fileId()).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: STICKERSET_NOT_MODIFIED", response.description()); @@ -1490,13 +1490,13 @@ public void deleteStickerFromSet() { @Test public void setStickerSetThumb() { String thumbFile = "CAACAgIAAxkBAAJ0ll6DO4bNCynpfZmS6g-YcGY2zrP5AAIBAAPANk8TGC5zMKs_LVEYBA"; - BaseResponse response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId, thumbFile)); + BaseResponse response = bot.setStickerSetThumb(stickerSetAnim, chatId, thumbFile).execute(); assertTrue(response.isOk()); - response = bot.execute(new SetStickerSetThumbnail(stickerSetAnim, chatId, thumbFile)); + response = bot.setStickerSetThumbnail(stickerSetAnim, chatId, thumbFile).execute(); assertTrue(response.isOk()); - StickerSet set = bot.execute(new GetStickerSet(stickerSetAnim)).stickerSet(); + StickerSet set = bot.getStickerSet(stickerSetAnim).execute().stickerSet(); assertTrue(set.isAnimated()); PhotoSize thumb = set.thumb(); PhotoSizeTest.checkPhotos(thumb); @@ -1505,16 +1505,16 @@ public void setStickerSetThumb() { assertEquals(Long.valueOf(8244), thumb.fileSize()); // clear thumb by not sending it - response = bot.execute(new SetStickerSetThumb(stickerSetAnim, chatId)); + response = bot.setStickerSetThumb(stickerSetAnim, chatId).execute(); assertTrue(response.isOk()); - response = bot.execute(new SetStickerSetThumbnail(stickerSetAnim, chatId)); + response = bot.setStickerSetThumbnail(stickerSetAnim, chatId).execute(); assertTrue(response.isOk()); } @Test public void getCustomEmojiStickers() { - GetCustomEmojiStickersResponse response = bot.execute(new GetCustomEmojiStickers("5434144690511290129")); + GetCustomEmojiStickersResponse response = bot.getCustomEmojiStickers("5434144690511290129").execute(); assertTrue(response.isOk()); assertEquals(1, response.result().length); } @@ -1522,50 +1522,47 @@ public void getCustomEmojiStickers() { @Test public void setCustomEmojiStickerSetThumbnail() { String setName = "custom_emoji_set_by_pengrad_test_bot"; - BaseResponse response = bot.execute( - new CreateNewStickerSet(chatId, setName, "title", + BaseResponse response = bot.createNewStickerSet(chatId, setName, "title", new InputSticker[]{new InputSticker(stickerFileAnim, new String[]{"\uD83D\uDE15"})}, - Sticker.Format.animated - ).stickerType(Sticker.Type.custom_emoji) - ); + Sticker.Format.animated).stickerType(Sticker.Type.custom_emoji) + .execute(); assertTrue(response.isOk()); - response = bot.execute(new SetCustomEmojiStickerSetThumbnail(setName).customEmojiId("123")); + response = bot.setCustomEmojiStickerSetThumbnail(setName).customEmojiId("123").execute(); assertTrue(response.isOk()); - response = bot.execute(new DeleteStickerSet(setName)); + response = bot.deleteStickerSet(setName).execute(); assertTrue(response.isOk()); } @Test public void editMessageLiveLocation() { - BaseResponse response = bot.execute(new EditMessageLiveLocation(chatId, 10009, 21, 105) - .replyMarkup(new InlineKeyboardMarkup())); + BaseResponse response = bot.editMessageLiveLocation(chatId, 10009, 21, 105) + .replyMarkup(new InlineKeyboardMarkup()).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: message can't be edited", response.description()); } String buttonText = "btn_" + System.currentTimeMillis(); - response = bot.execute( - new EditMessageLiveLocation("AgAAAPrwAQCj_Q4D2s-51_8jsuU", 21, 102) + response = bot.editMessageLiveLocation("AgAAAPrwAQCj_Q4D2s-51_8jsuU", 21, 102) .horizontalAccuracy(1f) .heading(10) .proximityAlertRadius(100) .replyMarkup(new InlineKeyboardMarkup(new InlineKeyboardButton(buttonText).callbackGame(buttonText))) - ); + .execute(); assertTrue(response.isOk()); } @Test public void stopMessageLiveLocation() { - BaseResponse response = bot.execute(new StopMessageLiveLocation(chatId, 10009)); + BaseResponse response = bot.stopMessageLiveLocation(chatId, 10009).execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: message can't be edited", response.description()); } - response = bot.execute(new StopMessageLiveLocation("AgAAAPrwAQCj_Q4D2s-51_8jsuU")); + response = bot.stopMessageLiveLocation("AgAAAPrwAQCj_Q4D2s-51_8jsuU").execute(); if (!response.isOk()) { assertEquals(400, response.errorCode()); assertEquals("Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message", @@ -1575,14 +1572,14 @@ public void stopMessageLiveLocation() { @Test public void setChatStickerSet() { - BaseResponse response = bot.execute(new SetChatStickerSet(groupId, "PengradTest")); + BaseResponse response = bot.setChatStickerSet(groupId, "PengradTest").execute(); assertFalse(response.isOk()); assertEquals(400, response.errorCode()); } @Test public void deleteChatStickerSet() { - BaseResponse response = bot.execute(new DeleteChatStickerSet(groupId)); + BaseResponse response = bot.deleteChatStickerSet(groupId).execute(); assertFalse(response.isOk()); assertEquals(400, response.errorCode()); } @@ -1592,7 +1589,7 @@ public void sendMediaGroup() { String url = "https://google.com/"; User user = new User(memberBot); String language = "ru"; - MessagesResponse response = bot.execute(new SendMediaGroup(chatId, + MessagesResponse response = bot.sendMediaGroup(chatId, new InputMediaPhoto(photoFileId).thumbnail(thumbFile), new InputMediaPhoto(imageFile).caption("some caption bold") .captionEntities( @@ -1605,8 +1602,9 @@ public void sendMediaGroup() { new InputMediaVideo(videoFileId).hasSpoiler(true), new InputMediaVideo(videoFile), new InputMediaVideo(videoBytes).caption("my video bold").parseMode(ParseMode.HTML) - .duration(10).width(11).height(12).supportsStreaming(true) - ).messageThreadId(0).disableNotification(false).allowSendingWithoutReply(false).replyToMessageId(1)); + .duration(10).width(11).height(12).supportsStreaming(true)) + .messageThreadId(0).disableNotification(false).allowSendingWithoutReply(false).replyToMessageId(1) + .execute(); assertTrue(response.isOk()); assertEquals(6, response.messages().length); @@ -1635,10 +1633,10 @@ public void sendMediaGroup() { @Test public void sendMediaGroupDocuments() { - MessagesResponse response = bot.execute(new SendMediaGroup(chatId, + MessagesResponse response = bot.sendMediaGroup(chatId, new InputMediaDocument(docFile), new InputMediaDocument(docBytes).fileName("test.pdf").contentType("application/pdf") - )); + ).execute(); assertTrue(response.isOk()); assertEquals(2, response.messages().length); assertNotNull(response.messages()[0].mediaGroupId()); @@ -1651,38 +1649,38 @@ public void editMessageMedia() { int messageId = 13541; SendResponse response; - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaDocument(docFile) .thumb(thumbFile) .disableContentTypeDetection(true) - ).replyMarkup(new InlineKeyboardMarkup())); + ).replyMarkup(new InlineKeyboardMarkup()).execute(); assertEquals((Long) 13264L, response.message().document().fileSize()); assertEquals(thumbSize, response.message().document().thumb().fileSize()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, - new InputMediaDocument(docBytes).thumb(thumbBytes))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, + new InputMediaDocument(docBytes).thumb(thumbBytes)).execute(); assertEquals((Long) 13264L, response.message().document().fileSize()); assertEquals(thumbSize, response.message().document().thumb().fileSize()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaDocument(docFileId))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaDocument(docFileId)).execute(); MessageTest.checkMessage(response.message()); DocumentTest.check(response.message().document()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFile))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaAnimation(gifFile)).execute(); assertEquals(Integer.valueOf(1), response.message().animation().duration()); int expectedSize = 160; // idk why? Integer durationAnim = 17, width = 21, height = 22; - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, - new InputMediaAnimation(gifBytes).duration(durationAnim).width(width).height(height).hasSpoiler(true) - )); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, + new InputMediaAnimation(gifBytes).duration(durationAnim).width(width).height(height).hasSpoiler(true)) + .execute(); Animation animation = response.message().animation(); assertEquals(1, animation.duration().intValue()); assertEquals(expectedSize, animation.width().intValue()); assertEquals(expectedSize, animation.height().intValue()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAnimation(gifFileId))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaAnimation(gifFileId)).execute(); assertTrue(response.isOk()); AnimationCheck.check(response.message().animation()); assertEquals(Integer.valueOf(3), response.message().animation().duration()); @@ -1691,17 +1689,17 @@ public void editMessageMedia() { assertEquals(Long.valueOf(57527), response.message().document().fileSize()); assertEquals("video/mp4", response.message().document().mimeType()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAudio(audioFileId))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaAudio(audioFileId)).execute(); assertEquals(Long.valueOf(10286), response.message().audio().fileSize()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAudio(audioFile))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaAudio(audioFile)).execute(); assertEquals(Long.valueOf(10286), response.message().audio().fileSize()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaAudio(audioBytes))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaAudio(audioBytes)).execute(); assertEquals(Long.valueOf(10286), response.message().audio().fileSize()); Integer duration = 34; String performer = "some performer", title = "just a title", fileName = "beep.mp3"; - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, - new InputMediaAudio(audioFile).duration(duration).performer(performer).title(title) - )); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, + new InputMediaAudio(audioFile).duration(duration).performer(performer).title(title)) + .execute(); Audio audio = response.message().audio(); assertEquals(Long.valueOf(10286), audio.fileSize()); assertEquals(duration, audio.duration()); @@ -1710,9 +1708,9 @@ public void editMessageMedia() { assertEquals(fileName, audio.fileName()); // send multipart InputMediaPhoto, InputMediaVideo to cover getFileName and getContentType - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaPhoto(photoFileId).thumb(thumbFile))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaPhoto(photoFileId).thumb(thumbFile)).execute(); assertNotNull(response.message().photo()); - response = (SendResponse) bot.execute(new EditMessageMedia(chatId, messageId, new InputMediaVideo(videoFileId).thumb(thumbFile))); + response = (SendResponse) bot.editMessageMedia(chatId, messageId, new InputMediaVideo(videoFileId).thumb(thumbFile)).execute(); assertNotNull(response.message().video()); } @@ -1721,9 +1719,10 @@ public void sendAnimation() { int expectedSize = 160; // idk why? int width = 340, height = 240; String caption = "gif *file*", captionCheck = "gif file"; - SendResponse response = bot.execute(new SendAnimation(chatId, gifFile) + SendResponse response = bot.sendAnimation(chatId, gifFile) .duration(222).width(width).height(height).thumb(thumbFile) - .caption(caption).parseMode(ParseMode.Markdown).hasSpoiler(true)); + .caption(caption).parseMode(ParseMode.Markdown).hasSpoiler(true) + .execute(); assertTrue(response.isOk()); Animation animation = response.message().animation(); assertEquals((Integer) 1, animation.duration()); @@ -1733,8 +1732,9 @@ public void sendAnimation() { assertEquals(captionCheck, response.message().caption()); assertEquals(MessageEntity.Type.bold, response.message().captionEntities()[0].type()); - response = bot.execute(new SendAnimation(chatId, gifBytes).thumb(thumbBytes) - .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7))); + response = bot.sendAnimation(chatId, gifBytes).thumb(thumbBytes) + .caption("caption").captionEntities(new MessageEntity(MessageEntity.Type.italic, 0, 7)) + .execute(); animation = response.message().animation(); assertEquals((Integer) 1, animation.duration()); assertEquals(expectedSize, animation.width().intValue()); @@ -1745,7 +1745,7 @@ public void sendAnimation() { assertEquals((Integer) 0, captionEntity.offset()); assertEquals((Integer) 7, captionEntity.length()); - response = bot.execute(new SendAnimation(chatId, gifFileId)); + response = bot.sendAnimation(chatId, gifFileId).execute(); animation = response.message().animation(); assertEquals((Integer) 3, animation.duration()); assertEquals((Integer) 128, animation.width()); @@ -1754,11 +1754,11 @@ public void sendAnimation() { @Test public void setPassportDataErrors() { - BaseResponse response = bot.execute(new SetPassportDataErrors(chatId, + BaseResponse response = bot.setPassportDataErrors(chatId, new PassportElementErrorDataField("personal_details", "first_name", "TueU2/SswOD5wgQ6uXQ62mJrr0Jdf30r/QQ/jyETHFM=", - "error in page 1") - )); + "error in page 1")) + .execute(); System.out.println(response); assertTrue(response.isOk()); } @@ -1835,8 +1835,7 @@ public void decryptPassport() throws Exception { public void sendPoll() { String question = "Question ?"; String[] answers = {"Answer 1", "Answer 2"}; - SendResponse sendResponse = bot.execute( - new SendPoll(groupId, question, answers) + SendResponse sendResponse = bot.sendPoll(groupId, question, answers) .isAnonymous(false) .type(Poll.Type.quiz) .allowsMultipleAnswers(false) @@ -1845,7 +1844,7 @@ public void sendPoll() { .explanation("Some __explanation__ of poll") .explanationParseMode(ParseMode.MarkdownV2) .openPeriod(500) - ); + .execute(); Poll poll = sendResponse.message().poll(); if (poll == null) { // sometimes response is success but poll is empty @@ -1876,8 +1875,7 @@ public void sendPollWithKeyboard() { String question = "Question ?"; String[] answers = {"Answer 1", "Answer 2"}; long closeDate = System.currentTimeMillis() / 1000 + 500; - SendResponse sendResponse = bot.execute( - new SendPoll(chatId, question, answers) + SendResponse sendResponse = bot.sendPoll(chatId, question, answers) .type("regular") .allowsMultipleAnswers(true) .replyMarkup(new ReplyKeyboardMarkup( @@ -1885,7 +1883,7 @@ public void sendPollWithKeyboard() { new KeyboardButton("quiz").requestPoll(new KeyboardButtonPollType(Poll.Type.quiz)), new KeyboardButton("regular").requestPoll(new KeyboardButtonPollType("regular")))) .closeDate(closeDate) - ); + .execute(); Poll poll = sendResponse.message().poll(); assertEquals(question, poll.question()); assertEquals(answers.length, poll.options().length); @@ -1900,10 +1898,10 @@ public void sendPollWithKeyboard() { public void stopPoll() { String question = "Question ?"; String[] answers = {"Answer 1", "Answer 2"}; - SendResponse sendResponse = bot.execute(new SendPoll(groupId, question, answers).messageThreadId(0)); + SendResponse sendResponse = bot.sendPoll(groupId, question, answers).messageThreadId(0).execute(); Integer messageId = sendResponse.message().messageId(); - PollResponse response = bot.execute(new StopPoll(groupId, messageId)); + PollResponse response = bot.stopPoll(groupId, messageId).execute(); Poll poll = response.poll(); assertTrue(poll.isClosed()); assertEquals(question, poll.question()); @@ -1930,7 +1928,7 @@ public void pollAnswer() { @Test public void testAsyncCallback() throws Exception { CountDownLatch latch = new CountDownLatch(1); - bot.execute(new GetMe(), new Callback() { + bot.getMe().execute(new Callback() { @Override public void onResponse(GetMe request, GetMeResponse response) { latch.countDown(); @@ -1948,7 +1946,7 @@ public void onFailure(GetMe request, IOException e) { public void botClientError() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); TelegramBotClient botClient = new TelegramBotClient(new OkHttpClient(), null, TelegramBot.Builder.API_URL); - botClient.send(new GetMe(), new Callback() { + botClient.send(new GetMe(botClient), new Callback() { @Override public void onResponse(GetMe request, GetMeResponse response) { } @@ -1963,19 +1961,19 @@ public void onFailure(GetMe request, IOException e) { @Test public void toWebhookResponse() { - assertEquals("{\"method\":\"getMe\"}", new GetMe().toWebhookResponse()); + assertEquals("{\"method\":\"getMe\"}", bot.getMe().toWebhookResponse()); } @Test public void loginButton() { String text = "login"; String url = "https://pengrad.herokuapp.com/hello"; - SendResponse response = bot.execute( - new SendMessage(chatId, "Login button").replyMarkup(new InlineKeyboardMarkup( + SendResponse response = bot.sendMessage(chatId, "Login button").replyMarkup(new InlineKeyboardMarkup( new InlineKeyboardButton(text).loginUrl(new LoginUrl(url) .forwardText("forwarded login") .botUsername("pengrad_test_bot") - .requestWriteAccess(true))))); + .requestWriteAccess(true)))) + .execute(); assertTrue(response.isOk()); InlineKeyboardButton button = response.message().replyMarkup().inlineKeyboard()[0][0]; assertEquals(text, button.text()); @@ -1985,9 +1983,8 @@ public void loginButton() { @Test public void multipartNonAscii() { String caption = "хорошо"; - Message message = bot.execute( - new SendPhoto(chatId, imageFile).fileName("файл.txt").caption(caption) - ).message(); + Message message = bot.sendPhoto(chatId, imageFile).fileName("файл.txt").caption(caption) + .execute().message(); assertEquals(caption, message.caption()); MessageTest.checkMessage(message); PhotoSizeTest.checkPhotos(message.photo()); @@ -2005,37 +2002,37 @@ public void testResponseParameters() { @Test public void sendDice() { - SendResponse response = bot.execute(new SendDice(chatId)); + SendResponse response = bot.sendDice(chatId).execute(); Dice dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 6); assertEquals("🎲", dice.emoji()); - response = bot.execute(new SendDice(chatId).darts()); + response = bot.sendDice(chatId).darts().execute(); dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 6); assertEquals("🎯", dice.emoji()); - response = bot.execute(new SendDice(chatId).basketball()); + response = bot.sendDice(chatId).basketball().execute(); dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 5); assertEquals("🏀", dice.emoji()); - response = bot.execute(new SendDice(chatId).football()); + response = bot.sendDice(chatId).football().execute(); dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 5); assertEquals("⚽", dice.emoji()); - response = bot.execute(new SendDice(chatId).slotMachine()); + response = bot.sendDice(chatId).slotMachine().execute(); dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 64); assertEquals("🎰", dice.emoji()); - response = bot.execute(new SendDice(chatId).bowling()); + response = bot.sendDice(chatId).bowling().execute(); dice = response.message().dice(); assertNotNull(dice); assertTrue(dice.value() >= 1 && dice.value() <= 6); @@ -2050,18 +2047,18 @@ public void setMyCommands() { new BotCommand("c3", "desc3"), }; - SetMyCommands cmds = new SetMyCommands(commands); + SetMyCommands cmds = bot.setMyCommands(commands); cmds.languageCode("en"); cmds.scope(new BotCommandScopeAllChatAdministrators()); - BaseResponse response = bot.execute(cmds); + BaseResponse response = cmds.execute(); assertTrue(response.isOk()); - GetMyCommands getCmds = new GetMyCommands(); + GetMyCommands getCmds = bot.getMyCommands(); getCmds.languageCode("en"); getCmds.scope(new BotCommandScopeAllChatAdministrators()); - GetMyCommandsResponse commandsResponse = bot.execute(getCmds); + GetMyCommandsResponse commandsResponse = getCmds.execute(); assertTrue(commandsResponse.isOk()); assertEquals(commands[0].command(), commandsResponse.commands()[0].command()); assertEquals(commands[0].description(), commandsResponse.commands()[0].description()); @@ -2070,18 +2067,18 @@ public void setMyCommands() { @Test public void deleteMyCommands() { - DeleteMyCommands cmds = new DeleteMyCommands(); + DeleteMyCommands cmds = bot.deleteMyCommands(); cmds.languageCode("en"); cmds.scope(new BotCommandScopeAllChatAdministrators()); - BaseResponse response = bot.execute(cmds); + BaseResponse response = cmds.execute(); assertTrue(response.isOk()); - GetMyCommands getCmds = new GetMyCommands(); + GetMyCommands getCmds = bot.getMyCommands(); getCmds.languageCode("en"); getCmds.scope(new BotCommandScopeAllChatAdministrators()); - GetMyCommandsResponse commandsResponse = bot.execute(getCmds); + GetMyCommandsResponse commandsResponse = getCmds.execute(); assertTrue(commandsResponse.isOk()); assertArrayEquals(commandsResponse.commands(), new BotCommand[0]); } @@ -2092,10 +2089,11 @@ public void inviteLinks() { int expireDate = (int) (System.currentTimeMillis() / 1000) + 500; String name = "TestName"; - ChatInviteLinkResponse response = bot.execute(new CreateChatInviteLink(groupId) + ChatInviteLinkResponse response = bot.createChatInviteLink(groupId) .expireDate(expireDate) .memberLimit(memberLimit) - .name(name)); + .name(name) + .execute(); ChatInviteLink link = response.chatInviteLink(); assertEquals(expireDate, link.expireDate().intValue()); assertEquals(memberLimit, link.memberLimit().intValue()); @@ -2106,76 +2104,81 @@ public void inviteLinks() { int editMemberLimit = 3; int editExpireDate = (int) (System.currentTimeMillis() / 1000) + 1500; String editName = name + "edit"; - response = bot.execute(new EditChatInviteLink(groupId, link.inviteLink()) + response = bot.editChatInviteLink(groupId, link.inviteLink()) .expireDate(editExpireDate) .memberLimit(editMemberLimit) - .name(editName)); + .name(editName) + .execute(); link = response.chatInviteLink(); assertEquals(editExpireDate, link.expireDate().intValue()); assertEquals(editMemberLimit, link.memberLimit().intValue()); assertEquals(editName, link.name()); assertFalse(link.isRevoked()); - response = bot.execute(new RevokeChatInviteLink(groupId, link.inviteLink())); + response = bot.revokeChatInviteLink(groupId, link.inviteLink()).execute(); link = response.chatInviteLink(); assertTrue(link.isRevoked()); assertFalse(link.isPrimary()); - response = bot.execute(new CreateChatInviteLink(groupId).createsJoinRequest(true)); + response = bot.createChatInviteLink(groupId).createsJoinRequest(true).execute(); link = response.chatInviteLink(); assertTrue(link.createsJoinRequest()); assertNull(link.pendingJoinRequestCount()); - response = bot.execute(new EditChatInviteLink(groupId, link.inviteLink()).createsJoinRequest(false)); + response = bot.editChatInviteLink(groupId, link.inviteLink()).createsJoinRequest(false).execute(); assertFalse(response.chatInviteLink().createsJoinRequest()); } @Test public void chatJoinRequest() { - BaseResponse response = bot.execute(new ApproveChatJoinRequest(groupId, memberBot)); + BaseResponse response = bot.approveChatJoinRequest(groupId, memberBot).execute(); assertFalse(response.isOk()); assertEquals("Bad Request: USER_ALREADY_PARTICIPANT", response.description()); - response = bot.execute(new DeclineChatJoinRequest(groupId, memberBot)); + response = bot.declineChatJoinRequest(groupId, memberBot).execute(); assertFalse(response.isOk()); assertEquals("Bad Request: HIDE_REQUESTER_MISSING", response.description()); } @Test public void banChatSenderChat() { - BaseResponse response = bot.execute(new BanChatSenderChat(channelName, memberBot)); + BaseResponse response = bot.banChatSenderChat(channelName, memberBot).execute(); assertTrue(response.isOk()); } @Test public void unbanChatSenderChat() { - BaseResponse response = bot.execute(new UnbanChatSenderChat(channelName, memberBot)); + BaseResponse response = bot.unbanChatSenderChat(channelName, memberBot).execute(); assertTrue(response.isOk()); } @Test public void setChatMenuButton() { - BaseResponse response = bot.execute(new SetChatMenuButton().chatId(chatId) - .menuButton(new MenuButtonWebApp("webapp", new WebAppInfo("https://core.telegram.org")))); + BaseResponse response = bot.setChatMenuButton().chatId(chatId) + .menuButton(new MenuButtonWebApp("webapp", new WebAppInfo("https://core.telegram.org"))) + .execute(); assertTrue(response.isOk()); - response = bot.execute(new SetChatMenuButton().chatId(chatId) - .menuButton(new MenuButtonCommands())); + response = bot.setChatMenuButton().chatId(chatId) + .menuButton(new MenuButtonCommands()) + .execute(); assertTrue(response.isOk()); - response = bot.execute(new SetChatMenuButton().chatId(chatId) - .menuButton(new MenuButtonDefault())); + response = bot.setChatMenuButton().chatId(chatId) + .menuButton(new MenuButtonDefault()) + .execute(); assertTrue(response.isOk()); } @Test public void getChatMenuButton() { MenuButton menu = new MenuButtonCommands(); - BaseResponse set = bot.execute(new SetChatMenuButton().chatId(chatId) - .menuButton(menu)); + BaseResponse set = bot.setChatMenuButton().chatId(chatId) + .menuButton(menu) + .execute(); assertTrue(set.isOk()); - GetChatMenuButtonResponse response = bot.execute(new GetChatMenuButton().chatId(chatId)); + GetChatMenuButtonResponse response = bot.getChatMenuButton().chatId(chatId).execute(); assertTrue(response.isOk()); assertEquals(menu.type(), response.result().type()); } @@ -2184,9 +2187,9 @@ public void getChatMenuButton() { public void sendWebAppInfo() { String text = "gh_app"; String url = "https://github.com/"; - SendResponse response = bot.execute(new SendMessage(chatId, "message with webApp") + SendResponse response = bot.sendMessage(chatId, "message with webApp") .replyMarkup(new InlineKeyboardMarkup(new InlineKeyboardButton(text).webApp(new WebAppInfo(url)))) - ); + .execute(); assertTrue(response.isOk()); InlineKeyboardMarkup markup = response.message().replyMarkup(); @@ -2199,15 +2202,15 @@ public void sendWebAppInfo() { assertNotNull(button.webApp()); assertEquals(url, button.webApp().url()); - response = bot.execute(new SendMessage(chatId, "message with webApp") + response = bot.sendMessage(chatId, "message with webApp") .replyMarkup(new ReplyKeyboardMarkup(new KeyboardButton(text).webAppInfo(new WebAppInfo(url)))) - ); + .execute(); assertTrue(response.isOk()); } @Test public void getMyDefaultAdministratorRights() { - bot.execute(new SetMyDefaultAdministratorRights() + bot.setMyDefaultAdministratorRights() .forChannels(false) .rights(new ChatAdministratorRights() .canManageChat(false) @@ -2221,8 +2224,8 @@ public void getMyDefaultAdministratorRights() { .canEditMessages(false) .canPinMessages(false) .canManageTopics(false) - )); - ChatAdministratorRights rights = bot.execute(new GetMyDefaultAdministratorRights().forChannels(false)).result(); + ).execute(); + ChatAdministratorRights rights = bot.getMyDefaultAdministratorRights().forChannels(false).execute().result(); assertFalse(rights.isAnonymous()); assertFalse(rights.canManageChat()); assertFalse(rights.canDeleteMessages()); @@ -2239,7 +2242,7 @@ public void getMyDefaultAdministratorRights() { @Test public void getForumTopicIconStickers() { - List stickers = bot.execute(new GetForumTopicIconStickers()).stickers(); + List stickers = bot.getForumTopicIconStickers().execute().stickers(); assertFalse(stickers.isEmpty()); } @@ -2247,9 +2250,9 @@ public void getForumTopicIconStickers() { public void createForumTopic() { Integer color = 7322096; String emoji = "5434144690511290129"; - CreateForumTopicResponse createResponse = bot.execute( - new CreateForumTopic(forum, "test_topic").iconColor(color).iconCustomEmojiId(emoji) - ); + CreateForumTopicResponse createResponse = bot.createForumTopic(forum, "test_topic") + .iconColor(color).iconCustomEmojiId(emoji) + .execute(); assertTrue(createResponse.isOk()); ForumTopic topic = createResponse.forumTopic(); assertNotNull(topic); @@ -2257,55 +2260,55 @@ public void createForumTopic() { assertEquals(emoji, topic.iconCustomEmojiId()); String name = "test_topic_edit"; - BaseResponse response = bot.execute( - new EditForumTopic(forum, topic.messageThreadId()).name(name).iconCustomEmojiId("") - ); + BaseResponse response = bot.editForumTopic(forum, topic.messageThreadId()) + .name(name).iconCustomEmojiId("") + .execute(); assertTrue(response.isOk()); - response = bot.execute(new CloseForumTopic(forum, topic.messageThreadId())); + response = bot.closeForumTopic(forum, topic.messageThreadId()).execute(); assertTrue(response.isOk()); - response = bot.execute(new ReopenForumTopic(forum, topic.messageThreadId())); + response = bot.reopenForumTopic(forum, topic.messageThreadId()).execute(); assertTrue(response.isOk()); - response = bot.execute(new DeleteForumTopic(forum, topic.messageThreadId())); + response = bot.deleteForumTopic(forum, topic.messageThreadId()).execute(); assertTrue(response.isOk()); } @Test public void unpinAllForumTopicMessages() { String name = "edit_thread-" + System.currentTimeMillis(); - BaseResponse response = bot.execute(new EditForumTopic(forum, forumEditThread, name, "")); + BaseResponse response = bot.editForumTopic(forum, forumEditThread, name, "").execute(); assertTrue(response.isOk()); - response = bot.execute(new UnpinAllForumTopicMessages(forum, forumEditThread)); + response = bot.unpinAllForumTopicMessages(forum, forumEditThread).execute(); assertTrue(response.isOk()); } @Test public void editGeneralForumTopic() { String name = "General " + System.currentTimeMillis(); - BaseResponse response = bot.execute(new EditGeneralForumTopic(forum, name)); + BaseResponse response = bot.editGeneralForumTopic(forum, name).execute(); assertTrue(response.isOk()); - response = bot.execute(new CloseGeneralForumTopic(forum)); + response = bot.closeGeneralForumTopic(forum).execute(); assertTrue(response.isOk()); - response = bot.execute(new HideGeneralForumTopic(forum)); + response = bot.hideGeneralForumTopic(forum).execute(); assertTrue(response.isOk()); - response = bot.execute(new UnhideGeneralForumTopic(forum)); + response = bot.unhideGeneralForumTopic(forum).execute(); assertTrue(response.isOk()); - response = bot.execute(new ReopenGeneralForumTopic(forum)); + response = bot.reopenGeneralForumTopic(forum).execute(); assertTrue(response.isOk()); } @Test public void setMyDescription() { - BaseResponse response = bot.execute(new SetMyDescription().description("desc").languageCode("en")); + BaseResponse response = bot.setMyDescription().description("desc").languageCode("en").execute(); assertTrue(response.isOk()); - GetMyDescriptionResponse descResponse = bot.execute(new GetMyDescription().languageCode("en")); + GetMyDescriptionResponse descResponse = bot.getMyDescription().languageCode("en").execute(); assertTrue(descResponse.isOk()); BotDescription desc = descResponse.botDescription(); assertNotNull(desc); @@ -2314,10 +2317,10 @@ public void setMyDescription() { @Test public void setMyShortDescription() { - BaseResponse response = bot.execute(new SetMyShortDescription().description("short_desc").languageCode("en")); + BaseResponse response = bot.setMyShortDescription().description("short_desc").languageCode("en").execute(); assertTrue(response.isOk()); - GetMyShortDescriptionResponse descResponse = bot.execute(new GetMyShortDescription().languageCode("en")); + GetMyShortDescriptionResponse descResponse = bot.getMyShortDescription().languageCode("en").execute(); assertTrue(descResponse.isOk()); BotShortDescription desc = descResponse.botShortDescription(); assertNotNull(desc); @@ -2326,17 +2329,17 @@ public void setMyShortDescription() { @Test public void setMyName() { - BaseResponse response = bot.execute(new SetMyName().name("name").languageCode("en")); + BaseResponse response = bot.setMyName().name("name").languageCode("en").execute(); assertTrue(response.isOk()); - GetMyNameResponse nameResponse = bot.execute(new GetMyName().languageCode("en")); + GetMyNameResponse nameResponse = bot.getMyName().languageCode("en").execute(); assertTrue(nameResponse.isOk()); assertEquals("name", nameResponse.botName().name()); } @Test public void answerWebAppQuery() { - SentWebAppMessageResponse response = bot.execute(new AnswerWebAppQuery("123", new InlineQueryResultArticle("1", "title", "text"))); + SentWebAppMessageResponse response = bot.answerWebAppQuery("123", new InlineQueryResultArticle("1", "title", "text")).execute(); assertFalse(response.isOk()); assertEquals("Bad Request: query is too old and response timeout expired or query ID is invalid", response.description()); assertNull(response.sentWebAppMessage()); diff --git a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/AqivnBot.java b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/AqivnBot.java index b6f139c3..dd2d224e 100644 --- a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/AqivnBot.java +++ b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/AqivnBot.java @@ -42,7 +42,7 @@ TelegramBot getBot() { @Override void onWebhookUpdate(Update update) { - bot.execute(new SendMessage(update.message().chat().id(), getAqi()).replyMarkup(simpleKeyboard())); + bot.sendMessage(update.message().chat().id(), getAqi()).replyMarkup(simpleKeyboard()).execute(); } private String getAqi() { @@ -95,7 +95,7 @@ public static void main(String[] args) throws IOException { .map(bot::documentToAqiString) .subscribe(str -> { System.out.println(str); - bot.bot.execute(new SendMessage(51314083, str)); + bot.bot.sendMessage(51314083, str).execute(); }); diff --git a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/KursBot.java b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/KursBot.java index 44d77801..dd5136b4 100644 --- a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/KursBot.java +++ b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/KursBot.java @@ -66,7 +66,7 @@ public Object handle(Request request, Response response) throws Exception { default: message = getAllKurs(); } - bot.execute(new SendMessage(chatId, message).replyMarkup(new ReplyKeyboardMarkup(new String[]{BUTTON_CB}, new String[]{BUTTON_EXCHANGE}))); + bot.sendMessage(chatId, message).replyMarkup(new ReplyKeyboardMarkup(new String[]{BUTTON_CB}, new String[]{BUTTON_EXCHANGE})).execute(); return "ok"; } diff --git a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/Main.java b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/Main.java index ebc0ee84..21a2d29f 100644 --- a/sample/src/main/java/com/pengrad/telegrambot/sample/spark/Main.java +++ b/sample/src/main/java/com/pengrad/telegrambot/sample/spark/Main.java @@ -24,7 +24,7 @@ public static void main(String[] args) throws Exception { post("/" + botHandler.getToken(), botHandler); String appSite = System.getenv("OPENSHIFT_APP_DNS"); - botHandler.getBot().execute(new SetWebhook().url(appSite + "/" + botHandler.getToken())); + botHandler.getBot().setWebhook().url(appSite + "/" + botHandler.getToken()).execute(); } private static class Test implements Route {