diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8f4c54b..9a4b1c7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - jdk: [ '8', '19' ] + jdk: [ '11', '21' ] steps: - name: Setup Java ${{ matrix.jdk }} JDK uses: actions/setup-java@v3 diff --git a/build.gradle b/build.gradle index dfb70cc..6cee164 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ plugins { } group = 'com.cadiducho' -version = '6.5' -sourceCompatibility = '1.8' +version = '6.6' +sourceCompatibility = JavaVersion.VERSION_11 java { withJavadocJar() diff --git a/src/main/java/com/cadiducho/telegrambotapi/Animation.java b/src/main/java/com/cadiducho/telegrambotapi/Animation.java index ed9e0c0..f38171f 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Animation.java +++ b/src/main/java/com/cadiducho/telegrambotapi/Animation.java @@ -47,7 +47,7 @@ public class Animation { /** * Optional. Animation thumbnail as defined by sender */ - private PhotoSize thumb; + private PhotoSize thumbnail; /** * Optional. Original animation filename as defined by sender diff --git a/src/main/java/com/cadiducho/telegrambotapi/Audio.java b/src/main/java/com/cadiducho/telegrambotapi/Audio.java index 32ce951..0217d70 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Audio.java +++ b/src/main/java/com/cadiducho/telegrambotapi/Audio.java @@ -62,5 +62,5 @@ public class Audio { /** * Optional. Thumbnail of the album cover to which the music file belongs */ - private PhotoSize thumb; + private PhotoSize thumbnail; } diff --git a/src/main/java/com/cadiducho/telegrambotapi/BotAPI.java b/src/main/java/com/cadiducho/telegrambotapi/BotAPI.java index 76841f9..e9c3769 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/BotAPI.java +++ b/src/main/java/com/cadiducho/telegrambotapi/BotAPI.java @@ -16,12 +16,16 @@ import com.cadiducho.telegrambotapi.keyboard.ReplyKeyboardRemove; import com.cadiducho.telegrambotapi.payment.LabeledPrice; import com.cadiducho.telegrambotapi.payment.ShippingOption; +import com.cadiducho.telegrambotapi.sticker.InputSticker; +import com.cadiducho.telegrambotapi.sticker.MaskPosition; +import com.cadiducho.telegrambotapi.sticker.Sticker; +import com.cadiducho.telegrambotapi.sticker.StickerSet; import java.util.List; /** * Interface to build Telegrams Bots - * Telegram Bot API version 6.5 + * Telegram Bot API version 6.6 */ public interface BotAPI { @@ -527,7 +531,7 @@ default Message sendAnimation(Object chat_id, java.io.File animation) throws Tel * @param duration Duration of the animation in seconds * @param width Animation width * @param height Animation height - * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. + * @param thumbnail Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. * @param caption Animation caption (may also be used when resending videos by file_id), 0-1024 characters * @param parse_mode Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. * @param has_spoiler Pass True if the animation needs to be covered with a spoiler animation @@ -539,8 +543,8 @@ default Message sendAnimation(Object chat_id, java.io.File animation) throws Tel * @return {@link Message} * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - default Message sendAnimation(Object chat_id, Object animation, Integer duration, Integer width, Integer height, Object thumb, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { - return sendAnimation(chat_id, null, animation, duration, width, height, thumb, caption, parse_mode, has_spoiler, disable_notification, protect_content, reply_to_message_id, reply_markup); + default Message sendAnimation(Object chat_id, Object animation, Integer duration, Integer width, Integer height, Object thumbnail, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { + return sendAnimation(chat_id, null, animation, duration, width, height, thumbnail, caption, parse_mode, has_spoiler, disable_notification, protect_content, reply_to_message_id, reply_markup); } /** @@ -553,7 +557,7 @@ default Message sendAnimation(Object chat_id, Object animation, Integer duration * @param duration Duration of the animation in seconds * @param width Animation width * @param height Animation height - * @param thumb Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. + * @param thumbnail Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. * @param caption Animation caption (may also be used when resending videos by file_id), 0-1024 characters * @param parse_mode Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. * @param has_spoiler Pass True if the animation needs to be covered with a spoiler animation @@ -565,7 +569,7 @@ default Message sendAnimation(Object chat_id, Object animation, Integer duration * @return {@link Message} * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Message sendAnimation(Object chat_id, Integer message_thread_id, Object animation, Integer duration, Integer width, Integer height, Object thumb, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException; + Message sendAnimation(Object chat_id, Integer message_thread_id, Object animation, Integer duration, Integer width, Integer height, Object thumbnail, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException; /** * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. @@ -1719,6 +1723,40 @@ default List getMyCommands() throws TelegramException { return getMyCommands(null, null); } + /** + * 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. + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param language_code A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. + * @return True on success. + * @throws TelegramException if the method fails in Telegram servers + */ + Boolean setMyDescription(String description, String language_code) throws TelegramException; + + /** + * Use this method to get the current bot description for the given user language. + * @param language_code A two-letter ISO 639-1 language code or an empty string + * @return {@link BotDescription} on success. + * @throws TelegramException if the method fails in Telegram servers + */ + BotDescription getMyDescription(String language_code) throws TelegramException; + + /** + * 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. + * @param short_description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. + * @param language_code A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description. + * @return True on success. + * @throws TelegramException if the method fails in Telegram servers + */ + Boolean setMyShortDescription(String short_description, String language_code) throws TelegramException; + + /** + * Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success. + * @param language_code A two-letter ISO 639-1 language code or an empty string + * @return {@link BotShortDescription} on success. + * @throws TelegramException if the method fails in Telegram servers + */ + BotShortDescription getMyShortDescription(String language_code) throws TelegramException; + /** * Use this method to change the bot's menu button in a private chat, or the default menu button. * @param chat_id Unique identifier for the target private chat. If not specified, default bot's menu button will be changed @@ -1962,7 +2000,7 @@ default Message sendSticker(Object chat_id, java.io.File sticker) throws Telegra * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ default Message sendSticker(Object chat_id, Object sticker, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { - return sendSticker(chat_id, null, sticker, disable_notification, protect_content, reply_to_message_id, reply_markup); + return sendSticker(chat_id, sticker, disable_notification, protect_content, reply_to_message_id, reply_markup); } /** @@ -1971,6 +2009,7 @@ default Message sendSticker(Object chat_id, Object sticker, Boolean disable_noti * @param message_thread_id Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param sticker Sticker to send. You can either pass a file_id as String to resend a sticker that is already on the Telegram servers, * or upload a new sticker using multipart/form-data. + * @param emoji Emoji associated with the sticker; only for just uploaded stickers * @param reply_to_message_id If the message is a reply, ID of the original message * @param disable_notification Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound. * @param reply_markup Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user. @@ -1978,7 +2017,7 @@ default Message sendSticker(Object chat_id, Object sticker, Boolean disable_noti * @return {@link Message} * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Message sendSticker(Object chat_id, Integer message_thread_id, Object sticker, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException; + Message sendSticker(Object chat_id, Integer message_thread_id, Object sticker, String emoji, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException; /** * Use this method to get a sticker set. On success, a StickerSet object is returned. @@ -2010,96 +2049,120 @@ default Message sendSticker(Object chat_id, Object sticker, Boolean disable_noti * @param user_id User identifier of created sticker set owner * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs. 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 png_sticker PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. 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 - * @param tgs_sticker TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements - * @param webm_sticker WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements + * @param stickers A JSON-serialized list of 1-50 initial stickers to be added to the sticker set + * @param sticker_format Format of stickers in the set, must be one of “static”, “animated”, “video” + * @param sticker_type Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created. * @param sticker_type Type of stickers in the set, pass “regular” or “mask”. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created. - * @param emojis One or more emoji corresponding to the sticker - * @param mask_position Optional. A JSON-serialized object for position where the mask should be placed on faces + * @param needs_repainting Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only * @return True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Boolean createNewStickerSet(Long user_id, String name, String title, java.io.File png_sticker, java.io.File tgs_sticker, java.io.File webm_sticker, String sticker_type, String emojis, MaskPosition mask_position) throws TelegramException; + Boolean createNewStickerSet(Long user_id, String name, String title, List stickers, String sticker_format, String sticker_type, Boolean needs_repainting) throws TelegramException; /** - * Use this method to add a new sticker to a set created by the bot. Returns True on success. + * 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 user_id User identifier of sticker set owner * @param name Sticker set name - * @param png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. 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 - * @param tgs_sticker TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements - * @param emojis One or more emoji corresponding to the sticker + * @param sticker A JSON-serialized 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 True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - default Boolean addStickerToSet(Long user_id, String name, java.io.File png_sticker, java.io.File tgs_sticker, String emojis) throws TelegramException { - return addStickerToSet(user_id, name, png_sticker, emojis, null); - } + Boolean addStickerToSet(Long user_id, String name, InputSticker sticker) throws TelegramException; /** - * Use this method to add a new sticker to a set created by the bot. Returns True on success. - * @param user_id User identifier of sticker set owner - * @param name Sticker set name - * @param png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. 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 - * @param emojis One or more emoji corresponding to the 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 True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - default Boolean addStickerToSet(Long user_id, String name, String png_sticker, String emojis) throws TelegramException { - return addStickerToSet(user_id, name, png_sticker, emojis, null); - } + Boolean setStickerPositionInSet(String sticker, Integer position) throws TelegramException; /** - * Use this method to add a new sticker to a set created by the bot. Returns True on success. - * @param user_id User identifier of sticker set owner - * @param name Sticker set name - * @param png_sticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. 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 - * @param emojis One or more emoji corresponding to the sticker - * @param mask_position Optional. A JSON-serialized object for position where the mask should be placed on faces + * 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 True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Boolean addStickerToSet(Long user_id, String name, Object png_sticker, String emojis, MaskPosition mask_position) throws TelegramException; - + Boolean deleteStickerFromSet(String sticker) throws TelegramException; + /** - * 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 + * Use this method to change the {@link com.cadiducho.telegrambotapi.sticker.MaskPosition} of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. + * @param name Sticker set name + * @param mask_position A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position. * @return True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Boolean setStickerPositionInSet(String sticker, Integer position) throws TelegramException; - + Boolean setStickerMaskPosition(String name, com.cadiducho.telegrambotapi.sticker.MaskPosition mask_position) throws TelegramException; + /** - * 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 + * 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 True on success. * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Boolean deleteStickerFromSet(String sticker) throws TelegramException; + Boolean setStickerSetTitle(String name, String title) throws TelegramException; /** * Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only * @param name Sticker set name * @param user_id User identifier of the sticker set owner - * @param thumb A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. + * @param thumbnail A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated 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. * More info on Sending Files ». Animated sticker set thumbnail can't be uploaded via HTTP URL. * @return True on success. * @throws TelegramException */ - Boolean setStickerSetThumb(String name, Long user_id, java.io.File thumb) throws TelegramException; + Boolean setStickerSetThumbnail(String name, Long user_id, java.io.File thumbnail) throws TelegramException; /** * Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only * @param name Sticker set name * @param user_id User identifier of the sticker set owner - * @param thumb A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. + * @param thumbnail A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated 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. * More info on Sending Files ». Animated sticker set thumbnail can't be uploaded via HTTP URL. * @return True on success. - * @throws TelegramException + * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers */ - Boolean setStickerSetThumb(String name, Long user_id, String thumb) throws TelegramException; + Boolean setStickerSetThumbnail(String name, Long user_id, String thumbnail) throws TelegramException; + + /** + * Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. + * @param name Sticker set name + * @param custom_emoji_id Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail. + * @return True on success. + * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers + */ + Boolean setCustomEmojiStickerSetThumbnail(String name, String custom_emoji_id) throws TelegramException; + + /** + * Use this method to delete a sticker set that was created by the bot. Returns True on success. + * @param name Sticker set name + * @return True on success. + * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers + */ + Boolean deleteStickerSet(String name) throws TelegramException; + + /** + * 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 emoji_list A JSON-serialized list of 1-20 emoji associated with the sticker + * @return True on success. + * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers + */ + Boolean setStickerEmojiList(String sticker, List emoji_list) throws TelegramException; + + /** + * 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 + * @param keywords A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters + * @return True on success. + * @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers + */ + Boolean setStickerKeywords(String sticker, List keywords) throws TelegramException; + /** * Use this method to send answers to an inline query. On success, True is returned. diff --git a/src/main/java/com/cadiducho/telegrambotapi/BotDescription.java b/src/main/java/com/cadiducho/telegrambotapi/BotDescription.java new file mode 100644 index 0000000..e40848b --- /dev/null +++ b/src/main/java/com/cadiducho/telegrambotapi/BotDescription.java @@ -0,0 +1,22 @@ +/* + * The MIT License + * + * Copyright 2023 Cadiducho. + * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE + */ + +package com.cadiducho.telegrambotapi; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@ToString +@Getter @Setter +public class BotDescription { + + /** + * The bot's description + */ + private String description; +} diff --git a/src/main/java/com/cadiducho/telegrambotapi/BotShortDescription.java b/src/main/java/com/cadiducho/telegrambotapi/BotShortDescription.java new file mode 100644 index 0000000..a79b1e2 --- /dev/null +++ b/src/main/java/com/cadiducho/telegrambotapi/BotShortDescription.java @@ -0,0 +1,26 @@ +/* + * The MIT License + * + * Copyright 2023 Cadiducho. + * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE + */ + +package com.cadiducho.telegrambotapi; + +import com.squareup.moshi.Json; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * This object represents the bot's short description. + */ +@ToString +@Getter @Setter +public class BotShortDescription { + + /** + * The bot's short description + */ + @Json(name = "short_description") private String shortDescription; +} diff --git a/src/main/java/com/cadiducho/telegrambotapi/Document.java b/src/main/java/com/cadiducho/telegrambotapi/Document.java index 30ee608..b7fbab7 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Document.java +++ b/src/main/java/com/cadiducho/telegrambotapi/Document.java @@ -32,7 +32,7 @@ public class Document { /** * Optional. Document thumbnail as defined by sender */ - private PhotoSize thumb; + private PhotoSize thumbnail; /** * Optional. Original filename as defined by sender diff --git a/src/main/java/com/cadiducho/telegrambotapi/InputMediaAnimation.java b/src/main/java/com/cadiducho/telegrambotapi/InputMediaAnimation.java index d14b10c..2709820 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/InputMediaAnimation.java +++ b/src/main/java/com/cadiducho/telegrambotapi/InputMediaAnimation.java @@ -17,7 +17,7 @@ public class InputMediaAnimation extends InputMedia { * Ignored if the file is not uploaded using multipart/form-data. * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . */ - private Object thumb; + private Object thumbnail; /** * Optional. Animation width diff --git a/src/main/java/com/cadiducho/telegrambotapi/InputMediaAudio.java b/src/main/java/com/cadiducho/telegrambotapi/InputMediaAudio.java index eea070d..13b4379 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/InputMediaAudio.java +++ b/src/main/java/com/cadiducho/telegrambotapi/InputMediaAudio.java @@ -16,7 +16,7 @@ public class InputMediaAudio extends InputMedia { * Ignored if the file is not uploaded using multipart/form-data. * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . */ - private Object thumb; + private Object thumbnail; /** * Optional. Duration of the audio in seconds @@ -33,9 +33,9 @@ public class InputMediaAudio extends InputMedia { */ private String title; - public InputMediaAudio(String media, Object thumb, String caption, ParseMode parseMode, Integer duration, String performer, String title, Boolean disableContentTypeDetection) { + public InputMediaAudio(String media, Object thumbnail, String caption, ParseMode parseMode, Integer duration, String performer, String title, Boolean disableContentTypeDetection) { super("audio", media, caption, parseMode, disableContentTypeDetection); - this.thumb = thumb; + this.thumbnail = thumbnail; this.duration = duration; this.performer = performer; this.title = title; diff --git a/src/main/java/com/cadiducho/telegrambotapi/InputMediaDocument.java b/src/main/java/com/cadiducho/telegrambotapi/InputMediaDocument.java index b13f200..8c426aa 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/InputMediaDocument.java +++ b/src/main/java/com/cadiducho/telegrambotapi/InputMediaDocument.java @@ -16,10 +16,10 @@ public class InputMediaDocument extends InputMedia { * Ignored if the file is not uploaded using multipart/form-data. * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . */ - private Object thumb; + private Object thumbnail; - public InputMediaDocument(String media,Object thumb, String caption, ParseMode parseMode, Boolean disableContentTypeDetection) { + public InputMediaDocument(String media,Object thumbnail, String caption, ParseMode parseMode, Boolean disableContentTypeDetection) { super("document", media, caption, parseMode, disableContentTypeDetection); - this.thumb = thumb; + this.thumbnail = thumbnail; } } diff --git a/src/main/java/com/cadiducho/telegrambotapi/InputMediaVideo.java b/src/main/java/com/cadiducho/telegrambotapi/InputMediaVideo.java index b2ccf28..c9542b9 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/InputMediaVideo.java +++ b/src/main/java/com/cadiducho/telegrambotapi/InputMediaVideo.java @@ -16,7 +16,7 @@ public class InputMediaVideo extends InputMedia { * Ignored if the file is not uploaded using multipart/form-data. * Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . */ - private Object thumb; + private Object thumbnail; /** * Optional. Video width @@ -43,9 +43,9 @@ public class InputMediaVideo extends InputMedia { */ @Json(name = "has_spoiler") private Boolean hasSpoiler; - public InputMediaVideo(String media, Object thumb, String caption, ParseMode parseMode, Integer width, Integer height, Integer duration, Boolean supportsStreaming, Boolean disableContentTypeDetection, Boolean hasSpoiler) { + public InputMediaVideo(String media, Object thumbnail, String caption, ParseMode parseMode, Integer width, Integer height, Integer duration, Boolean supportsStreaming, Boolean disableContentTypeDetection, Boolean hasSpoiler) { super("video", media, caption, parseMode, disableContentTypeDetection); - this.thumb = thumb; + this.thumbnail = thumbnail; this.width = width; this.height = height; this.duration = duration; diff --git a/src/main/java/com/cadiducho/telegrambotapi/Message.java b/src/main/java/com/cadiducho/telegrambotapi/Message.java index 1913bc5..174e1f9 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Message.java +++ b/src/main/java/com/cadiducho/telegrambotapi/Message.java @@ -14,6 +14,7 @@ import com.cadiducho.telegrambotapi.payment.SuccessfulPayment; import java.util.List; +import com.cadiducho.telegrambotapi.sticker.Sticker; import com.squareup.moshi.Json; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/cadiducho/telegrambotapi/TelegramBot.java b/src/main/java/com/cadiducho/telegrambotapi/TelegramBot.java index ce7ba1c..575eeb6 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/TelegramBot.java +++ b/src/main/java/com/cadiducho/telegrambotapi/TelegramBot.java @@ -17,6 +17,10 @@ import com.cadiducho.telegrambotapi.keyboard.ReplyKeyboardRemove; import com.cadiducho.telegrambotapi.payment.LabeledPrice; import com.cadiducho.telegrambotapi.payment.ShippingOption; +import com.cadiducho.telegrambotapi.sticker.InputSticker; +import com.cadiducho.telegrambotapi.sticker.MaskPosition; +import com.cadiducho.telegrambotapi.sticker.Sticker; +import com.cadiducho.telegrambotapi.sticker.StickerSet; import com.cadiducho.telegrambotapi.util.ApiResponse; import com.cadiducho.telegrambotapi.util.MediaTypes; import com.cadiducho.telegrambotapi.util.MoshiProvider; @@ -32,7 +36,7 @@ /** * Default implementation to build Telegrams Bots - * Telegram Bot API version 6.5 + * Telegram Bot API version 6.6 */ public class TelegramBot implements BotAPI { @@ -336,7 +340,7 @@ public Message sendVideo(Object chat_id, Integer message_thread_id, Object video @Override - public Message sendAnimation(Object chat_id, Integer message_thread_id, Object animation, Integer duration, Integer width, Integer height, Object thumb, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { + public Message sendAnimation(Object chat_id, Integer message_thread_id, Object animation, Integer duration, Integer width, Integer height, Object thumbnail, String caption, ParseMode parse_mode, Boolean has_spoiler, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { Object safeChatId = getSafeChatId(chat_id); final MultipartBody.Builder parameters = bodyBuilder(); @@ -347,7 +351,7 @@ public Message sendAnimation(Object chat_id, Integer message_thread_id, Object a safeAdd(parameters, "width", width); safeAdd(parameters, "height", height); safeAdd(parameters, "caption", caption); - addFile(parameters, "thumb", thumb, MediaTypes.MEDIA_TYPE_PHOTO); + addFile(parameters, "thumbnail", thumbnail, MediaTypes.MEDIA_TYPE_PHOTO); safeAdd(parameters, "parse_mode", parse_mode); safeAdd(parameters, "has_spoiler", has_spoiler); safeAdd(parameters, "disable_notification", disable_notification); @@ -1308,6 +1312,60 @@ public List getMyCommands(BotCommandScope scope, String language_cod return handleRequest(request, Types.newParameterizedType(List.class, BotCommand.class)); } + @Override + public Boolean setMyDescription(String description, String language_code) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "description", description); + safeAdd(parameters, "language_code", language_code); + + final Request request = new Request.Builder() + .url(apiUrl + "setMyDescription") + .post(parameters.build()) + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public BotDescription getMyDescription(String language_code) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "language_code", language_code); + + final Request request = new Request.Builder() + .url(apiUrl + "getMyDescription") + .post(parameters.build()) + .build(); + return handleRequest(request, BotDescription.class); + } + + @Override + public Boolean setMyShortDescription(String short_description, String language_code) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "short_description", short_description); + safeAdd(parameters, "language_code", language_code); + + final Request request = new Request.Builder() + .url(apiUrl + "setMyShortDescription") + .post(parameters.build()) + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public BotShortDescription getMyShortDescription(String language_code) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "language_code", language_code); + + final Request request = new Request.Builder() + .url(apiUrl + "getMyShortDescription") + .post(parameters.build()) + .build(); + return handleRequest(request, BotShortDescription.class); + } + @Override public Boolean setChatMenuButton(Object chat_id, MenuButton menu_button) throws TelegramException { Object safeChatId = getSafeChatId(chat_id); @@ -1527,11 +1585,12 @@ public Boolean deleteWebhook(Boolean drop_pending_updates) throws TelegramExcept } @Override - public Message sendSticker(Object chat_id, Integer message_thread_id, Object sticker, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { + public Message sendSticker(Object chat_id, Integer message_thread_id, Object sticker, String emoji, Boolean disable_notification, Boolean protect_content, Integer reply_to_message_id, Object reply_markup) throws TelegramException { Object safeChatId = getSafeChatId(chat_id); final MultipartBody.Builder parameters = bodyBuilder(); safeAdd(parameters, "chat_id", safeChatId); + safeAdd(parameters, "emoji", emoji); safeAdd(parameters, "message_thread_id", message_thread_id); safeAdd(parameters, "disable_notification", disable_notification); safeAdd(parameters, "protect_content", protect_content); @@ -1584,18 +1643,16 @@ public File uploadStickerFile(Long user_id, java.io.File png_sticker) throws Tel } @Override - public Boolean createNewStickerSet(Long user_id, String name, String title, java.io.File png_sticker, java.io.File tgs_sticker, java.io.File webm_sticker, String sticker_type, String emojis, MaskPosition mask_position) throws TelegramException { + public Boolean createNewStickerSet(Long user_id, String name, String title, List stickers, String sticker_format, String sticker_type, Boolean needs_repainting) throws TelegramException { final MultipartBody.Builder parameters = bodyBuilder(); safeAdd(parameters, "user_id", user_id); safeAdd(parameters, "name", name); safeAdd(parameters, "title", title); + safeAdd(parameters, "stickers", stickers); + safeAdd(parameters, "sticker_format", sticker_format); safeAdd(parameters, "sticker_type", sticker_type); - safeAdd(parameters, "emojis", emojis); - safeAdd(parameters, "mask_position", mask_position); - addFile(parameters, "png_sticker", png_sticker, MediaTypes.MEDIA_TYPE_PHOTO); - addFile(parameters, "tgs_sticker", png_sticker, MediaTypes.MEDIA_TYPE_PHOTO); - addFile(parameters, "webm_sticker", webm_sticker, MediaTypes.MEDIA_TYPE_PHOTO); + safeAdd(parameters, "needs_repainting", needs_repainting); final Request request = new Request.Builder() .url(apiUrl + "createNewStickerSet") @@ -1604,14 +1661,12 @@ public Boolean createNewStickerSet(Long user_id, String name, String title, java } @Override - public Boolean addStickerToSet(Long user_id, String name, Object png_sticker, String emojis, MaskPosition mask_position) throws TelegramException { + public Boolean addStickerToSet(Long user_id, String name, InputSticker sticker) throws TelegramException { final MultipartBody.Builder parameters = bodyBuilder(); safeAdd(parameters, "user_id", user_id); safeAdd(parameters, "name", name); - safeAdd(parameters, "emojis", emojis); - safeAdd(parameters, "mask_position", mask_position); - addFile(parameters, "png_sticker", png_sticker, MediaTypes.MEDIA_TYPE_APPLICATION); + safeAdd(parameters, "sticker", sticker); final Request request = new Request.Builder() .url(apiUrl + "addStickerToSet") @@ -1645,29 +1700,106 @@ public Boolean deleteStickerFromSet(String sticker) throws TelegramException { } @Override - public Boolean setStickerSetThumb(String name, Long user_id, java.io.File thumb) throws TelegramException { + public Boolean setStickerMaskPosition(String name, MaskPosition mask_position) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "name", name); + safeAdd(parameters, "mask_position", mask_position); + + final Request request = new Request.Builder() + .url(apiUrl + "setStickerMaskPosition") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean setStickerSetTitle(String name, String title) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "name", name); + safeAdd(parameters, "title", title); + + final Request request = new Request.Builder() + .url(apiUrl + "setStickerSetTitle") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean setStickerSetThumbnail(String name, Long user_id, java.io.File thumbnail) throws TelegramException { final MultipartBody.Builder parameters = bodyBuilder(); safeAdd(parameters, "name", name); safeAdd(parameters, "user_id", user_id); - addFile(parameters, "thumb", thumb, MediaTypes.MEDIA_TYPE_PHOTO); + addFile(parameters, "thumbnail", thumbnail, MediaTypes.MEDIA_TYPE_PHOTO); final Request request = new Request.Builder() - .url(apiUrl + "setStickerSetThumb") + .url(apiUrl + "setStickerSetThumbnail") .build(); return handleRequest(request, Boolean.class); } @Override - public Boolean setStickerSetThumb(String name, Long user_id, String thumb) throws TelegramException { + public Boolean setStickerSetThumbnail(String name, Long user_id, String thumbnail) throws TelegramException { final MultipartBody.Builder parameters = bodyBuilder(); safeAdd(parameters, "name", name); safeAdd(parameters, "user_id", user_id); - safeAdd(parameters, "thumb", thumb); + safeAdd(parameters, "thumbnail", thumbnail); + + final Request request = new Request.Builder() + .url(apiUrl + "setStickerSetThumbnail") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean setCustomEmojiStickerSetThumbnail(String name, String custom_emoji_id) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "name", name); + safeAdd(parameters, "custom_emoji_id", custom_emoji_id); + + final Request request = new Request.Builder() + .url(apiUrl + "setCustomEmojiStickerSetThumbnail") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean deleteStickerSet(String name) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "name", name); + + final Request request = new Request.Builder() + .url(apiUrl + "deleteStickerSet") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean setStickerEmojiList(String sticker, List emoji_list) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "sticker", sticker); + safeAdd(parameters, "emoji_list", emoji_list); + + final Request request = new Request.Builder() + .url(apiUrl + "setStickerEmojiList") + .build(); + return handleRequest(request, Boolean.class); + } + + @Override + public Boolean setStickerKeywords(String sticker, List keywords) throws TelegramException { + final MultipartBody.Builder parameters = bodyBuilder(); + + safeAdd(parameters, "sticker", sticker); + safeAdd(parameters, "keywords", keywords); final Request request = new Request.Builder() - .url(apiUrl + "setStickerSetThumb") + .url(apiUrl + "setStickerKeywords") .build(); return handleRequest(request, Boolean.class); } diff --git a/src/main/java/com/cadiducho/telegrambotapi/Video.java b/src/main/java/com/cadiducho/telegrambotapi/Video.java index d228b14..918150b 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Video.java +++ b/src/main/java/com/cadiducho/telegrambotapi/Video.java @@ -47,7 +47,7 @@ public class Video { /** * Optional. Video thumbnail */ - private PhotoSize thumb; + private PhotoSize thumbnail; /** * Optional. Original filename as defined by sender diff --git a/src/main/java/com/cadiducho/telegrambotapi/VideoNote.java b/src/main/java/com/cadiducho/telegrambotapi/VideoNote.java index 49dcefc..18a9e65 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/VideoNote.java +++ b/src/main/java/com/cadiducho/telegrambotapi/VideoNote.java @@ -42,7 +42,7 @@ public class VideoNote { /** * Optional. Video thumbnail */ - private PhotoSize thumb; + private PhotoSize thumbnail; /** * Optional. File size diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultArticle.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultArticle.java index 914cc66..a65a5d5 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultArticle.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultArticle.java @@ -58,17 +58,17 @@ public class InlineQueryResultArticle extends InlineQueryResult { /** * Optional. Url of the thumbnail for the result */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Thumbnail width */ - @Json(name = "thumb_width") private Integer thumbWidth; + @Json(name = "thumbnail_width") private Integer thumbnailWidth; /** * Optional. Thumbnail height */ - @Json(name = "thumb_height") private Integer thumbHeight; + @Json(name = "thumbnail_height") private Integer thumbnailHeight; public InlineQueryResultArticle() { super("article"); @@ -94,15 +94,15 @@ public InlineQueryResultArticle(String title, String messageText) { * @param url Optional. URL of the result * @param hideUrl Optional. Pass True, if you don't want the URL to be shown in the message * @param description Optional. Short description of the result - * @param thumbUrl Optional. Url of the thumbnail for the result - * @param thumbWidth Optional. Thumbnail width - * @param thumbHeight Optional. Thumbnail height + * @param thumbnailUrl Optional. Url of the thumbnail for the result + * @param thumbnailWidth Optional. Thumbnail width + * @param thumbnailHeight Optional. Thumbnail height * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message to be sent */ public InlineQueryResultArticle(String title, String messageText, ParseMode parseMode, Boolean disableWebPagePreview, String url, Boolean hideUrl, String description, - String thumbUrl, Integer thumbWidth, Integer thumbHeight, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { + String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.title = title; this.messageText = messageText; @@ -111,9 +111,9 @@ public InlineQueryResultArticle(String title, String messageText, ParseMode pars this.url = url; this.hideUrl = hideUrl; this.description = description; - this.thumbUrl = thumbUrl; - this.thumbWidth = thumbWidth; - this.thumbHeight = thumbHeight; + this.thumbnailUrl = thumbnailUrl; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; this.replyMarkup = replyMarkup; this.inputMessageContent = inputMessageContent; } diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultContact.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultContact.java index 29982dd..268da04 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultContact.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultContact.java @@ -43,17 +43,17 @@ public class InlineQueryResultContact extends InlineQueryResult { /** * Optional. URL of the thumbnail (jpeg only) for the file */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Thumbnail width */ - @Json(name = "thumb_width") private Integer thumbWidth; + @Json(name = "thumbnail_width") private Integer thumbnailWidth; /** * Optional. Thumbnail height */ - @Json(name = "thumb_height") private Integer thumbHeight; + @Json(name = "thumbnail_height") private Integer thumbnailHeight; public InlineQueryResultContact() { super("contact"); @@ -75,22 +75,22 @@ public InlineQueryResultContact(String phoneNumber, String firstName) { * @param phoneNumber Contact's phone number * @param firstName Contact's first name * @param lastName Optional. Contact's last name - * @param thumbUrl Optional. URL of the thumbnail (jpeg only) for the file - * @param thumbWidth Optional. Thumbnail width - * @param thumbHeight Optional. Thumbnail height + * @param thumbnailUrl Optional. URL of the thumbnail (jpeg only) for the file + * @param thumbnailWidth Optional. Thumbnail width + * @param thumbnailHeight Optional. Thumbnail height * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ public InlineQueryResultContact(String phoneNumber, String firstName, String lastName, - String thumbUrl, Integer thumbWidth, Integer thumbHeight, + String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.phoneNumber = phoneNumber; this.firstName = firstName; this.lastName = lastName; - this.thumbUrl = thumbUrl; - this.thumbWidth = thumbWidth; - this.thumbHeight = thumbHeight; + this.thumbnailUrl = thumbnailUrl; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; this.replyMarkup = replyMarkup; this.inputMessageContent = inputMessageContent; } diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultDocument.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultDocument.java index d762a6d..342437c 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultDocument.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultDocument.java @@ -49,17 +49,17 @@ public class InlineQueryResultDocument extends InlineQueryResult { /** * Optional. URL of the thumbnail (jpeg only) for the file */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Thumbnail width */ - @Json(name = "thumb_width") private Integer thumbWidth; + @Json(name = "thumbnail_width") private Integer thumbnailWidth; /** * Optional. Thumbnail height */ - @Json(name = "thumb_height") private Integer thumbHeight; + @Json(name = "thumbnail_height") private Integer thumbnailHeight; public InlineQueryResultDocument() { super("document"); @@ -85,14 +85,14 @@ public InlineQueryResultDocument(String documentUrl, String title, String mimeTy * @param title Title for the result * @param caption Optional. Caption of the document to be sent, 0-200 characters * @param description Optional. Short description of the result - * @param thumbUrl Optional. URL of the thumbnail (jpeg only) for the file - * @param thumbWidth Optional. Thumbnail width - * @param thumbHeight Optional. Thumbnail height + * @param thumbnailUrl Optional. URL of the thumbnail (jpeg only) for the file + * @param thumbnailWidth Optional. Thumbnail width + * @param thumbnailHeight Optional. Thumbnail height * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ public InlineQueryResultDocument(String documentUrl, String title, String mimeType, String caption, - String description, String thumbUrl, Integer thumbWidth, Integer thumbHeight, + String description, String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.documentUrl = documentUrl; @@ -100,9 +100,9 @@ public InlineQueryResultDocument(String documentUrl, String title, String mimeTy this.mimeType = mimeType; this.caption = caption; this.description = description; - this.thumbUrl = thumbUrl; - this.thumbWidth = thumbWidth; - this.thumbHeight = thumbHeight; + this.thumbnailUrl = thumbnailUrl; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; this.replyMarkup = replyMarkup; this.inputMessageContent = inputMessageContent; } diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultGif.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultGif.java index 17ba583..9dd5bde 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultGif.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultGif.java @@ -42,9 +42,14 @@ public class InlineQueryResultGif extends InlineQueryResult { @Json(name = "gif_duration") private Integer gifDuration; /** - * URL of the static thumbnail for the result (jpeg or gif) + * URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; + + /** + * Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + */ + @Json(name = "thumbnail_mime_type") private String thumbnailMimeType; /** * Optional. Title for the result @@ -68,12 +73,12 @@ public InlineQueryResultGif() { /** * * @param gifUrl A valid URL for the GIF file. File size must not exceed 1MB - * @param thumbUrl URL of the static thumbnail for the result (jpeg or gif) + * @param thumbnailUrl URL of the static thumbnail for the result (jpeg or gif) */ - public InlineQueryResultGif(String gifUrl, String thumbUrl) { + public InlineQueryResultGif(String gifUrl, String thumbnailUrl) { this(); this.gifUrl = gifUrl; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; } /** @@ -81,7 +86,7 @@ public InlineQueryResultGif(String gifUrl, String thumbUrl) { * @param gifUrl A valid URL for the GIF file. File size must not exceed 1MB * @param gifWidth Optional. Width of the GIF * @param gifHeight Optional. Height of the GIF - * @param thumbUrl URL of the static thumbnail for the result (jpeg or gif) + * @param thumbnailUrl URL of the static thumbnail for the result (jpeg or gif) * @param title Optional. Title for the result * @param caption Optional. Caption of the GIF file to be sent, 0-200 characters * @param parseMode Optional. Send “Markdown”, if you want Telegram apps to show @@ -90,13 +95,13 @@ public InlineQueryResultGif(String gifUrl, String thumbUrl) { * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ - public InlineQueryResultGif(String gifUrl, Integer gifWidth, Integer gifHeight, String thumbUrl, String title, + public InlineQueryResultGif(String gifUrl, Integer gifWidth, Integer gifHeight, String thumbnailUrl, String title, String caption, ParseMode parseMode, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.gifUrl = gifUrl; this.gifWidth = gifWidth; this.gifHeight = gifHeight; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; this.title = title; this.caption = caption; this.parseMode = parseMode; diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultLocation.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultLocation.java index f25ce30..8ddc912 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultLocation.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultLocation.java @@ -58,17 +58,17 @@ public class InlineQueryResultLocation extends InlineQueryResult { /** * Optional. URL of the thumbnail (jpeg only) for the file */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Thumbnail width */ - @Json(name = "thumb_width") private Integer thumbWidth; + @Json(name = "thumbnail_width") private Integer thumbnailWidth; /** * Optional. Thumbnail height */ - @Json(name = "thumb_height") private Integer thumbHeight; + @Json(name = "thumbnail_height") private Integer thumbnailHeight; public InlineQueryResultLocation() { super("location"); @@ -92,22 +92,22 @@ public InlineQueryResultLocation(String title, Float latitude, Float longitude) * @param title Location title * @param latitude Location latitude in degrees * @param longitude Location longitude in degrees - * @param thumbUrl Optional. URL of the thumbnail (jpeg only) for the file - * @param thumbWidth Optional. Thumbnail width - * @param thumbHeight Optional. Thumbnail height + * @param thumbnailUrl Optional. URL of the thumbnail (jpeg only) for the file + * @param thumbnailWidth Optional. Thumbnail width + * @param thumbnailHeight Optional. Thumbnail height * @param livePeriod Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ - public InlineQueryResultLocation(String title, Float latitude, Float longitude, String thumbUrl, Integer thumbWidth, Integer thumbHeight, Integer livePeriod, + public InlineQueryResultLocation(String title, Float latitude, Float longitude, String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight, Integer livePeriod, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.title = title; this.latitude = latitude; this.longitude = longitude; - this.thumbUrl = thumbUrl; - this.thumbWidth = thumbWidth; - this.thumbHeight = thumbHeight; + this.thumbnailUrl = thumbnailUrl; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; this.livePeriod = livePeriod; this.replyMarkup = replyMarkup; this.inputMessageContent = inputMessageContent; diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultMpeg4Gif.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultMpeg4Gif.java index 1e32e8f..a71ca24 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultMpeg4Gif.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultMpeg4Gif.java @@ -43,9 +43,14 @@ public class InlineQueryResultMpeg4Gif extends InlineQueryResult { @Json(name = "mpeg4_duration") private Integer mpeg4Duration; /** - * URL of the static thumbnail (jpeg or gif) for the result + * URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; + + /** + * Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + */ + @Json(name = "thumbnail_mime_type") private String thumbnailMimeType; /** * Optional. Title for the result @@ -69,18 +74,18 @@ public InlineQueryResultMpeg4Gif() { /** * * @param mpeg4Url A valid URL for the MP4 file. File size must not exceed 1MB - * @param thumbUrl URL of the static thumbnail (jpeg or gif) for the result + * @param thumbnailUrl URL of the static thumbnail (jpeg or gif) for the result */ - public InlineQueryResultMpeg4Gif(String mpeg4Url, String thumbUrl) { + public InlineQueryResultMpeg4Gif(String mpeg4Url, String thumbnailUrl) { this(); this.mpeg4Url = mpeg4Url; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; } /** * * @param mpeg4Url A valid URL for the MP4 file. File size must not exceed 1MB - * @param thumbUrl URL of the static thumbnail (jpeg or gif) for the result + * @param thumbnailUrl URL of the static thumbnail (jpeg or gif) for the result * @param mpeg4Width Optional. Video width * @param mpeg4Height Optional. Video height * @param title Optional. Title for the result @@ -91,14 +96,14 @@ public InlineQueryResultMpeg4Gif(String mpeg4Url, String thumbUrl) { * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ - public InlineQueryResultMpeg4Gif(String mpeg4Url, String thumbUrl, Integer mpeg4Width, Integer mpeg4Height, + public InlineQueryResultMpeg4Gif(String mpeg4Url, String thumbnailUrl, Integer mpeg4Width, Integer mpeg4Height, String title, String caption, ParseMode parseMode, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.mpeg4Url = mpeg4Url; this.mpeg4Width = mpeg4Width; this.mpeg4Height = mpeg4Height; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; this.title = title; this.caption = caption; this.parseMode = parseMode; diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultPhoto.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultPhoto.java index ecd2c28..f8bbb63 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultPhoto.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultPhoto.java @@ -39,7 +39,7 @@ public class InlineQueryResultPhoto extends InlineQueryResult { /** * URL of the thumbnail for the photo */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Title for the result @@ -63,18 +63,18 @@ public InlineQueryResultPhoto() { /** * * @param photoUrl A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB - * @param thumbUrl URL of the thumbnail for the photo + * @param thumbnailUrl URL of the thumbnail for the photo */ - public InlineQueryResultPhoto(String photoUrl, String thumbUrl) { + public InlineQueryResultPhoto(String photoUrl, String thumbnailUrl) { this(); this.photoUrl = photoUrl; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; } /** * * @param photoUrl A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB - * @param thumbUrl URL of the thumbnail for the photo + * @param thumbnailUrl URL of the thumbnail for the photo * @param photoWidth Optional. Width of the photo * @param photoHeight Optional. Height of the photo * @param title Optional. Title for the result @@ -83,13 +83,13 @@ public InlineQueryResultPhoto(String photoUrl, String thumbUrl) { * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ - public InlineQueryResultPhoto(String photoUrl, String thumbUrl, Integer photoWidth, Integer photoHeight, + public InlineQueryResultPhoto(String photoUrl, String thumbnailUrl, Integer photoWidth, Integer photoHeight, String title, String description, String caption, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.photoUrl = photoUrl; this.photoWidth = photoWidth; this.photoHeight = photoHeight; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; this.title = title; this.description = description; this.caption = caption; diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVenue.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVenue.java index f8c2519..edb16f8 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVenue.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVenue.java @@ -53,17 +53,17 @@ public class InlineQueryResultVenue extends InlineQueryResult { /** * Optional. URL of the thumbnail (jpeg only) for the file */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Optional. Thumbnail width */ - @Json(name = "thumb_width") private Integer thumbWidth; + @Json(name = "thumbnail_width") private Integer thumbnailWidth; /** * Optional. Thumbnail height */ - @Json(name = "thumb_height") private Integer thumbHeight; + @Json(name = "thumbnail_height") private Integer thumbnailHeight; public InlineQueryResultVenue() { super("venue"); @@ -92,14 +92,14 @@ public InlineQueryResultVenue(String title, String address, Float latitude, Floa * @param foursquareType Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) * @param latitude Location latitude in degrees * @param longitude Location longitude in degrees - * @param thumbUrl Optional. URL of the thumbnail (jpeg only) for the file - * @param thumbWidth Optional. Thumbnail width - * @param thumbHeight Optional. Thumbnail height + * @param thumbnailUrl Optional. URL of the thumbnail (jpeg only) for the file + * @param thumbnailWidth Optional. Thumbnail width + * @param thumbnailHeight Optional. Thumbnail height * @param replyMarkup Optional. Inline keyboard attached to the message * @param inputMessageContent Optional. Content of the message */ public InlineQueryResultVenue(String title, String address, String foursquareId, String foursquareType, Float latitude, Float longitude, - String thumbUrl, Integer thumbWidth, Integer thumbHeight, + String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.title = title; @@ -108,9 +108,9 @@ public InlineQueryResultVenue(String title, String address, String foursquareId, this.foursquareType = foursquareType; this.latitude = latitude; this.longitude = longitude; - this.thumbUrl = thumbUrl; - this.thumbWidth = thumbWidth; - this.thumbHeight = thumbHeight; + this.thumbnailUrl = thumbnailUrl; + this.thumbnailWidth = thumbnailWidth; + this.thumbnailHeight = thumbnailHeight; this.replyMarkup = replyMarkup; this.inputMessageContent = inputMessageContent; } diff --git a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVideo.java b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVideo.java index 931e32f..fc5bc48 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVideo.java +++ b/src/main/java/com/cadiducho/telegrambotapi/inline/InlineQueryResultVideo.java @@ -65,7 +65,7 @@ public class InlineQueryResultVideo extends InlineQueryResult { /** * URL of the thumbnail (jpeg only) for the video */ - @Json(name = "thumb_url") private String thumbUrl; + @Json(name = "thumbnail_url") private String thumbnailUrl; /** * Title for the result @@ -86,15 +86,15 @@ public InlineQueryResultVideo() { * @param videoUrl A valid URL for the embedded video player or video file * @param mimeType Mime type of the content of video url, “text/html” or “video/mp4” * @param messageText Text of the message to be sent with the video, 1-512 characters - * @param thumbUrl URL of the thumbnail (jpeg only) for the video + * @param thumbnailUrl URL of the thumbnail (jpeg only) for the video * @param title Title for the result */ - public InlineQueryResultVideo(String videoUrl, String mimeType, String messageText, String thumbUrl, String title) { + public InlineQueryResultVideo(String videoUrl, String mimeType, String messageText, String thumbnailUrl, String title) { this(); this.videoUrl = videoUrl; this.mimeType = mimeType; this.messageText = messageText; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; this.title = title; } @@ -110,7 +110,7 @@ public InlineQueryResultVideo(String videoUrl, String mimeType, String messageTe * @param videoWidth Optional. Video width * @param videoHeight Optional. Video height * @param videoDuration Optional. Video duration in seconds - * @param thumbUrl URL of the thumbnail (jpeg only) for the video + * @param thumbnailUrl URL of the thumbnail (jpeg only) for the video * @param title Title for the result * @param description Optional. Short description of the result * @param replyMarkup Optional. Inline keyboard attached to the message @@ -118,7 +118,7 @@ public InlineQueryResultVideo(String videoUrl, String mimeType, String messageTe */ public InlineQueryResultVideo(String videoUrl, String mimeType, String messageText, ParseMode parseMode, Boolean disableWebPagePreview, Integer videoWidth, Integer videoHeight, - Integer videoDuration, String thumbUrl, String title, String description, + Integer videoDuration, String thumbnailUrl, String title, String description, InlineKeyboardMarkup replyMarkup, InputMessageContent inputMessageContent) { this(); this.videoUrl = videoUrl; @@ -129,7 +129,7 @@ public InlineQueryResultVideo(String videoUrl, String mimeType, String messageTe this.videoWidth = videoWidth; this.videoHeight = videoHeight; this.videoDuration = videoDuration; - this.thumbUrl = thumbUrl; + this.thumbnailUrl = thumbnailUrl; this.title = title; this.description = description; this.replyMarkup = replyMarkup; diff --git a/src/main/java/com/cadiducho/telegrambotapi/sticker/InputSticker.java b/src/main/java/com/cadiducho/telegrambotapi/sticker/InputSticker.java new file mode 100644 index 0000000..f4b29d5 --- /dev/null +++ b/src/main/java/com/cadiducho/telegrambotapi/sticker/InputSticker.java @@ -0,0 +1,39 @@ +/* + * The MIT License + * + * Copyright 2023 Cadiducho. + * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE + */ + +package com.cadiducho.telegrambotapi.sticker; + +import com.squareup.moshi.Json; + +import java.util.List; + +/** + * This object describes a sticker to be added to a sticker set. + */ +public class InputSticker { + + /** + * 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://” to upload a new one using multipart/form-data under name. Animated and video stickers can't be uploaded via HTTP URL. + */ + private Object sticker; + + /** + * List of 1-20 emoji associated with the sticker + */ + private List emoji_list; + + /** + * Optional. Position where the mask should be placed on faces. For “mask” stickers only. + */ + @Json(name = "mask_position") private MaskPosition maskPosition; + + /** + * Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only. + */ + private List keywords; + +} diff --git a/src/main/java/com/cadiducho/telegrambotapi/MaskPosition.java b/src/main/java/com/cadiducho/telegrambotapi/sticker/MaskPosition.java similarity index 96% rename from src/main/java/com/cadiducho/telegrambotapi/MaskPosition.java rename to src/main/java/com/cadiducho/telegrambotapi/sticker/MaskPosition.java index 134b3c7..c916c1f 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/MaskPosition.java +++ b/src/main/java/com/cadiducho/telegrambotapi/sticker/MaskPosition.java @@ -5,7 +5,7 @@ * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE */ -package com.cadiducho.telegrambotapi; +package com.cadiducho.telegrambotapi.sticker; import com.squareup.moshi.Json; import lombok.Getter; diff --git a/src/main/java/com/cadiducho/telegrambotapi/Sticker.java b/src/main/java/com/cadiducho/telegrambotapi/sticker/Sticker.java similarity index 82% rename from src/main/java/com/cadiducho/telegrambotapi/Sticker.java rename to src/main/java/com/cadiducho/telegrambotapi/sticker/Sticker.java index fde8dc6..c184f64 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/Sticker.java +++ b/src/main/java/com/cadiducho/telegrambotapi/sticker/Sticker.java @@ -5,8 +5,10 @@ * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE */ -package com.cadiducho.telegrambotapi; +package com.cadiducho.telegrambotapi.sticker; +import com.cadiducho.telegrambotapi.File; +import com.cadiducho.telegrambotapi.PhotoSize; import com.squareup.moshi.Json; import lombok.Getter; import lombok.Setter; @@ -54,7 +56,7 @@ public class Sticker { /** * Optional. Sticker thumbnail in .webp or .jpg format */ - private PhotoSize thumb; + private PhotoSize thumbnail; /** * Optional. Emoji associated with the sticker @@ -80,6 +82,11 @@ public class Sticker { * Optional. For custom emoji stickers, unique identifier of the custom emoji */ @Json(name = "custom_emoji_id") private MaskPosition customEmojiId; + + /** + * Optional. True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places + */ + @Json(name = "needs_repainting") private Boolean needsRepainting; /** * Optional. File size diff --git a/src/main/java/com/cadiducho/telegrambotapi/StickerSet.java b/src/main/java/com/cadiducho/telegrambotapi/sticker/StickerSet.java similarity index 91% rename from src/main/java/com/cadiducho/telegrambotapi/StickerSet.java rename to src/main/java/com/cadiducho/telegrambotapi/sticker/StickerSet.java index 03a7f9e..4936611 100644 --- a/src/main/java/com/cadiducho/telegrambotapi/StickerSet.java +++ b/src/main/java/com/cadiducho/telegrambotapi/sticker/StickerSet.java @@ -5,10 +5,11 @@ * Read more in https://github.com/Cadiducho/Telegram-Bot-API/blob/master/LICENSE */ -package com.cadiducho.telegrambotapi; +package com.cadiducho.telegrambotapi.sticker; import java.util.List; +import com.cadiducho.telegrambotapi.PhotoSize; import com.squareup.moshi.Json; import lombok.Getter; import lombok.Setter; @@ -56,6 +57,6 @@ public class StickerSet { /** * Optional. Sticker set thumbnail in the .WEBP or .TGS format */ - private PhotoSize thumb; + private PhotoSize thumbnail; } diff --git a/src/test/java/com/cadiducho/telegrambotapi/TelegramBotTest.java b/src/test/java/com/cadiducho/telegrambotapi/TelegramBotTest.java index 81e1210..3728b68 100644 --- a/src/test/java/com/cadiducho/telegrambotapi/TelegramBotTest.java +++ b/src/test/java/com/cadiducho/telegrambotapi/TelegramBotTest.java @@ -149,6 +149,26 @@ void setAndGetBotCommands() throws TelegramException { assertEquals(bot.getMyCommands(), list); } + @Nested + class DescriptionTest { + + @Test + void setAndGetBotDescription() throws TelegramException { + String description = "Bot description test"; + String languageCode = "en"; + assertTrue(bot.setMyDescription(description, languageCode)); + assertEquals(bot.getMyDescription(languageCode).getDescription(), description); + } + + @Test + void setAndGetBotShortDescription() throws TelegramException { + String shortDescription = "Bot short description test"; + String languageCode = "en"; + assertTrue(bot.setMyShortDescription(shortDescription, languageCode)); + assertEquals(bot.getMyShortDescription(languageCode).getShortDescription(), shortDescription); + } + } + @Nested class MenuButtonTest {