Skip to content

Commit

Permalink
Telegram Bot API 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiducho committed Jun 28, 2022
1 parent 6994fa7 commit b9ccdbb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If you want use Telegram Bot API as a Maven Dependency simply add repo and artif
<dependency>
<groupId>com.cadiducho</groupId>
<artifactId>TelegramBotAPI</artifactId>
<version>5.6</version>
<version>5.7</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.cadiducho'
version = '5.6'
version = '5.7'
sourceCompatibility = '1.8'

java {
Expand Down
36 changes: 4 additions & 32 deletions src/main/java/com/cadiducho/telegrambotapi/BotAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1461,50 +1461,22 @@ 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
*/
File uploadStickerFile(Long user_id, java.io.File png_sticker) throws TelegramException;

/**
* Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
* @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_&lt;bot username&gt;”. &lt;bot_username&gt; 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
* @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
* @return True on success.
* @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers
*/
default Boolean createNewStickerSet(Long user_id, String name, String title, java.io.File png_sticker, java.io.File tgs_sticker, String emojis) throws TelegramException {
return createNewStickerSet(user_id, name, title, png_sticker, tgs_sticker, emojis, null, null);
}

/**
* Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
* @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_&lt;bot username&gt;”. &lt;bot_username&gt; 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
* @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
* @return True on success.
* @throws com.cadiducho.telegrambotapi.exception.TelegramException if the method fails in Telegram servers
*/
default Boolean createNewStickerSet(Long user_id, String name, String title, String png_sticker, java.io.File tgs_sticker, String emojis) throws TelegramException {
return createNewStickerSet(user_id, name, title, png_sticker, tgs_sticker, emojis, null, null);
}

/**
* Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
* @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_&lt;bot username&gt;”. &lt;bot_username&gt; 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
* @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 emojis One or more emoji corresponding to the sticker
* @param contains_masks Optional. Pass True, if a set of mask stickers should be created
* @param mask_position Optional. A JSON-serialized object for position where the mask should be placed on faces
* @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, Object png_sticker, java.io.File tgs_sticker, String emojis, Boolean contains_masks, MaskPosition mask_position) throws TelegramException;
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 emojis, Boolean contains_masks, MaskPosition mask_position) throws TelegramException;

/**
* Use this method to add a new sticker to a set created by the bot. Returns True on success.
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/cadiducho/telegrambotapi/Sticker.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ public class Sticker {
* See <a href="https://telegram.org/blog/animated-stickers">https://telegram.org/blog/animated-stickers</a>
*/
@Json(name = "is_animated") private Boolean isAnimated;


/**
* True, if the sticker is a video sticker.
* See <a href="https://telegram.org/blog/video-stickers-better-reactions">https://telegram.org/blog/video-stickers-better-reactions</a>
*/
@Json(name = "is_video") private Boolean isVideo;

/**
* Optional. Sticker thumbnail in .webp or .jpg format
*/
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/cadiducho/telegrambotapi/StickerSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public class StickerSet {
* See <a href="https://telegram.org/blog/animated-stickers">https://telegram.org/blog/animated-stickers</a>
*/
@Json(name = "is_animated") private Boolean isAnimated;

/**
* True, if the sticker set contains
* See <a href="https://telegram.org/blog/video-stickers-better-reactions">https://telegram.org/blog/video-stickers-better-reactions</a>
*/
@Json(name = "is_video") private Boolean isVideo;

/**
* True, if the sticker set contains masks
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/cadiducho/telegrambotapi/TelegramBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ public File uploadStickerFile(Long user_id, java.io.File png_sticker) throws Tel
}

@Override
public Boolean createNewStickerSet(Long user_id, String name, String title, Object png_sticker, java.io.File tgs_sticker, String emojis, Boolean contains_masks, MaskPosition mask_position) throws TelegramException {
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 emojis, Boolean contains_masks, MaskPosition mask_position) throws TelegramException {
final MultipartBody.Builder parameters = bodyBuilder();

safeAdd(parameters, "user_id", user_id);
Expand All @@ -1316,6 +1316,7 @@ public Boolean createNewStickerSet(Long user_id, String name, String title, Obje
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);

final Request request = new Request.Builder()
.url(apiUrl + "createNewStickerSet")
Expand Down

0 comments on commit b9ccdbb

Please sign in to comment.